Fixed build_index