Use a queue rather than recursively adding arcs.

Also, unify now returns the exact set of arcs, rather than the old lines.