Fix issue where setIndex would return wrong index for next+prev