Fix a few cppcheck findings

See #1436 for my intention. :) I'll rebase this PR (and fix the compile time error I introduced) after #1436 is done.