Optimized macro output, refactored code.