Refactor Macros module