Various code fixes from static analysis
Merge pull request #2 from remram44/code-fixes

Various code fixes from static analysis