Fix a few problems reported by cppcheck