Fix removing of duplicates.