Factor out common macro operations into utility class