clean up the macros and add some documentation