Cppcheck analysis

Some issues detected by cppcheck.