Better unionPolygons algorithm