memory improvement: do not copy AST for functions