Killed most cppcheck errors found.

Fixes #306