Major reworking of parser to get error messages