Fixed defects from coverity scan
Merge pull request #27 from ryanshawty/defect_fixes

Fixed defects from coverity scan