Miscellaneous cppcheck fixes

I'm happy to squash things if you feel like these are too many commits for such trivial changes!