More randomised cleanups, slowly working through compiler warnings and other cleanups found along the way