diff --git a/.travis.yml b/.travis.yml
index f1996215bd10f5bd1b00dc6114b9c246b0e4be94..e3408cf6f1d28b1615a7aa4fde68349d8677f9aa 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,19 +2,199 @@ language: c
 sudo: required
 dist: trusty
 
-env:
-- CFLAGS=-Wall -W -Werror
-
-os:
-  - linux
-  - osx
-
-compiler:
-  - gcc
-  - clang
+matrix:
+    include:
+        - os: linux
+          addons:
+            apt:
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - gcc-4.4
+          compiler: gcc-4.4
+          #gcc-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7
+        - os: linux
+          addons:
+            apt:
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - gcc-4.6
+          compiler: gcc-4.6
+          #gcc-4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4
+        - os: linux
+          addons:
+            apt:
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - gcc-4.7
+          compiler: gcc-4.7
+          #gcc-4.7
+        - os: linux
+          compiler: gcc
+          #gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - ubuntu-toolchain-r-test
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - gcc-4.8
+          compiler: gcc-4.8
+          #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - ubuntu-toolchain-r-test
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - gcc-4.9
+          compiler: gcc-4.9
+          #gcc-4.9 (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - ubuntu-toolchain-r-test
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - gcc-5
+          compiler: gcc-5
+          #gcc-5 (Ubuntu 5.3.0-3ubuntu1~14.04) 5.3.0 20151204
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - ubuntu-toolchain-r-test
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - gcc-6
+          compiler: gcc-6
+          env: WFLAGS="-Wno-error=tautological-compare"
+          #gcc-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511
+        - os: linux
+          compiler: clang
+          #clang version 3.5.0 (tags/RELEASE_350/final)
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - llvm-toolchain-precise-3.5
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - clang-3.5
+          compiler: clang-3.5
+          #Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - llvm-toolchain-precise-3.6
+              - ubuntu-toolchain-r-test
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - clang-3.6
+          compiler: clang-3.6
+          #Ubuntu clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2)
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - llvm-toolchain-precise-3.7
+              - ubuntu-toolchain-r-test
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - clang-3.7
+          compiler: clang-3.7
+          #Ubuntu clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1)
+        - os: linux
+          addons:
+            apt:
+              sources:
+              - llvm-toolchain-precise-3.8
+              - ubuntu-toolchain-r-test
+              packages:
+              - libsdl2-mixer-dev
+              - libpng-dev
+              - libgl1-mesa-dev
+              - libgme-dev
+              - p7zip-full
+              - clang-3.8
+          compiler: clang-3.8
+          #clang version 3.8.1-svn271127-1~exp1 (branches/release_38)
+        - os: osx
+          osx_image: beta-xcode6.1
+          #Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
+        - os: osx
+          osx_image: beta-xcode6.2
+          compiler: gcc
+          #Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
+#        - os: osx
+#          osx_image: beta-xcode6.3
+#          #I think xcode.6.3 VM is broken, it does not boot
+        - os: osx
+          osx_image: xcode6.4
+          #Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
+        - os: osx
+          osx_image: xcode7
+          #Apple LLVM version 7.0.0 (clang-700.0.72)
+        - os: osx
+          osx_image: xcode7.1
+          #Apple LLVM version 7.0.0 (clang-700.1.76)
+        - os: osx
+          osx_image: xcode7.2
+          #Apple LLVM version 7.0.2 (clang-700.1.81)
+        - os: osx
+          osx_image: xcode7.3
+          #Apple LLVM version 7.3.0 (clang-703.0.31)
+    allow_failures:
+      - compiler: clang-3.5
+      - compiler: clang-3.6
+      - compiler: clang-3.7
+      - compiler: clang-3.8
 
 cache:
-  apt:  true
+  apt: true
   ccache: true
   directories:
   - $HOME/srb2_cache
@@ -33,11 +213,14 @@ before_script:
   - 7z x $HOME/srb2_cache/SRB2-v2115-assets-2.7z -oassets
   - mkdir build
   - cd build
