Reimplement macroexpansion in terms of middleware