Fix some issues reported by freem