Fix some issues detected by Cppcheck