Improve memory management in grammar start state