Improved connectVertices.