Fix some CppCheck reports and Clang compilation

I submit a few fixes after toying around with cppcheck and clang.

Please review since I am not too familiar with the code base. The changes aren't too invasive, however.