-  - cmake ..
+  - export CFLAGS="-Wall -W $WFLAGS"
+  - export CCACHE_COMPRESS=true
+  - cmake .. -DCMAKE_BUILD_TYPE=Release
 
 before_install:
   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
-  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer game-music-emu p7zip ; fi
+  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer game-music-emu p7zip; fi
+  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install cmake||true; fi
   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.4.dmg; hdiutil attach SDL2-2.0.4.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi
   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi
   - mkdir -p $HOME/srb2_cache
diff --git a/appveyor.yml b/appveyor.yml
index fd949dbb3244dab193e9b12194d6cc790b2a41f2..85cee6a3107a224213512eea0fba150d799c7232 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -75,6 +75,9 @@ deploy:
     folder: appveyor
     application:
     active_mode: false
+    on:
+      branch: master
+      appveyor_repo_tag: true
 
 
 on_finish:
diff --git a/src/Makefile b/src/Makefile
index f43e3c24d16624a54b409f143856fbccedc14a47..f7a8c1b85effd05aa269687578e9ec39a085e808 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -366,7 +366,12 @@ ifdef DEBUGMODE
 
 	# build with debugging information
 	WINDRESFLAGS = -D_DEBUG
-	CFLAGS+=-O0 -Wall -DPARANOIA -DRANGECHECK
+ifdef GCC48
+	CFLAGS+=-Og
+else
+	CFLAGS+=-O0
+endif
+	CFLAGS+= -Wall -DPARANOIA -DRANGECHECK
 else
 
 
diff --git a/src/am_map.c b/src/am_map.c
index 90f815729fe3f5368ff4d42bcf7444a83a355240..b28cecf11602e99caea132e326f6bff1b1bdfe0f 100644
--- a/src/am_map.c
+++ b/src/am_map.c
@@ -999,7 +999,7 @@ static inline void AM_drawWalls(void)
 	static mline_t l;
 #ifdef ESLOPE
 	fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
-	fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends
+	fixed_t backf1 = 0, backf2 = 0, backc1 = 0, backc2 = 0; // back floor ceiling ends
 #endif
 
 	for (i = 0; i < numlines; i++)
