Fix handling of duplicate inserts.