Ran CppCheck and fixed all mistakes I cared about