Lots of refactoring in the parser