Fix n-1 bug in split_tranges()