diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c
index d448aa55e847015fa953d5cf6b9401f0bc62eb83..db4fb53c85de719f770f1be366548df252c2edd9 100644
--- a/src/hardware/hw_main.c
+++ b/src/hardware/hw_main.c
@@ -1625,12 +1625,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
 
 				side_t *side = &sides[rover->master->sidenum[0]];
 
+				INT16 lineflags;
+
 				if (rover->master->flags & ML_TFERLINE)
 				{
 					size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
 					newline = rover->master->frontsector->lines[0] + linenum;
 					side = &sides[newline->sidenum[0]];
+					lineflags = newline->flags;
 				}
+				else
+					lineflags = gl_curline->linedef->flags;
 
 				texnum = R_GetTextureNum(side->midtexture);
 
@@ -1669,13 +1674,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
 					// ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software
 					// -- Monster Iestyn 26/06/18
 					fixed_t texturevpeg = side->rowoffset + side->offsety_mid;
-					boolean attachtobottom = !!(rover->master->flags & ML_DONTPEGBOTTOM);
+					boolean attachtobottom = !!(lineflags & ML_DONTPEGBOTTOM);
 
 					grTex = HWR_GetTexture(texnum);
 					xscale = FixedToFloat(side->scalex_mid);
 					yscale = FixedToFloat(side->scaley_mid);
 
-					if (!(rover->master->flags & ML_SKEWTD)) // no skewing
+					if (!(lineflags & ML_SKEWTD)) // no skewing
 					{
 						if (attachtobottom)
 							texturevpeg -= (*rover->topheight - *rover->bottomheight) * yscale;
diff --git a/src/r_segs.c b/src/r_segs.c
index 6ca7bce28029973cd2dae5e30c6689bf1a68b07d..bd4869bdcc28ed4b4a891bcd8b8288e5e0b37263 100644
--- a/src/r_segs.c
+++ b/src/r_segs.c
@@ -553,7 +553,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
 	fixed_t       left_top, left_bottom; // needed here for slope skewing
 	pslope_t      *skewslope = NULL;
 	boolean do_texture_skew;
-	UINT32 lineflags;
+	INT16 lineflags;
 	fixed_t wall_scalex, wall_scaley;
 
 	void (*colfunc_2s) (column_t *);
@@ -578,7 +578,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
 		lineflags = newline->flags;
 	}
 	else
-		lineflags = pfloor->master->flags;
+		lineflags = curline->linedef->flags;
 
 	texnum = R_GetTextureNum(sidedef->midtexture);
 
@@ -757,10 +757,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
 	left_bottom = P_GetFFloorBottomZAt(pfloor, ds->leftpos.x, ds->leftpos.y) - viewz;
 
 	do_texture_skew = lineflags & ML_SKEWTD;
-	skewslope = *pfloor->t_slope; // skew using top slope by default
 
 	if (do_texture_skew)
+	{
+		skewslope = *pfloor->t_slope; // skew using top slope by default
 		dc_texturemid = FixedMul(left_top, wall_scaley);
+	}
 	else
 		dc_texturemid = FixedMul(*pfloor->topheight - viewz, wall_scaley);
 
@@ -768,14 +770,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
 
 	if (lineflags & ML_DONTPEGBOTTOM)
 	{
-		skewslope = *pfloor->b_slope; // skew using bottom slope
 		if (do_texture_skew)
+		{
+			skewslope = *pfloor->b_slope; // skew using bottom slope
 			dc_texturemid = FixedMul(left_bottom, wall_scaley);
+		}
 		else
 			offsetvalue -= FixedMul(*pfloor->topheight - *pfloor->bottomheight, wall_scaley);
 	}
 
-	if (do_texture_skew && skewslope)
+	if (skewslope)
 	{
 		angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y);
 		ffloortextureslide = FixedMul(skewslope->zdelta, FINECOSINE((lineangle-skewslope->xydirection)>>ANGLETOFINESHIFT));