diff --git a/src/blua/lcode.c b/src/blua/lcode.c
index 743a094a874f91958055777efc4708734e638dba..5c7fed4541a4442d9d40691663965250de434619 100644
--- a/src/blua/lcode.c
+++ b/src/blua/lcode.c
@@ -270,6 +270,7 @@ static int boolK (FuncState *fs, int b) {
 
 static int nilK (FuncState *fs) {
   TValue k, v;
+  setbvalue(&v, 0);
   setnilvalue(&v);
   /* cannot use nil as key; instead use table itself to represent nil */
   sethvalue(fs->L, &k, fs->h);
diff --git a/src/blua/ltablib.c b/src/blua/ltablib.c
index 2e50ce0ae20d0bc2e5bfecddba8c6feb5eb21b17..2dd1571556cb7d255ae7109698236e00d4736526 100644
--- a/src/blua/ltablib.c
+++ b/src/blua/ltablib.c
@@ -137,7 +137,7 @@ static void addfield (lua_State *L, luaL_Buffer *b, int i) {
   if (!lua_isstring(L, -1))
     luaL_error(L, "invalid value (%s) at index %d in table for "
                   LUA_QL("concat"), luaL_typename(L, -1), i);
-    luaL_addvalue(b);
+  luaL_addvalue(b);
 }
 
 
diff --git a/src/d_netcmd.c b/src/d_netcmd.c
index b3903659603ba26cc00402124f3182759953f6bd..4b45ef1a709bb0a689f886793f1a8ff2cdd17f3d 100644
--- a/src/d_netcmd.c
+++ b/src/d_netcmd.c
@@ -2598,11 +2598,13 @@ static void D_MD5PasswordPass(const UINT8 *buffer, size_t len, const char *salt,
 	memset(dest, 0, 16);
 #else
 	XBOXSTATIC char tmpbuf[256];
+	const size_t sl = strlen(salt);
 
-	if (len > 256-strlen(salt))
-		len = 256-strlen(salt);
+	if (len > 256-sl)
+		len = 256-sl;
 	memcpy(tmpbuf, buffer, len);
-	strcpy(&tmpbuf[len], salt);
+	memmove(&tmpbuf[len], salt, sl);
+	//strcpy(&tmpbuf[len], salt);
 	len += strlen(salt);
 	if (len < 256)
 		memset(&tmpbuf[len],0,256-len);
diff --git a/src/dehacked.c b/src/dehacked.c
index 75235e054f97d329a6438a070389daa59def085f..a536b4e54a73c087480c48b752f4c66373a5dcca 100644
--- a/src/dehacked.c
+++ b/src/dehacked.c
@@ -8302,6 +8302,9 @@ static inline int lib_getenum(lua_State *L)
 	} else if (fastcmp(word,"VERSIONSTRING")) {
 		lua_pushstring(L, VERSIONSTRING);
 		return 1;
+	} else if (fastcmp(word, "token")) {
+		lua_pushinteger(L, token);
+		return 1;
 	}
 
 	return 0;
diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c
index 34fce21bcec92b3693566c0f1ccdc0ae16962717..a656786df6f39cb2ee64056069e55eccf366db92 100644
--- a/src/hardware/hw_main.c
+++ b/src/hardware/hw_main.c
@@ -1675,9 +1675,9 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
 				else
 				{
 					// Skewed by bottom
-					wallVerts[0].t = (texturevpegtop + worldhigh - worldtop) * grTex->scaleY;
-					wallVerts[2].t = wallVerts[3].t - (worldhighslope - worldhigh) * grTex->scaleY;
-					wallVerts[1].t = wallVerts[2].t - (worldhighslope - worldtopslope) * grTex->scaleY;
+					wallVerts[0].t = wallVerts[1].t = (texturevpegtop + worldtop - worldhigh) * grTex->scaleY;
+					wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY;
+					wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY;
 				}
 #endif
 			}
@@ -1719,12 +1719,12 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
 				if (!(gr_linedef->flags & ML_DONTPEGBOTTOM))
 					texturevpegbottom = 0;
 				else if (gr_linedef->flags & ML_EFFECT1)
-					texturevpegbottom = worldtop - worldlow;
+					texturevpegbottom = worldbottom - worldlow;
 				else
-					texturevpegbottom = gr_frontsector->ceilingheight - gr_backsector->floorheight;
+					texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight;
 #else
 				if (gr_linedef->flags & ML_DONTPEGBOTTOM)
-					texturevpegbottom = worldtop - worldlow;
+					texturevpegbottom = worldbottom - worldlow;
                 else
                     texturevpegbottom = 0;
 #endif
@@ -1752,9 +1752,9 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
 				else if (gr_linedef->flags & ML_DONTPEGBOTTOM)
 				{
 					// Skewed by bottom
-					wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY;
-					wallVerts[2].t = wallVerts[3].t - (worldlowslope - worldlow) * grTex->scaleY;
-					wallVerts[1].t = wallVerts[2].t - (worldbottomslope - worldlowslope) * grTex->scaleY;
+					wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY;
+					//wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this
+					wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY;
 				}
 				else
 				{
diff --git a/src/i_tcp.c b/src/i_tcp.c
index 89e59c8b80eb4239c55f5833378f3dc34053f205..eca218c804dde4eabf59963d6a752d2c3aed0fa6 100644
--- a/src/i_tcp.c
+++ b/src/i_tcp.c
@@ -466,7 +466,7 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
 	UINT32 bitmask = INADDR_NONE;
 
 	if (mask && mask < 32)
-		bitmask = htonl(-1 << (32 - mask));
+		bitmask = htonl((UINT32)(-1) << (32 - mask));
 
 	if (b->any.sa_family == AF_INET)
 		return (a->ip4.sin_addr.s_addr & bitmask) == (b->ip4.sin_addr.s_addr & bitmask)
diff --git a/src/m_menu.c b/src/m_menu.c
index 24025694866ddf4d1e3dd681341f9c55fac39957..c225e7f15bc2408491e895a51cf4af2cc70e4eea 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -7424,7 +7424,7 @@ static void M_HandleFogColor(INT32 choice)
 				l = strlen(temp);
 				for (i = 0; i < l; i++)
 					cv_grfogcolor.zstring[5 - i] = temp[l - i];
-					cv_grfogcolor.zstring[5] = (char)choice;
+				cv_grfogcolor.zstring[5] = (char)choice;
 			}
 			break;
 	}
