Fix up the graph traversal.  I think there's still a bug here.