A few fixes for things scrutinizer-ci found

Nowhere near all cleaned up, but it's bedtime now :P

(I'm assuming that it's worth merging these fixes in small chunks rather than all in one go, as the one patch to fix all of them would be unmanagably huge)