Fixed computation of initial index.