Fix everything flagged by initial coverity scan
Merge pull request #16 from LinuxJedi/coverity-fixes

Fix everything flagged by initial coverity scan