Refactored parsing of macros