Remove giant switch and macros in favor of more concise logic