Reorder segmentation for less runs
Move code into functions in edge generation