Fix some issues reported by Coverity