Fix bugs related to semantic indices.
Fix next frame calculation.