Additional performance fixes

Found by cppcheck.
This is basically all of them.