Clean up a bunch of horrible and error prone repeated code with a couple of macros