Fix errors found by cppcheck