Free memory after sorting
Optimized overlaps() function