Made segment_dat much much faster.