Refining segmentation code.