Some misc. code and formatting tidying.

Partially from what cppcheck is saying, partially from CodeMaid doing
its thing.
A few more misc. code and formatting changes.