diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h
index 8021514a6..06b36da07 100644
--- a/polymer/eduke32/build/include/build.h
+++ b/polymer/eduke32/build/include/build.h
@@ -1187,7 +1187,7 @@ static inline int32_t logapproach(int32_t val, int32_t targetval)
 void   rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y,
                    int16_t daang, int32_t *x2, int32_t *y2) ATTRIBUTE((nonnull(6,7)));
 int32_t   lastwall(int16_t point);
-int32_t   nextsectorneighborz(int16_t sectnum, int32_t thez, int16_t topbottom, int16_t direction);
+int32_t   nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction);
 
 int32_t   getceilzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
 int32_t   getflorzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h
index f537fd2c1..faf3a56e6 100644
--- a/polymer/eduke32/build/include/polymost.h
+++ b/polymer/eduke32/build/include/polymost.h
@@ -60,9 +60,14 @@ static inline float getshadefactor(int32_t shade)
 {
     int32_t shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1;
     float clamped_shade = min(max(shade*shadescale, 0), shadebound);
+
+    // 8-bit tiles, i.e. non-hightiles and non-models, don't get additional
+    // glColor() shading with r_usetileshades!
     if (getrendermode() == REND_POLYMOST && r_usetileshades &&
         (!usehightile || !hicfindsubst(globalpicnum, globalpal, 0)) &&
-        (!usemodels || md_tilehasmodel(globalpicnum, globalpal) < 0)) return 1.f;
+        (!usemodels || md_tilehasmodel(globalpicnum, globalpal) < 0))
+        return 1.f;
+
     return ((float)(numshades-clamped_shade))/(float)numshades;
 }
 
diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c
index ceb54e973..c7ef1b633 100644
--- a/polymer/eduke32/build/src/engine.c
+++ b/polymer/eduke32/build/src/engine.c
@@ -12062,7 +12062,7 @@ int32_t setspritez(int16_t spritenum, const vec3_t *newpos)
 //
 // -1: ceiling or up
 //  1: floor or down
-int32_t nextsectorneighborz(int16_t sectnum, int32_t thez, int16_t topbottom, int16_t direction)
+int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction)
 {
     int32_t nextz = (direction==1) ? INT32_MAX : INT32_MIN;
     int32_t sectortouse = -1;
@@ -12080,8 +12080,8 @@ int32_t nextsectorneighborz(int16_t sectnum, int32_t thez, int16_t topbottom, in
                 sector[ns].floorz : sector[ns].ceilingz;
 
             const int32_t update = (direction == 1) ?
-                (testz > thez && testz < nextz) :
-                (testz < thez && testz > nextz);
+                (nextz > testz && testz > refz) :
+                (nextz < testz && testz < refz);
 
             if (update)
             {
diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c
index c881de1dc..feffde7f3 100644
--- a/polymer/eduke32/build/src/polymost.c
+++ b/polymer/eduke32/build/src/polymost.c
@@ -1308,7 +1308,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
     int32_t texunits = GL_TEXTURE0_ARB;
 #endif
     // backup of the n for possible redrawing of fullbright
-    int32_t n_ = n, method_ = method;
+    const int32_t n_ = n, method_ = method;
 
     if (method == -1) return;
 #ifdef YAX_ENABLE