cleaned up rete-beta part, added comments