quick cherry pick of segment code to seperate branch

Not sure how handy it is to you, but here is a seperate pr that should enable segments. Untested, pulled over some polygon code too