various fixes on AST generation