Fix gcc-4.9.2 warnings

Rather than just reporting these individually, I thought I'd have a go at fixing them.