Fix some issues reported by Coverity Scan