Make the toposort routine actually detect cycles.