Handle types in grammar better