Cppchecking

Ran [CPPCheck](http://cppcheck.sourceforge.net/) and fixed the simple things. Rest of the results are https://gist.github.com/nschonni/7b3d806a0ede8b6428bd