diff --git a/src/p_mobj.c b/src/p_mobj.c
index 9e061950f92e7454558467e019ec4071cb9afa25..5fb3c81d747c511fcbf718de5071ec31817062c3 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -2420,6 +2420,7 @@ static boolean P_ZMovement(mobj_t *mo)
 		case MT_BLUETEAMRING:
 		case MT_FLINGRING:
 		case MT_FLINGCOIN:
+		case MT_FLINGEMERALD:
 			// Remove flinged stuff from death pits.
 			if (P_CheckDeathPitCollide(mo))
 			{
@@ -2451,7 +2452,6 @@ static boolean P_ZMovement(mobj_t *mo)
 			if (!(mo->momx || mo->momy || mo->momz))
 				return true;
 			break;
-		case MT_FLINGEMERALD:
 		case MT_NIGHTSWING:
 			if (!(mo->momx || mo->momy || mo->momz))
 				return true;
diff --git a/src/p_spec.c b/src/p_spec.c
index 3ca697295a3a4a984dc5d071962125f59d01b57a..36df3de36c4cee81b9ae478ba7db743ac8f68b59 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -2435,10 +2435,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
 						if (rover->master->frontsector->tag != line->tag)
 							continue;
 
-						if (mo->z > *rover->topheight)
+						if (mo->z > P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector))
 							continue;
 
-						if (mo->z + mo->height < *rover->bottomheight)
+						if (mo->z + mo->height < P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))
 							continue;
 
 						foundit = true;
@@ -3228,8 +3228,8 @@ boolean P_IsFlagAtBase(mobjtype_t flag)
 				if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum)
 					continue;
 
-				if (mo->z <= *rover->topheight
-					&& mo->z >= *rover->bottomheight)
+				if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector)
+					&& mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))
 					return true;
 			}
 		}
@@ -3263,12 +3263,17 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
 	// Hmm.. maybe there's a FOF that has it...
 	for (rover = player->mo->subsector->sector->ffloors; rover; rover = rover->next)
 	{
+		fixed_t topheight, bottomheight;
+
 		if (GETSECSPECIAL(rover->master->frontsector->special, section) != number)
 			continue;
 
 		if (!(rover->flags & FF_EXISTS))
 			continue;
 
+		topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
+		bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
+
 		// Check the 3D floor's type...
 		if (rover->flags & FF_BLOCKPLAYER)
 		{
@@ -3276,27 +3281,27 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
 			if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
 				&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
 			{
-				if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != *rover->topheight)
+				if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
 					continue;
 			}
 			else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
 				&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
 			{
 				if (!(player->mo->eflags & MFE_VERTICALFLIP)
-					|| player->mo->z + player->mo->height != *rover->bottomheight)
+					|| player->mo->z + player->mo->height != bottomheight)
 					continue;
 			}
 			else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
 			{
-				if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == *rover->bottomheight)
-					|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == *rover->topheight)))
+				if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
+					|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
 					continue;
 			}
 		}
 		else
 		{
 			// Water and DEATH FOG!!! heh
-			if (player->mo->z > *rover->topheight || (player->mo->z + player->mo->height) < *rover->bottomheight)
+			if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
 				continue;
 		}
 
