Fixed some issues highlighted by CppCheck