diff --git a/src/pathfinder/astar.cpp b/src/pathfinder/astar.cpp
index 981b27bd9..7932fdcea 100644
--- a/src/pathfinder/astar.cpp
+++ b/src/pathfinder/astar.cpp
@@ -307,19 +307,16 @@ static void AStarPrepare()
 /**
 **  Clean up A*
 */
-static void CostMoveToCacheCleanUp();
 static void AStarCleanUp()
 {
 	ProfileBegin("AStarCleanUp");
 
 	if (CloseSetSize >= Threshold) {
 		AStarPrepare();
-		CostMoveToCacheCleanUp();
 	} else {
 		for (int i = 0; i < CloseSetSize; ++i) {
 			AStarMatrix[CloseSet[i]].CostFromStart = 0;
 			AStarMatrix[CloseSet[i]].InGoal = 0;
-			CostMoveToCache[CloseSet[i]] = CacheNotSet;
 		}
 	}
 	ProfileEnd("AStarCleanUp");
@@ -939,6 +936,7 @@ int AStarFindPath(const Vec2i &startPos, const Vec2i &goalPos, int gw, int gh,
 
 	//  Initialize
 	AStarCleanUp();
+	CostMoveToCacheCleanUp();
 
 	OpenSetSize = 0;
 	CloseSetSize = 0;