Fix typechecking
Rewrite AST generation