Fixed errors reported by cppcheck