Improvements to the parser, more helpful error messages, fix a crasher