Rewrite macros using staged functions for commutivity