Clean up core-new (should not be pushed)
rewrite SortedCollection to use topological sorting