Reorder grammar states
Extend and extensions support, fixes #10