Fix groups so the indices are correct