Fix for coverity issue 52010
Fix for coverity issue 52012
Fix for coverity issue 52013
Fix for coverity issue 52011
Merge pull request #15 from strykejern/coverity

Coverity fixes by Anders