Add a more efficient at_index algorithm.