Refactored grammar