Moved to small functions instead of big macros