fix some cppcheck warnings

fix some cppcheck warnings, mostly remove useless code