Optimisation of the grammar