Refactored MacroExpr.scala to reduce code duplication.