     
     let s = 1 / q0.magnitude
     let t = 1 / q1.magnitude
-    let start = Point(x: p0.x + a0.y * q0.y * s, y: p0.y - a0.y * q0.x * s)
-    let end = Point(x: p2.x + a1.y * q1.y * t, y: p2.y - a1.y * q1.x * t)
-    
-    let z = Point(x: a1.x * length, y: -a1.y) - Point(x: a0.x * length, y: -a0.y)
-    let zh = z.phase
-    
-    if let mid = QuadBezierFitting(start, end, q0 * SDTransform.Rotate(zh), q1 * SDTransform.Rotate(zh)) {
+    let a_first = a.first!
+    let a_last = a.last!
+    let start = Point(x: p0.x + a_first.y * q0.y * s, y: p0.y - a_first.y * q0.x * s)
+    let end = Point(x: p2.x + a_last.y * q1.y * t, y: p2.y - a_last.y * q1.x * t)
+    
+    let z0 = a.lazy.map { $0 - a_first }.first { !$0.x.almostZero() || !$0.y.almostZero() }!
+    let z1 = a.reversed().lazy.map { a_last - $0 }.first { !$0.x.almostZero() || !$0.y.almostZero() }!
+    
+    if let mid = QuadBezierFitting(start, end, q0 * SDTransform.Rotate(z0.phase), q1 * SDTransform.Rotate(z1.phase)) {
         return limit > 0 && BezierOffsetCurvature(start, mid, end) ? split_half() : [[start, mid, end]]
     }
     
-    return BezierVariableOffset(p0, p2, a0, a1).map { [$0] } ?? []
+    return BezierVariableOffset(p0, p2, a).map { [$0] } ?? []
 }
 
 // MARK: Stationary Points

}

public func BezierVariableOffset(_ p0: Point, _ p1: Point, _ a: Point ... ) -> [Point]? {
    let z = p1 - p0
    if z.x.almostZero() && z.y.almostZero() {
        return nil

    let ph1 = q1.phase
    
    if ph0.almostEqual(ph1) || ph0.almostEqual(ph1 + 2 * M_PI) || ph0.almostEqual(ph1 - 2 * M_PI) {
        return BezierVariableOffset(p0, p2, a).map { [$0] } ?? []
    }
    
    let length = QuadBezierLength(1, p0, p1, p2)
