Factored some repeated behavior code into some macros.