diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 67cf3d065f3869d1fe9fe0c6d0ed5cbd8b36fff0..1374184715376014dab049a3e0a04f8d06bd18bc 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -41,8 +41,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 const char *GenElementManager::ELEMENT_TITLE = "element";
 
-static const s16 INVALID_HEIGHT = MAP_GENERATION_LIMIT + 1;
-
 FlagDesc flagdesc_mapgen[] = {
 	{"trees",    MG_TREES},
 	{"caves",    MG_CAVES},
@@ -140,6 +138,7 @@ s16 Mapgen::findGroundLevelFull(v2s16 p2d)
 }
 
 
+// Returns -MAP_GENERATION_LIMIT if not found
 s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
 {
 	v3s16 em = vm->m_area.getExtent();
@@ -153,16 +152,10 @@ s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
 
 		vm->m_area.add_y(em, i, -1);
 	}
-	return y;
+	return (y >= ymin) ? y : -MAP_GENERATION_LIMIT;
 }
 
 
-void Mapgen::initHeightMap(s16 *dest, size_t len)
-{
-	for (size_t i = 0; i < len; i++)
-		dest[i] = INVALID_HEIGHT;
-}
-
 void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax)
 {
 	if (!heightmap)
@@ -174,14 +167,6 @@ void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax)
 		for (s16 x = nmin.X; x <= nmax.X; x++, index++) {
 			s16 y = findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
 
-			if (heightmap[index] != INVALID_HEIGHT) {
-				// if the values found are out of range, trust the old heightmap
-				if (y == nmax.Y && heightmap[index] > nmax.Y)
-					continue;
-				if (y == nmin.Y - 1 && heightmap[index] < nmin.Y)
-					continue;
-			}
-
 			heightmap[index] = y;
 		}
 	}
diff --git a/src/mapgen.h b/src/mapgen.h
index c9aee5ef58cc40da00e472972d6292d383d95fee..756a1f339ef94bef0f98a19e2622d0de2811cbe1 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -154,7 +154,6 @@ class Mapgen {
 	static u32 getBlockSeed2(v3s16 p, int seed);
 	s16 findGroundLevelFull(v2s16 p2d);
 	s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
-	void initHeightMap(s16 *dest, size_t len);
 	void updateHeightmap(v3s16 nmin, v3s16 nmax);
 	void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
 
diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp
index 48f524e6efcd0a502f3d85a34afe30b39c425c78..561b8a410f2b0bd6aeaed2f62efb7037bbfe9679 100644
--- a/src/mapgen_v5.cpp
+++ b/src/mapgen_v5.cpp
@@ -60,8 +60,6 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge)
 	this->biomemap  = new u8[csize.X * csize.Z];
 	this->heightmap = new s16[csize.X * csize.Z];
 
-	initHeightMap(this->heightmap, csize.X * csize.Z);
-
 	MapgenV5Params *sp = (MapgenV5Params *)params->sparams;
 	this->spflags      = sp->spflags;
 
diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp
index 89efcb9d30c88eba083d31b635380aa78257909e..7f5be27ae83ad4b7d7597364f289337188804c06 100644
--- a/src/mapgen_v6.cpp
+++ b/src/mapgen_v6.cpp
@@ -57,8 +57,6 @@ MapgenV6::MapgenV6(int mapgenid, MapgenParams *params, EmergeManager *emerge)
 
 	this->heightmap = new s16[csize.X * csize.Z];
 
-	initHeightMap(this->heightmap, csize.X * csize.Z);
-
 	MapgenV6Params *sp = (MapgenV6Params *)params->sparams;
 	this->spflags     = sp->spflags;
 	this->freq_desert = sp->freq_desert;
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index 4b5a10ca14b5c0d6ad0b34fa8c0caed1f7b3c339..09e6e54c2805eb28eee7311a826e22826fa8474b 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -64,8 +64,6 @@ MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
 	this->heightmap = new s16[csize.X * csize.Z];
 	this->ridge_heightmap = new s16[csize.X * csize.Z];
 
-	initHeightMap(this->heightmap, csize.X * csize.Z);
-
 	MapgenV7Params *sp = (MapgenV7Params *)params->sparams;
 	this->spflags = sp->spflags;