Fix a lot of errors that appeared with cppcheck