Add some comments and macros to make the code more readable