Fixes for issues identified by Coverity.
Merge pull request #2 from jamesodhunt/coverity-fixes-20131212

Fixes for issues identified by Coverity.