Fix broken distinct iterator.