refactor event model handling of state. add logging.
dispose of preview editor and tool console.
don't parse if bad grammars.
Merge pull request #78 from parrt/master

Big refactoring to handle event-based state better