build_index now in separate thread