diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c
index 8bbbebe1d4c1340e974bd4df7e3d9b29d8ddaa1a..5fc3babd3b657fe88133910f552171a286545604 100644
--- a/src/lua_mobjlib.c
+++ b/src/lua_mobjlib.c
@@ -804,7 +804,12 @@ static int mapthing_set(lua_State *L)
 	else if(fastcmp(field,"z"))
 		mt->z = (INT16)luaL_checkinteger(L, 3);
 	else if(fastcmp(field,"extrainfo"))
-		mt->extrainfo = (UINT8)luaL_checkinteger(L, 3);
+	{
+		INT32 extrainfo = luaL_checkinteger(L, 3);
+		if (extrainfo & ~15)
+			return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15);
+		mt->extrainfo = (UINT8)extrainfo;
+	}
 	else if(fastcmp(field,"mobj"))
 		mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
 	else
diff --git a/src/p_mobj.c b/src/p_mobj.c
index fe45a799a7ede072d224a970dd141a155de1da24..5b924c3eb5aab8eb8832092d6945272df005f49a 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -7011,7 +7011,7 @@ void P_MobjThinker(mobj_t *mobj)
 	if (mobj->flags & MF_NOTHINK)
 		return;
 
-	if ((mobj->flags & MF_BOSS) && mobj->spawnpoint && !(mobj->spawnpoint->extrainfo & ~15) && (bossdisabled & (1<<mobj->spawnpoint->extrainfo)))
+	if ((mobj->flags & MF_BOSS) && mobj->spawnpoint && (bossdisabled & (1<<mobj->spawnpoint->extrainfo)))
 		return;
 
 	// Remove dead target/tracer.