guarantee that IndexedSequence always has length when it needs to flipIndices. fix a bug where cached iteration doesnt return the correct length