All CppCheck warnings about style and performance fixed