optimize index generator and writer