Fix computation of frameIndex, formatting changes