Fixed cppcheck issues and regressions