Looks like custom functions kept in the functionTable are lost when a new scope is created in TreeInterpreter.ts. I can create a PR for a fix if nobody is working on that at the moment?