Rewrite of the parser. Engine is starting to work consistently.