Move some repetition into a macro

Probably a lot more could be done.