Why does this have an (int) cast? index is declared as long, so the types should match.