Bunch of clean-up flagged by static code analysis.  Some refactoring to reduce duplicate code, removing unused stuff, etc.
Merge pull request #37 from jnoring/master

Bunch of clean-up flagged by static code analysis.  Some refactoring to ...