Remove some magic numbers; use macros to clarify intent