Fix issues reported by wchen-r7 and mmetince