Move macros around

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=84491
Move code around