diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c
index 6eaafca6d0deec87da0404a1ecb508880e06494c..2d4704b8b1d55bf8127fd311f70c572e6fce0bcf 100644
--- a/src/hardware/hw_cache.c
+++ b/src/hardware/hw_cache.c
@@ -771,18 +771,25 @@ void HWR_InitTextureCache(void)
 	gr_textures2 = NULL;
 }
 
-
 // Callback function for HWR_FreeTextureCache.
 static void FreeMipmapColormap(INT32 patchnum, void *patch)
 {
-	GLPatch_t* const grpatch = patch;
+	GLPatch_t* const pat = patch;
 	(void)patchnum; //unused
-	while (grpatch->mipmap->nextcolormap)
+	while (pat->mipmap && pat->mipmap->nextcolormap) // The mipmap must be valid, obviously
 	{
-		GLMipmap_t *grmip = grpatch->mipmap->nextcolormap;
-		grpatch->mipmap->nextcolormap = grmip->nextcolormap;
-		if (grmip->grInfo.data) Z_Free(grmip->grInfo.data);
-		free(grmip);
+		// Confusing at first, but pat->mipmap->nextcolormap
+		// at the beginning of the loop is the first colormap
+		// from the linked list of colormaps
+		GLMipmap_t *next = pat->mipmap->nextcolormap;
+		// Set the first colormap
+		// to the one that comes after it
+		pat->mipmap->nextcolormap = next->nextcolormap;
+		// Free image data from memory
+		if (next->grInfo.data)
+			Z_Free(next->grInfo.data);
+		// Free the old colormap from memory
+		free(next);
 	}
 }
 
@@ -799,7 +806,7 @@ void HWR_FreeTextureCache(void)
 
 	// Alam: free the Z_Blocks before freeing it's users
 
-	// free all skin after each level: must be done after pfnClearMipMapCache!
+	// free all patch colormaps after each level: must be done after ClearMipMapCache!
 	for (i = 0; i < numwadfiles; i++)
 		M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap);