cosmetic: move macros to the top of the file, add comments.
merge