Various fixes from SCA

Fixes like:
- fix typo in help text
- fix format qualifiers
- catch/call by reference
- fix bool comparison using relational operator
- rename variables
- reduce scope of variables
- prefer prefix ++/-- operator for non-trivial interator
- static_cast vs. c-style
- remove unused variables and some unused private functions
- forward error code to caller
- remove twice included headers