diff --git a/client/goto.c b/client/goto.c
index 9ef201d..5d50ecf 100644
--- a/client/goto.c
+++ b/client/goto.c
@@ -439,7 +439,7 @@ static enum tile_behavior get_TB_aggr(const struct tile *ptile,
   } else if (is_non_allied_unit_tile(ptile, param->owner)
 	     || is_non_allied_city_tile(ptile, param->owner)) {
     /* Can attack but can't count on going through */
-    return TB_DONT_LEAVE;
+    return TB_END_PATH;
   }
   return TB_NORMAL;
 }
@@ -459,7 +459,7 @@ static enum tile_behavior get_TB_caravan(const struct tile *ptile,
   } else if (is_non_allied_city_tile(ptile, param->owner)) {
     /* UTYF_TRADE_ROUTE units can travel to, but not through, enemy cities.
      * FIXME: UTYF_HELP_WONDER units cannot.  */
-    return TB_DONT_LEAVE;
+    return TB_END_PATH;
   } else if (is_non_allied_unit_tile(ptile, param->owner)) {
     /* Note this must be below the city check. */
     return TB_IGNORE;
diff --git a/common/aicore/path_finding.c b/common/aicore/path_finding.c
index 19be518..43984ef 100644
--- a/common/aicore/path_finding.c
+++ b/common/aicore/path_finding.c
@@ -556,7 +556,7 @@ static bool pf_normal_map_iterate(struct pf_map *pfm)
   int cost_of_path;
 
   /* There is no exit from DONT_LEAVE tiles! */
-  if (node->behavior != TB_DONT_LEAVE) {
+  if (node->behavior != TB_DONT_LEAVE && node->behavior != TB_END_PATH) {
     /* Processing Stage */
 
     /* The previous position is defined by 'tile' (tile pointer), 'node'
@@ -612,7 +612,11 @@ static bool pf_normal_map_iterate(struct pf_map *pfm)
       }
 
       /* Total cost at tile1. Cost may be negative; see pf_turns(). */
-      cost += node->cost;
+      if (node1->behavior == TB_END_PATH) {
+        cost = node->cost;
+      } else {
+        cost += node->cost;
+      }
 
       /* Evaluate the extra cost if it's relevant */
       if (NULL != params->get_EC) {
@@ -1292,7 +1296,7 @@ static bool pf_danger_map_iterate(struct pf_map *pfm)
 
   for (;;) {
     /* There is no exit from DONT_LEAVE tiles! */
-    if (node->behavior != TB_DONT_LEAVE) {
+    if (node->behavior != TB_DONT_LEAVE && node->behavior != TB_END_PATH) {
       /* Cost at tile but taking into account waiting. */
       int loc_cost;
       if (node->status != NS_WAITING) {
@@ -1357,7 +1361,11 @@ static bool pf_danger_map_iterate(struct pf_map *pfm)
         }
 
         /* Total cost at 'tile1'. */
-        cost += loc_cost;
+        if (node1->behavior == TB_END_PATH) {
+          cost = loc_cost;
+        } else {
+          cost += loc_cost;
+        }
 
         /* Evaluate the extra cost of the destination, if it's relevant. */
         if (NULL != params->get_EC) {
@@ -2241,7 +2249,7 @@ static bool pf_fuel_map_iterate(struct pf_map *pfm)
 
   for (;;) {
     /* There is no exit from DONT_LEAVE tiles! */
-    if (node->behavior != TB_DONT_LEAVE) {
+    if (node->behavior != TB_DONT_LEAVE && node->behavior != TB_END_PATH) {
       int loc_cost, loc_moves_left;
 
       if (node->status != NS_WAITING) {
@@ -2327,7 +2335,11 @@ static bool pf_fuel_map_iterate(struct pf_map *pfm)
         }
 
         /* Total cost at 'tile1' */
-        cost += loc_cost;
+        if (node1->behavior == TB_END_PATH) {
+          cost = loc_cost;
+        } else {
+          cost += loc_cost;
+        }
 
         /* Evaluate the extra cost of the destination, if it's relevant. */
         if (NULL != params->get_EC) {
diff --git a/common/aicore/path_finding.h b/common/aicore/path_finding.h
index 3066507..05d8b28 100644
--- a/common/aicore/path_finding.h
+++ b/common/aicore/path_finding.h
@@ -272,6 +272,8 @@ enum tile_behavior {
   TB_IGNORE = 0,        /* This one will be ignored. */
   TB_DONT_LEAVE,        /* Paths can lead _to_ such tile, but are not
                          * allowed to go _through_. */
+  TB_END_PATH,          /* Like TB_DONT_LEAVE, but the last part of the
+                         * path is evaluated as free moving. */
   TB_NORMAL             /* Well, normal .*/
 };
 
diff --git a/common/aicore/pf_tools.c b/common/aicore/pf_tools.c
index 2ce0158..b3e6f48 100644
--- a/common/aicore/pf_tools.c
+++ b/common/aicore/pf_tools.c
@@ -530,7 +530,7 @@ enum tile_behavior no_intermediate_fights(const struct tile *ptile,
 {
   if (is_non_allied_unit_tile(ptile, param->owner)
       || is_non_allied_city_tile(ptile, param->owner)) {
-    return TB_DONT_LEAVE;
+    return TB_END_PATH;
   }
   return TB_NORMAL;
 }
