Factor macro expansion code into own module.