Fixed state index bug.