Fixed some issues reported by cppcheck