Better fix for n-1 bug in split_tranges()