BAMPFA-79: Lots of grammar refactoring.