diff --git a/src/g_game.c b/src/g_game.c
index 7ee6bab36fc1ad7b394a9fda0e58ae52466022dc..987a5faccfe71c7381d6c3faadd3258797d9e16b 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -3935,6 +3935,8 @@ void G_InitTeam(UINT8 team)
 	G_FreeTeamData(team);
 
 	memset(&teams[team], 0, sizeof(team_t));
+
+	teams[team].flag = 1 << (team - 1);
 }
 
 UINT8 G_AddTeam(const char *name)
diff --git a/src/p_mobj.c b/src/p_mobj.c
index 4755583c13cb44217fff351d164fb5ff3648e6bf..56c7d4cb6e6c62a9b3dbe90d8bb6af544190a0ae 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -12083,7 +12083,7 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
 	}
 	else if (i == MT_BLUEFLAG || i == MT_REDFLAG || i == MT_TEAMFLAG)
 	{
-		UINT8 team = i == MT_TEAMFLAG ? mthing->args[0] : mobjinfo[i].mass;
+		UINT8 team = i == MT_TEAMFLAG ? mthing->args[0] : G_GetTeam(mobjinfo[i].mass);
 		if (team == TEAM_NONE || team >= numteams)
 			return false;
 		else if (flagmobjs[team] && !P_MobjWasRemoved(flagmobjs[team]))
@@ -12178,6 +12178,13 @@ static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i)
 			return MT_NULL;
 		return teams[team].flag_mobj_type;
 	}
+	else if (i == MT_BLUEFLAG || i == MT_REDFLAG)
+	{
+		INT32 team = G_GetTeam(mobjinfo[i].mass);
+		if (team == TEAM_NONE || team >= numteams)
+			return MT_NULL;
+		return teams[team].flag_mobj_type;
+	}
 
 	if (!(gametyperules & GTR_TEAMS))
 	{
diff --git a/src/p_spec.c b/src/p_spec.c
index 36e07d819a496d624857dff326d70dff1c79f13e..9810ec20f599e8b367de0c6cc08a544356df1efb 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -3945,7 +3945,7 @@ void P_SetupSignExit(player_t *player)
 //
 boolean P_TeamHasFlagAtBase(UINT8 team)
 {
-	if (team == TEAM_NONE || team >= teamsingame)
+	if (team == TEAM_NONE || team >= numteams)
 		return false;
 
 	thinker_t *think;
@@ -4738,7 +4738,7 @@ static void P_ProcessExitSector(player_t *player, mtag_t sectag)
 
 static void P_ProcessTeamBase(player_t *player, UINT8 team)
 {
-	if (team == TEAM_NONE || team >= teamsingame)
+	if (team == TEAM_NONE || team >= numteams)
 		return;
 
 	if (!(gametyperules & GTR_TEAMFLAGS))
@@ -4794,14 +4794,14 @@ static void P_ProcessTeamBase(player_t *player, UINT8 team)
 	if (totalcaptured == 1)
 	{
 		UINT8 otherteam = teamscaptured[0];
-		HU_DoCEcho(va(M_GetText("%s%s\200\\captured the %s%s\200.\\\\\\\\"), GetChatColorForSkincolor(G_GetTeamColor(team)), player_names[player-players], GetChatColorForSkincolor(G_GetTeamColor(otherteam)), G_GetTeamFlagName(otherteam)));
+		HU_DoCEcho(va(M_GetText("%s%s\200\\captured the %s%s\200.\\\\\\\\"), GetChatColorForSkincolor(G_GetTeamColor(player->ctfteam)), player_names[player-players], GetChatColorForSkincolor(G_GetTeamColor(otherteam)), G_GetTeamFlagName(otherteam)));
 	}
 	else
 	{
 		char *buffer = NULL;
 		size_t buffer_size = 0;
 
-		const char *text = va(M_GetText("%s%s\200 captured the:\\"), GetChatColorForSkincolor(G_GetTeamColor(team)), player_names[player-players]);
+		const char *text = va(M_GetText("%s%s\200 captured the:\\"), GetChatColorForSkincolor(G_GetTeamColor(player->ctfteam)), player_names[player-players]);
 		buffer_size += strlen(text) + 1;
 		buffer = Z_Realloc(buffer, buffer_size, PU_STATIC, NULL);
 		strcpy(buffer, text);