Use a hash set instead of tree set for faster lookup.