Merged in more changes to rete.cpp