Fix some issues reported by CoverityScan service