Optimizes index rebuild performance and fixes tests