Improvements to scanner and start on parser