diff --git a/src/p_setup.c b/src/p_setup.c
index 0b43f76a5708457ea22dce3ee3d387e88b1ba94c..5014f0a7e3e1cf29f303ccf0d0a7c15d9e12d04f 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -638,7 +638,7 @@ texturefound:
 	{
 flatfound:
 		/* This could be a flat, patch, or PNG. */
-		flatpatch = W_CacheLumpNum(flatnum, PU_STATIC);
+		flatpatch = W_CacheLumpNum(flatnum, PU_CACHE);
 		lumplength = W_LumpLength(flatnum);
 		if (Picture_CheckIfPatch(flatpatch, lumplength))
 			levelflat->type = LEVELFLAT_PATCH;
diff --git a/src/p_setup.h b/src/p_setup.h
index ff28e36e4fac84b5edadd6542c888b0bf22688ba..77c932afc4e33de41b1c5b5bd5096455237b73a8 100644
--- a/src/p_setup.h
+++ b/src/p_setup.h
@@ -72,7 +72,6 @@ typedef struct
 	u;
 
 	UINT16 width, height;
-	fixed_t topoffset, leftoffset;
 
 	// for flat animation
 	INT32 animseq; // start pos. in the anim sequence
diff --git a/src/r_picformats.c b/src/r_picformats.c
index b907ac4d4e42bd66cc9ab15fa6bc2527b7cb01c7..ec953dfe9906937676ebab64d63b393e8627a854 100644
--- a/src/r_picformats.c
+++ b/src/r_picformats.c
@@ -615,7 +615,7 @@ boolean Picture_CheckIfPatch(patch_t *patch, size_t size)
 
 	width = SHORT(patch->width);
 	height = SHORT(patch->height);
-	result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4));
+	result = (height > 0 && height <= 16384 && width > 0 && width <= 16384);
 
 	if (result)
 	{
@@ -930,6 +930,9 @@ void *Picture_PNGConvert(
 	png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, insize);
 	png_uint_32 width = *w, height = *h;
 
+	if (png == NULL)
+		I_Error("Picture_PNGConvert: picture was NULL!");
+
 	// Find the output format's bits per pixel amount
 	outbpp = Picture_FormatBPP(outformat);
 
diff --git a/src/r_plane.c b/src/r_plane.c
index 8e1ddb8dbc033315a82f3cbf2a66d36897178123..9e90aba15177da7badc0ef1c5301667eafbc3f55 100644
--- a/src/r_plane.c
+++ b/src/r_plane.c
@@ -777,12 +777,11 @@ d.z = (v1.x * v2.y) - (v1.y * v2.x)
 
 void R_DrawSinglePlane(visplane_t *pl)
 {
-	UINT8 *flat;
+	levelflat_t *levelflat;
 	INT32 light = 0;
 	INT32 x;
 	INT32 stop, angle;
 	ffloor_t *rover;
-	levelflat_t *levelflat;
 	int type;
 	int spanfunctype = BASEDRAWFUNC;
 
@@ -943,30 +942,15 @@ void R_DrawSinglePlane(visplane_t *pl)
 		case LEVELFLAT_NONE:
 			return;
 		case LEVELFLAT_FLAT:
-			ds_source = R_GetFlat(levelflat->u.flat.lumpnum);
+			ds_source = (UINT8 *)R_GetFlat(levelflat->u.flat.lumpnum);
 			R_CheckFlatLength(W_LumpLength(levelflat->u.flat.lumpnum));
 			// Raw flats always have dimensions that are powers-of-two numbers.
 			ds_powersoftwo = true;
 			break;
 		default:
-			switch (type)
-			{
-				case LEVELFLAT_TEXTURE:
-					/* Textures get cached differently and don't need ds_source */
-					ds_source = R_GetTextureFlat(levelflat, true, false);
-					break;
-				default:
-					ds_source = R_GetFlat(levelflat->u.flat.lumpnum);
-					flat      = R_GetTextureFlat(levelflat, false,
-#ifndef NO_PNG_LUMPS
-							( type == LEVELFLAT_PNG )
-#else
-							false
-#endif
-					);
-					Z_ChangeTag(ds_source, PU_CACHE);
-					ds_source = flat;
-			}
+			ds_source = (UINT8 *)R_GetLevelFlat(levelflat);
+			if (!ds_source)
+				return;
 			// Check if this texture or patch has power-of-two dimensions.
 			if (R_CheckPowersOfTwo())
 				R_CheckFlatLength(ds_flatwidth * ds_flatheight);
diff --git a/src/r_textures.c b/src/r_textures.c
index 60d9a802e60fc6e78f8492a8ac300d4efab74090..5e03f57fcccd749195c579a5634b5292912fc67e 100644
--- a/src/r_textures.c
+++ b/src/r_textures.c
@@ -497,31 +497,29 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col)
 	return data + LONG(texturecolumnofs[tex][col]);
 }
 
