Fix error when a collection had duplicate entries in it