[cppcheck] some cppcheck nits and other bugs