Some cleanups in preparation for... other cleanups and features.

Signed-off-by: Chris Riddoch <riddochc@gmail.com>