-UINT8 *R_GetFlat(lumpnum_t flatlumpnum)
+void *R_GetFlat(lumpnum_t flatlumpnum)
 {
 	return W_CacheLumpNum(flatlumpnum, PU_CACHE);
 }
 
 //
-// R_GetTextureFlat
+// R_GetLevelFlat
 //
-// Convert a texture or patch to a flat.
+// If needed, convert a texture or patch to a flat.
 //
-UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boolean ispng)
+void *R_GetLevelFlat(levelflat_t *levelflat)
 {
-	UINT8 *flat;
+	UINT8 *flatdata = NULL;
+	boolean leveltexture = (levelflat->type == LEVELFLAT_TEXTURE);
 	textureflat_t *texflat = &texflats[levelflat->u.texture.num];
-	patch_t *patch = NULL;
 	boolean texturechanged = (leveltexture ? (levelflat->u.texture.num != levelflat->u.texture.lastnum) : false);
 
-	(void)ispng;
-
 	// Check if the texture changed.
 	if (leveltexture && (!texturechanged))
 	{
 		if (texflat != NULL && texflat->flat)
 		{
-			flat = texflat->flat;
+			flatdata = texflat->flat;
 			ds_flatwidth = texflat->width;
 			ds_flatheight = texflat->height;
 			texturechanged = false;
@@ -547,23 +545,19 @@ UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boolean is
 			converted = (UINT8 *)Picture_TextureToFlat(levelflat->u.texture.num);
 			M_Memcpy(texflat->flat, converted, size);
 			Z_Free(converted);
-			flat = texflat->flat;
 
-			levelflat->flatpatch = flat;
+			levelflat->flatpatch = texflat->flat;
 			levelflat->width = ds_flatwidth;
 			levelflat->height = ds_flatheight;
 		}
-		// Patch (never happens yet)
 		else
 		{
-			patch = (patch_t *)ds_source;
 #ifndef NO_PNG_LUMPS
-			if (ispng)
+			if (levelflat->type == LEVELFLAT_PNG)
 			{
 				INT32 pngwidth, pngheight;
 
-				levelflat->flatpatch = Picture_PNGConvert(ds_source, PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
-				levelflat->topoffset = levelflat->leftoffset = 0;
+				levelflat->flatpatch = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
 				levelflat->width = (UINT16)pngwidth;
 				levelflat->height = (UINT16)pngheight;
 
@@ -572,35 +566,33 @@ UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boolean is
 			}
 			else
 #endif
+			if (levelflat->type == LEVELFLAT_PATCH)
 			{
 				UINT8 *converted;
 				size_t size;
+				patch_t *patch = W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE);
+
 				levelflat->width = ds_flatwidth = SHORT(patch->width);
 				levelflat->height = ds_flatheight = SHORT(patch->height);
 
-				levelflat->topoffset = patch->topoffset * FRACUNIT;
-				levelflat->leftoffset = patch->leftoffset * FRACUNIT;
-
 				levelflat->flatpatch = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL);
 				converted = Picture_FlatConvert(PICFMT_PATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0);
 				M_Memcpy(levelflat->flatpatch, converted, size);
 				Z_Free(converted);
 			}
-			flat = levelflat->flatpatch;
 		}
 	}
 	else
 	{
-		flat = levelflat->flatpatch;
 		ds_flatwidth = levelflat->width;
 		ds_flatheight = levelflat->height;
 	}
 
-	//xoffs += levelflat->leftoffset;
-	//yoffs += levelflat->topoffset;
-
 	levelflat->u.texture.lastnum = levelflat->u.texture.num;
-	return flat;
+
+	if (flatdata == NULL)
+		flatdata = levelflat->flatpatch;
+	return flatdata;
 }
 
 //
diff --git a/src/r_textures.h b/src/r_textures.h
index e2bb40274ca0b4400485fce068e6d90785fb6d10..62ef523b2866dcab68edfadb5b32ed5684b6b056 100644
--- a/src/r_textures.h
+++ b/src/r_textures.h
@@ -93,8 +93,8 @@ void R_ClearTextureNumCache(boolean btell);
 
 // Retrieve texture data.
 UINT8 *R_GetColumn(fixed_t tex, INT32 col);
-UINT8 *R_GetFlat(lumpnum_t flatnum);
-UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boolean ispng);
+void *R_GetFlat(lumpnum_t flatnum);
+void *R_GetLevelFlat(levelflat_t *levelflat);
 
 boolean R_CheckPowersOfTwo(void);
 void R_CheckFlatLength(size_t size);