Improved closure algorithm

~45% perf improvement on test grammar generation