Fix medium issues reported by Coverity Scan