address review comments - add macros, match style, and fix memory leak