More parsing and some checking / simplification of AST