Use sets.
Use sorted-set.
Add some more tests.
Revert "Use sorted-set."

This reverts commit ce0d765af647480a565cd4afde5a07994dd38c41.