Seems to have problems with embedded RETEs. Probably there is a bad use of defvar, which should all be replaced by defining an environment for each RETE