substitution sets added to agents dictionary; unbalanced tree bug corrected