Fixed problem when index adds duplicate entries.