Added code ensuring indices exist on all collections

@turicas please check and see if that is enough.