Greatly improved the performance of .unique.string

The previous .unique.string was so slow that it made many operations
slower that they should have been.