Move parser code into separate class.