Fix some problems reported by cppcheck