Got rid of some code duplication in _index_to_arrays