Tweaks to the order of dupe detection to improve performance