Cppcheck warnings

This fixes everything locally except a Cppcheck missing includes error.