Remove unused debug flag.
Fix various problems found by cppcheck