Updated parser code to be more efficient and readable.