Minor cleanups

Mostly tidying up macros and constants and removing some unused bits.