Update topsort; add debug method.