Fixed bug in refine polygons