Fix issues found by cppcheck

Should address all the quasi-interesting content of #390.