Removes a lot of unused nodes from the grammar.