Segmentation improvements

Tinkered with segmentation code a fair bit