Make rebuildPolygon() work properly