diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToTrianglesVisitor.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToTrianglesVisitor.java
index 62cf3ea5bb631cd462b98138d9a739a232f83076..0f6391f8c49a43c14f448bcd7b4c8b19bc0897df 100644
--- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToTrianglesVisitor.java
+++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToTrianglesVisitor.java
@@ -87,14 +87,39 @@ public class DistanceToTrianglesVisitor extends MeshVisitor {
         DistanceToVerticesVisitor vis = new DistanceToVerticesVisitor(myPoint, relativeDist, false);
         facet.accept(vis);
         
-        List<MeshFacet> closestFacets = vis.getClosestFacets();
-        List<Integer> closestVertices = vis.getClosestVertices();
+        List<MeshFacet> clFacets = vis.getClosestFacets();
+        List<Integer> clVertices = vis.getClosestVertices();
 
-        for (int i = 0; i < closestVertices.size(); i++) { // for all found closest vertices
-            MeshFacet closestF = closestFacets.get(i);
-            int closestI = closestVertices.get(i);
-            MeshPoint closestP = closestF.getVertex(closestI);
+        for (int i = 0; i < clVertices.size(); i++) { // for all found closest vertices
+            MeshFacet closestF = clFacets.get(i);
+            int closestI = clVertices.get(i);
             
+            Vector3d projection = closestF.getClosestAdjacentPoint(my, closestI);
+            Vector3d aux = new Vector3d(projection);
+            aux.sub(myPoint.getPosition());
+            
+            double dist = aux.length();
+            
+            synchronized (this) {
+                if (dist > distance) {
+                    continue;
+                }
+                if (dist < distance) { // new closest point
+                    sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1;
+                    distance = dist;
+                    closestFacets.clear();
+                    closestTriangles.clear();
+                    closestFacets.add(closestF);
+                    closestTriangles.add(closestI);
+                } else { // the same distance
+                    if (!closestFacets.contains(closestF)) {
+                        closestFacets.add(closestF);
+                        closestTriangles.add(closestI);
+                    }
+                }
+            }
+            
+            /*
             CornerTable ct = closestF.getCornerTable();
             
             List<Integer> adjacentTrianglesI = ct.getTriangleIndexesByVertexIndex(closestI);
@@ -111,6 +136,7 @@ public class DistanceToTrianglesVisitor extends MeshVisitor {
                 Vector3d projection = tri.getClosestPoint(my);
                 checkAndUpdateDistance(projection, facet, i);
             }
+            */
         }
     }
     
diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToVerticesVisitor.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToVerticesVisitor.java
index d6dbfa18aafd73005fcb4273ec589f569b3f7a5f..d4d353a67123bd832f9d64544f66982a0609fe56 100644
--- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToVerticesVisitor.java
+++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/DistanceToVerticesVisitor.java
@@ -84,7 +84,30 @@ public class DistanceToVerticesVisitor extends MeshVisitor {
     protected void visitMeshFacet(MeshFacet facet) {
         List<MeshPoint> vertices = facet.getVertices();
         for (int i = 0; i < vertices.size(); i++) {
-            checkAndUpdateDistance(vertices.get(i).getPosition(), facet, i);
+            //checkAndUpdateDistance(vertices.get(i).getPosition(), facet, i);
+            Vector3d pointOnSurface = vertices.get(i).getPosition();
+            Vector3d aux = new Vector3d(pointOnSurface);
+            aux.sub(myPoint.getPosition());
+            double dist = aux.length();
+            
+            synchronized (this) {
+                if (dist > distance) {
+                    continue;
+                }                
+                if (dist < distance) { // new closest point
+                    distance = dist;
+                    sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1;
+                    closestFacets.clear();
+                    closestVertices.clear();
+                    closestFacets.add(facet);
+                    closestVertices.add(i);
+                } else { // the same distance
+                    if (!closestFacets.contains(facet)) {
+                        closestFacets.add(facet);
+                        closestVertices.add(i);
+                    }
+                }
+            }
         }
     }
     
@@ -142,7 +165,6 @@ public class DistanceToVerticesVisitor extends MeshVisitor {
     protected void checkAndUpdateDistance(Vector3d pointOnSurface, MeshFacet facet, int index) {
         Vector3d aux = new Vector3d(pointOnSurface);
         aux.sub(myPoint.getPosition());
-        sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1;
         double dist = aux.length();
         
         synchronized (this) {
@@ -152,6 +174,7 @@ public class DistanceToVerticesVisitor extends MeshVisitor {
         
             if (dist < distance) { // new closest point
                 distance = dist;
+                sign = relativeDist ? (int) Math.signum(aux.dot(myPoint.getNormal())): 1;
                 closestFacets.clear();
                 closestVertices.clear();
                 closestFacets.add(facet);
diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/HausdorffDistanceVisitor.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/HausdorffDistanceVisitor.java
index 4ea073905df0a6cd1e38c8b7b6fb6895c060f200..672247b79422f0b60eee7ff9be58883ea835beb8 100644
--- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/HausdorffDistanceVisitor.java
+++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/HausdorffDistanceVisitor.java
@@ -18,6 +18,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import javax.vecmath.Vector3d;
 
 /**
  * Visitor for Hausdorff distance. 
@@ -62,6 +63,7 @@ public class HausdorffDistanceVisitor extends MeshVisitor {
             throw new IllegalArgumentException("mainFacets");
         }
         for (MeshFacet f: mainFacets) {
+            // create the list of distances initiate it with infinity
             distances.put(f, new ArrayList<>());
         }
         this.relativeDistance = relativeDistance;
@@ -107,12 +109,13 @@ public class HausdorffDistanceVisitor extends MeshVisitor {
         ExecutorService executor = Executors.newFixedThreadPool(threads);
         List<Future<MeshVisitor>> results = new LinkedList<>();
         
+        // fo all my facets
         for (Map.Entry<MeshFacet, List<Double>> entry: distances.entrySet()) {
             List<MeshPoint> vertices = entry.getKey().getVertices();
             List<Double> distList = entry.getValue();
             
             if (concurrently()) {
-                for (int i = 0; i < vertices.size(); i++) {
+                for (int i = 0; i < vertices.size(); i++) { // for all my vertices
                     if (strategy == Strategy.POINT_TO_POINT) {
                         DistanceToVerticesVisitor visitor = new DistanceToVerticesVisitor(vertices.get(i), relativeDistance, true);
                         comparedFacet.accept(visitor);
@@ -125,40 +128,36 @@ public class HausdorffDistanceVisitor extends MeshVisitor {
                         results.add(result);
                     }
                 }
-                //updateFacetDistancesConcurrently(distList, results);
                 
-                boolean firstComparison = distList.isEmpty();
-
                 try {
+                    boolean firstApplication = distList.isEmpty(); // first application of the visitor
                     for (int i = 0; i < results.size(); i++) { // wait ntil all computations are finished
                         if (strategy == Strategy.POINT_TO_POINT) {
                             DistanceToVerticesVisitor visitor = (DistanceToVerticesVisitor) results.get(i).get(); 
                             double dist = visitor.getDistance();
-                            updateDistances(distList, firstComparison, dist, i);
+                            updateDistances(distList, firstApplication, dist, i);
                         } else if (strategy == Strategy.POINT_TO_TRIANGLE) {
                             DistanceToTrianglesVisitor visitor = (DistanceToTrianglesVisitor) results.get(i).get(); 
                             double dist = visitor.getDistance();
-                            updateDistances(distList, firstComparison, dist, i);
+                            updateDistances(distList, firstApplication, dist, i);
                         }
                     }
                 } catch (InterruptedException | ExecutionException ex) {
                     Logger.getLogger(HausdorffDistanceVisitor.class.getName()).log(Level.SEVERE, null, ex);
                 }
             } else { // sequentially
-                //updateFacetDistancesSequentially(vertices, distList, comparedFacet);
-                boolean firstComparison = distList.isEmpty();
-            
-                for (int i = 0; i < vertices.size(); i++) {
+                boolean firstApplication = distList.isEmpty(); // first application of the visitor
+                for (int i = 0; i < vertices.size(); i++) { // for all my vertices
                     if (strategy == Strategy.POINT_TO_POINT) {
                         DistanceToVerticesVisitor visitor = new DistanceToVerticesVisitor(vertices.get(i), relativeDistance, false);
                         comparedFacet.accept(visitor);
                         double dist = visitor.getDistance();
-                        updateDistances(distList, firstComparison, dist, i);
+                        updateDistances(distList, firstApplication, dist, i);
                     } else if (strategy == Strategy.POINT_TO_TRIANGLE) {
                         DistanceToTrianglesVisitor visitor = new DistanceToTrianglesVisitor(vertices.get(i), relativeDistance, false);
                         comparedFacet.accept(visitor);
                         double dist = visitor.getDistance();
-                        updateDistances(distList, firstComparison, dist, i);
+                        updateDistances(distList, firstApplication, dist, i);
                     }
                 }
             }
@@ -186,19 +185,13 @@ public class HausdorffDistanceVisitor extends MeshVisitor {
         return distances;
     }
     
-    protected void updateDistances(List<Double> distList, boolean firstComparison, double dist, int index) {
-        if (firstComparison) {
+    protected synchronized void updateDistances(List<Double> distList, boolean firstApplication, double dist, int index) {
+        if (firstApplication) {
             distList.add(dist);
-            return;
-        } 
-        
-        if (dist >= 0 && dist < distList.get(index)) {
+        } else if (dist >= 0 && dist < distList.get(index)) {
             distList.set(index, dist);
-            return;
-        }
-        
-        if (dist < 0 && dist > distList.get(index)) { // for relative dist only
+        } else if (dist < 0 && dist > distList.get(index)) { // for relative dist only
             distList.set(index, dist);
         }
-    }
+    }    
 }