Cleanup/refactoring according to cppcheck output.