Merged in some of changes to rete from 9.4 branch.  Passes unit tests.