Miscellaneous cppcheck fixes

Like #268 but for master, not stable-0.8. Sorry!