Polygon and polylines code reduction

Reduce a little bit a code between the 2 classes.
Not important, just a proposal.