Speed improvement: fold over set instead of list in addAllToIndex

Altered items:
main, addToIndex, addAllToIndex