Fix some issues reported by krazy2