Cleanup, reworked macros, added pre/post-render hooks