Switch from O(n²) to O(n) duplicate detection

Importing 2374 people was taking 10mins. Now it's 1min.