Refactored so that source nodes are passed to target nodes when added or inserted.