@@ -3318,12 +3323,17 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
 		// Hmm.. maybe there's a FOF that has it...
 		for (rover = node->m_sector->ffloors; rover; rover = rover->next)
 		{
+			fixed_t topheight, bottomheight;
+
 			if (GETSECSPECIAL(rover->master->frontsector->special, section) != number)
 				continue;
 
 			if (!(rover->flags & FF_EXISTS))
 				continue;
 
+			topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
+			bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
+
 			// Check the 3D floor's type...
 			if (rover->flags & FF_BLOCKPLAYER)
 			{
@@ -3331,27 +3341,27 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
 				if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
 					&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
 				{
-					if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != *rover->topheight)
+					if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
 						continue;
 				}
 				else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
 					&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
 				{
 					if (!(player->mo->eflags & MFE_VERTICALFLIP)
-						|| player->mo->z + player->mo->height != *rover->bottomheight)
+						|| player->mo->z + player->mo->height != bottomheight)
 						continue;
 				}
 				else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
 				{
-					if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == *rover->bottomheight)
-						|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == *rover->topheight)))
+					if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
+						|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
 						continue;
 				}
 			}
 			else
 			{
 				// Water and DEATH FOG!!! heh
-				if (player->mo->z > *rover->topheight || (player->mo->z + player->mo->height) < *rover->bottomheight)
+				if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
 					continue;
 			}
 
@@ -4336,12 +4346,17 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo)
 
 	for (rover = sector->ffloors; rover; rover = rover->next)
 	{
+		fixed_t topheight, bottomheight;
+
 		if (!rover->master->frontsector->special)
 			continue;
 
 		if (!(rover->flags & FF_EXISTS))
 			continue;
 
+		topheight = P_GetSpecialTopZ(mo, sectors + rover->secnum, sector);
+		bottomheight = P_GetSpecialBottomZ(mo, sectors + rover->secnum, sector);
+
 		// Check the 3D floor's type...
 		if (((rover->flags & FF_BLOCKPLAYER) && mo->player)
 			|| ((rover->flags & FF_BLOCKOTHERS) && !mo->player))
@@ -4350,27 +4365,27 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo)
 			if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
 				&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
 			{
-				if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != *rover->topheight)
+				if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != topheight)
 					continue;
 			}
 			else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
 				&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
 			{
 				if (!(mo->eflags & MFE_VERTICALFLIP)
-					|| mo->z + mo->height != *rover->bottomheight)
+					|| mo->z + mo->height != bottomheight)
 					continue;
 			}
 			else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
 			{
-				if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == *rover->bottomheight)
-					|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == *rover->topheight)))
+				if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottomheight)
+					|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == topheight)))
 					continue;
 			}
 		}
 		else
 		{
 			// Water and intangible FOFs
-			if (mo->z > *rover->topheight || (mo->z + mo->height) < *rover->bottomheight)
+			if (mo->z > topheight || (mo->z + mo->height) < bottomheight)
 				continue;
 		}
 
@@ -4392,12 +4407,17 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
 
 	for (rover = sector->ffloors; rover; rover = rover->next)
 	{
+		fixed_t topheight, bottomheight;
+
 		if (!rover->master->frontsector->special)
 			continue;
 
 		if (!(rover->flags & FF_EXISTS))
 			continue;
 
+		topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector);
+		bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector);
+
 		// Check the 3D floor's type...
 		if (rover->flags & FF_BLOCKPLAYER)
 		{
@@ -4405,27 +4425,27 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
 			if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
 				&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
 			{
-				if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector))
+				if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
 					continue;
 			}
 			else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
 				&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
 			{
 				if (!(player->mo->eflags & MFE_VERTICALFLIP)
-					|| player->mo->z + player->mo->height != P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector))
+					|| player->mo->z + player->mo->height != bottomheight)
 					continue;
 			}
 			else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
 			{
-				if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector))
-					|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector))))
+				if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
+					|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
 					continue;
 			}
 		}
 		else
 		{
 			// Water and DEATH FOG!!! heh
-			if (player->mo->z > P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector) || (player->mo->z + player->mo->height) < P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector))
+			if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
 				continue;
 		}
 
@@ -5277,7 +5297,15 @@ void T_LaserFlash(laserthink_t *flash)
 
 	sourcesec = ffloor->master->frontsector; // Less to type!
 
