Fix thread indexes