Fix clang warnings along with some other minor stuff, no logic changes.
mentioned in issue #835 (closed)