Fix issues reported by wchen-r7