Factored out common setup into macros