Tidy up the parsing a bit