Fix for self-intersecting polygons