With two players autobalancer sometimes assigns both players to the same team, instead of assigning them to different teams. This is a problem, for example, in a team game with a minimum of two players, which expects players to be assigned to different teams.
If I uncheck the only switch dead players option, then this seems to balance correctly.
I would like to recommend some improvements in the functionality of this code:
I think it would be very confusing if a player is switched teams mid-round. Can you add an option to not do any switching if the game is in round. So the only time switching occurs would be during the lobby phase.
With the above change, when a new player joins the game, have them go to the appropriate team based on balance.
IMO, all of this should really be automatic and built into the system. Anyone who builds a team game expects autobalanced teams.