Refactored a lot of code and simplified some of the parser construction logic.