Cache state transition computations by grammar rule

This results in a huge speed increase