Fixed a few compiler and cppcheck warnings