diff --git a/src/Mod/Path/PathScripts/PathAdaptive.py b/src/Mod/Path/PathScripts/PathAdaptive.py
index 06cc36774f..da550a9f71 100644
--- a/src/Mod/Path/PathScripts/PathAdaptive.py
+++ b/src/Mod/Path/PathScripts/PathAdaptive.py
@@ -28,6 +28,8 @@ import PathScripts.PathLog as PathLog
 import PathScripts.PathGeom as PathGeom
 import Path
 import FreeCAD
+import numpy
+import sys
 import time
 import json
 import math
@@ -557,6 +559,11 @@ def Execute(op, obj):
             job.ViewObject.Visibility = oldJobVisibility
             sceneClean()
 
+def cmpEdge(a, b):
+    if (abs(a[0]-b[0])<1e-05 and
+        abs(a[1]-b[1])<1e-05):
+        return True
+    return False
 
 def _get_working_edges(op, obj):
     """_get_working_edges(op, obj)...
@@ -568,6 +575,7 @@ def _get_working_edges(op, obj):
     regions = list()
     all_regions = list()
     edge_list = list()
+    edge_list_unsorted = list()
     avoidFeatures = list()
 
     # Get extensions and identify faces to avoid
@@ -576,20 +584,60 @@ def _get_working_edges(op, obj):
         if e.avoid:
             avoidFeatures.append(e.feature)
 
+    f=list()
     # Get faces selected by user
+    maxHeight=None
     for base, subs in obj.Base:
         for sub in subs:
-            if sub not in avoidFeatures:
-                if obj.UseOutline:
-                    face = base.Shape.getElement(sub)
-                    # get outline with wire_A method used in PocketShape, but it does not play nicely later
-                    # wire_A = TechDraw.findShapeOutline(face, 1, FreeCAD.Vector(0.0, 0.0, 1.0))
-                    wire_B = face.Wires[0]
-                    shape = Part.Face(wire_B)
-                else:
-                    shape = base.Shape.getElement(sub)
-                regions.append(shape)
-    # Efor
+            if sub.startswith("Face"):
+                if sub not in avoidFeatures:
+                    if obj.UseOutline:
+                        face = base.Shape.getElement(sub)
+                        # get outline with wire_A method used in PocketShape, but it does not play nicely later
+                        # wire_A = TechDraw.findShapeOutline(face, 1, FreeCAD.Vector(0.0, 0.0, 1.0))
+                        wire_B = face.Wires[0]
+                        shape = Part.Face(wire_B)
+                    else:
+                        shape = base.Shape.getElement(sub)
+                    regions.append(shape)
+            elif sub.startswith("Edge"):
+                shape = base.Shape.getElement(sub)
+                if (maxHeight == None or shape.valueAt(shape.FirstParameter)[2]>maxHeight):
+                   maxHeight=shape.valueAt(shape.FirstParameter)[2]
+                if (shape.valueAt(shape.LastParameter)[2]>maxHeight):
+                   maxHeight=shape.valueAt(shape.LastParameter)[2]
+                f.append(shape)
+
+    if (len(f) != 0):
+      EdgeList=list()
+      endlen=len(f)
+      i=f[0]
+      coord=i.valueAt(i.FirstParameter)
+      i.translate(FreeCAD.Vector(0,0,maxHeight)-FreeCAD.Vector(0,0,coord[2]))
+      EdgeList.append(i)
+      f.remove(f[0])
+      while len(EdgeList) != endlen:
+       lastEdge=EdgeList[len(EdgeList)-1]
+       for i in f:
+           if cmpEdge(lastEdge.valueAt(lastEdge.LastParameter), i.valueAt(i.FirstParameter)):
+             coord=i.valueAt(i.FirstParameter)
+             if abs(coord[2]-maxHeight)>1e-5:
+               i.translate(FreeCAD.Vector(0,0,maxHeight)-FreeCAD.Vector(0,0,coord[2]))
+             EdgeList.append(i)
+             f.remove(i)
+             break
+           elif cmpEdge(lastEdge.valueAt(lastEdge.LastParameter), i.valueAt(i.LastParameter)):
+             b=PathGeom.flipEdge(i)
+             coord=b.valueAt(b.FirstParameter)
+             if abs(coord[2]-maxHeight)>1e-5:
+               b.translate(FreeCAD.Vector(0,0,maxHeight)-FreeCAD.Vector(0,0,coord[2]))
+             EdgeList.append(b)
+             f.remove(i)
+             break
+
+      wire=Part.Wire(EdgeList)
+      pf=Part.Face(wire)
+      regions.append(pf)
 
     # Return Extend Outline extension, OR regular edge extension
     all_regions = regions
@@ -608,8 +656,28 @@ def _get_working_edges(op, obj):
     for f in horizontal:
         for w in f.Wires:
             for e in w.Edges:
-                edge_list.append([discretize(e)])
-
+                edge_list_unsorted.append(e)
+    if False: # disabled for now because not needed
+     if (len(edge_list_unsorted) != 0):
+      EdgeList=list()
+      endlen=len(edge_list_unsorted)
+      EdgeList.append(edge_list_unsorted[0])
+      edge_list_unsorted.remove(edge_list_unsorted[0])
+      while len(EdgeList) != endlen:
+       lastEdge=EdgeList[len(EdgeList)-1]
+       for i in edge_list_unsorted:
+           if cmpEdge(lastEdge.valueAt(lastEdge.LastParameter), i.valueAt(i.FirstParameter)):
+             EdgeList.append(i)
+             edge_list_unsorted.remove(i)
+             break
+           elif cmpEdge(lastEdge.valueAt(lastEdge.LastParameter), i.valueAt(i.LastParameter)):
+             b=PathGeom.flipEdge(i)
+             EdgeList.append(b)
+             edge_list_unsorted.remove(i)
+             break
+
+    for e in edge_list_unsorted:
+        edge_list.append([discretize(e)])
     return edge_list
 
 
diff --git a/src/Mod/Path/PathScripts/PathFeatureExtensions.py b/src/Mod/Path/PathScripts/PathFeatureExtensions.py
index d3b7ead79c..81ecaaa4d4 100644
--- a/src/Mod/Path/PathScripts/PathFeatureExtensions.py
+++ b/src/Mod/Path/PathScripts/PathFeatureExtensions.py
@@ -195,10 +195,24 @@ class Extension(object):
         if isinstance(e0.Curve, Part.Line) or isinstance(e0.Curve, Part.LineSegment):
             e2 = e0.copy()
             off = self.length.Value * direction
+            #if (e0.LastParameter == 14.172381):
+            #    return None
+            #if (e0.LastParameter == 18.952844)
+            #    return None
+            #if (e0.LastParameter == 33.788421):
+            #    return None
+            #if (e0.LastParameter >= 14.1723 and e0.LastParameter <= 14.1724):
+            #     print("wrong part")
+            #    return None
+            #if (e0.LastParameter >= 18.9528 and e0.LastParameter <= 18.9529):
+            #    return None
             e2.translate(off)
-            e2 = PathGeom.flipEdge(e2)
-            e1 = Part.Edge(Part.LineSegment(e0.valueAt(e0.LastParameter), e2.valueAt(e2.FirstParameter)))
-            e3 = Part.Edge(Part.LineSegment(e2.valueAt(e2.LastParameter), e0.valueAt(e0.FirstParameter)))
+            #print("values: %s %s %s %s" % (str(e0.valueAt(e0.LastParameter)), str(e2.valueAt(e2.FirstParameter)), str(e0.valueAt(e0.FirstParameter)), str(e2.valueAt(e2.LastParameter))))
+            #e2 = PathGeom.flipEdge(e2)
+            #e1 = Part.Edge(Part.LineSegment(e0.valueAt(e0.LastParameter), e2.valueAt(e2.FirstParameter)))
+            #e3 = Part.Edge(Part.LineSegment(e2.valueAt(e2.LastParameter), e0.valueAt(e0.FirstParameter)))
+            e1 = Part.Edge(Part.LineSegment(e0.valueAt(e0.FirstParameter), e2.valueAt(e2.FirstParameter)))
+            e3 = Part.Edge(Part.LineSegment(e2.valueAt(e2.LastParameter), e0.valueAt(e0.LastParameter)))
             wire = Part.Wire([e0, e1, e2, e3])
             self.wire = wire
             return wire
@@ -314,7 +328,7 @@ class Extension(object):
 
                 # assuming the offset produces a valid circle - go for it
                 if r > 0:
-                    e3 = Part.makeCircle(r, circle.Center, circle.Axis, edge.FirstParameter * 180 / math.pi, edge.LastParameter * 180 / math.pi)
+                    e3 = Part.makeCircle(r, circle.Center, circle.Axis, edge.FirstParameter * 180 / math.pi-90, edge.LastParameter * 180 / math.pi-90)
                     if endPoints(edge):
                         # need to construct the arc slice
                         e0 = Part.makeLine(edge.valueAt(edge.FirstParameter), e3.valueAt(e3.FirstParameter))
@@ -343,7 +357,7 @@ class Extension(object):
                 if direction is None:
                     return None
 
-            #    return self._extendEdge(feature, edge, direction)
+            #return self._extendEdge(feature, edge, direction)
             return self._extendEdge(feature, edges[0], direction)
         elif sub.isClosed():
             PathLog.debug("Extending multi-edge closed wire")
@@ -373,7 +387,6 @@ class Extension(object):
         pertaining to the feature and sub element provided at class instantiation, as a closed wire.
         If no closed wire is possible, a `None` value is returned.'''
         PathLog.track()
-
         baseShape = self.obj.Shape
         face = baseShape.getElement(self.feature)
         useOutline = False