+#ifdef ESLOPE
+	top = (*ffloor->t_slope) ? P_GetZAt(*ffloor->t_slope, sector->soundorg.x, sector->soundorg.y)
+			: *ffloor->topheight;
+	bottom = (*ffloor->b_slope) ? P_GetZAt(*ffloor->b_slope, sector->soundorg.x, sector->soundorg.y)
+			: *ffloor->bottomheight;
+	sector->soundorg.z = (top + bottom)/2;
+#else
 	sector->soundorg.z = (*ffloor->topheight + *ffloor->bottomheight)/2;
+#endif
 	S_StartSound(&sector->soundorg, sfx_laser);
 
 	// Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough*
@@ -6876,6 +6904,11 @@ void T_Disappear(disappear_t *d)
 
 					if (!(lines[d->sourceline].flags & ML_NOCLIMB))
 					{
+#ifdef ESLOPE
+						if (*rover->t_slope)
+							sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y);
+						else
+#endif
 						sectors[s].soundorg.z = *rover->topheight;
 						S_StartSound(&sectors[s].soundorg, sfx_appear);
 					}
diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c
index 74b61339bbc7bba6046d9143b2fa4818a67f73c6..25fccb9f921a7fc4087e58769c7903e74eaaaaf8 100644
--- a/src/sdl/i_main.c
+++ b/src/sdl/i_main.c
@@ -144,10 +144,8 @@ void XBoxStartup()
 	myargv = NULL;
 #else
 #ifdef FORCESDLMAIN
-FUNCNORETURN
 int SDL_main(int argc, char **argv)
 #else
-FUNCNORETURN
 int main(int argc, char **argv)
 #endif
 {
@@ -216,12 +214,14 @@ int main(int argc, char **argv)
 #if defined (_WIN32) && !defined (_XBOX)
 #ifndef _WIN32_WCE
 	{
+#if 0 // just load the DLL
 		p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent");
 		if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent())
 #ifdef BUGTRAP
 			&& !InitBugTrap()
 #endif
 			)
+#endif
 		{
 			LoadLibraryA("exchndl.dll");
 		}
@@ -245,8 +245,6 @@ int main(int argc, char **argv)
 #endif
 
 	// return to OS
-#ifndef __GNUC__
 	return 0;
-#endif
 }
 #endif
diff --git a/src/w_wad.c b/src/w_wad.c
index 40fea52230c20ef4cdac76a22a162158314c080b..aeaad3ced975cafeb8a190b814d9361d381765c6 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -475,11 +475,11 @@ UINT16 W_LoadWadFile(const char *filename)
 	//
 	CONS_Printf(M_GetText("Added file %s (%u lumps)\n"), filename, numlumps);
 	wadfiles[numwadfiles] = wadfile;
-	W_LoadDehackedLumps(numwadfiles);
+	numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded
+	W_LoadDehackedLumps(numwadfiles-1);
 
 	W_InvalidateLumpnumCache();
 
-	numwadfiles++;
 	return wadfile->numlumps;
 }
 
diff --git a/src/win32/win_main.c b/src/win32/win_main.c
index 9c9a20e75cfc00127a28b150c98afc1ee344009c..663eddbd443d7b3e5f7a2fffc09b74e2c4e6a508 100644
--- a/src/win32/win_main.c
+++ b/src/win32/win_main.c
@@ -644,13 +644,16 @@ int WINAPI WinMain (HINSTANCE hInstance,
 {
 	int Result = -1;
 
+#if 0
 	// Win95 and NT <4 don't have this, so link at runtime.
 	p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsDebuggerPresent");
+#endif
 
 	UNREFERENCED_PARAMETER(hPrevInstance);
 	UNREFERENCED_PARAMETER(lpCmdLine);
 	UNREFERENCED_PARAMETER(nCmdShow);
 
+#if 0
 #ifdef BUGTRAP
 	// Try BugTrap first.
 	if((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) && InitBugTrap())
@@ -660,6 +663,7 @@ int WINAPI WinMain (HINSTANCE hInstance,
 #endif
 		// Try Dr MinGW's exception handler.
 		if (!pfnIsDebuggerPresent || !pfnIsDebuggerPresent())
+#endif
 			LoadLibraryA("exchndl.dll");
 
 		prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo);