anchor.diff:  			{reply, Error, pending, State}
   	end;
   pending({player_quit, PlayerId},
  -		State = #state{game_sup = BcGameSup,
  -					   game_event = GameEventPid,
  -					   game_id = GameId,
  -					   players = Players}) ->
  -	Player = find_player(PlayerId),
  +			#state{game_event = GameEventPid,
  +				   game_id = GameId,
  +				   players = Players} = State) ->
   	case remove_player(GameId, PlayerId) of
   		ok ->
  +			QuitPlayer = find_player(PlayerId),
   			gen_event:delete_handler(GameEventPid, {bc_game_event, PlayerId}, []),
  -			gen_event:notify(GameEventPid, {player_quit, PlayerId, Player#player.handle}),
  +			gen_event:notify(GameEventPid, {player_quit, PlayerId, QuitPlayer#player.handle}),
  +			case dict:find(PlayerId, Players) of
  +				{ok, #{monitor := Monitor}} ->
  +					erlang:demonitor(Monitor);
  +				_ ->
  +					ok
  +			end,
   			UpdatedPlayers = dict:erase(PlayerId, Players),
   			UpdatedState = State#state{players = UpdatedPlayers},
   			case pending_players_changed(GameId, UpdatedPlayers) of
  
positive.code: 	case update_out_player(OutPlayerId) of
  		ok ->
  			OutPlayer = find_player(OutPlayerId),
  			gen_event:notify(GameEventPid, 
  							 {player_out, OutPlayerId, OutPlayer#player.handle}),
  			InPlayers = in_players(GameId),
  			case length(InPlayers) of
  
negative.code: %%====================================================================
  
  init(GameId, BcGameSup) ->
  	{ok, BcInputSup} = supervisor:start_child(BcGameSup, #{
  		id => bc_input_sup,
  		start => {bc_input_serv, start_link, []},
  		modules => [bc_input_serv]													   
  	}),
  	{ok, BcGoldSup} = supervisor:start_child(BcGameSup, #{
  		id => bc_gold_sup,
  		start => {bc_gold_sup, start_link, []},
  		modules => [bc_gold_sup]													  
  	}),
  	{ok, BcEntitySup} = supervisor:start_child(BcGameSup, #{
  		id => bc_entity_sup,
  		start => {bc_entity_sup, start_link, []},
  		modules => [bc_entity_sup]
  	}),
  	{ok, GameEventPid} = supervisor:start_child(BcGameSup, #{
  		id => bc_game_event,
  		start => {gen_event, start_link, []},
  		modules => [gen_event]
  	}),
  	MapGraph = bc_map:init(),
  	CollisionTab = bc_collision:init(BcGameSup),
  	{ok, pending, #state{game_sup = BcGameSup,
  						 input_sup = BcInputSup,
  						 gold_sup = BcGoldSup,
  						 entity_sup = BcEntitySup,
  						 game_event = GameEventPid,
  						 game_id = GameId,
  						 map_graph = MapGraph,
  						 collision_tab = CollisionTab,
  						 players = dict:new()}}.
  
  pending({player_join, #{player_pid := PlayerPid, 
  						handle := Handle}},
  			#state{game_sup = BcGameSup,
  				   input_sup = BcInputSup,
  				   gold_sup = BcGoldSup,
  				   entity_sup = BcEntitySup,
  				   game_event = GameEventPid,
  				   game_id = GameId,
  				   map_graph = MapGraph,
  				   collision_tab = CollisionTab,
  				   players = Players} = State) ->
  	case save_player(GameId, Handle) of
  		{ok, PlayerId} ->
  			gen_event:notify(GameEventPid, {player_joined, PlayerId, Handle}),
  			gen_event:add_handler(GameEventPid,
  								  {bc_game_event, PlayerId},
  								  {player_pid, PlayerPid}),
  			{ok, BcGoldFsm} = supervisor:start_child(BcGoldSup, #{
  				id => PlayerId,
  				start => {bc_gold_fsm, start_link, [PlayerId, PlayerPid]},
  				modules => [bc_gold_fsm]													  
  			}),
  			{ok, BcInputServ} = supervisor:start_child(BcInputSup, #{
  				id => PlayerId,
  				start => {bc_input_serv, start_link, [BcEntitySup, MapGraph, CollisionTab, BcGoldFsm]},
  				modules => [bc_input_serv]							  
  			}),
  			UpdatedPlayers = dict:store(PlayerId,
  										#{pid => PlayerPid,
  										  monitor => erlang:monitor(process, PlayerPid)}, Players),
  			UpdatedState = State#state{players = UpdatedPlayers},
  			case pending_players_changed(GameId, UpdatedPlayers) of
  				{ok, started} ->
  					%%gen_event:notify(GameEventPid, {game_started, dict:to_list(UpdatedPlayers)}),
  					{reply, {ok, PlayerId, BcInputServ}, started, UpdatedState};
  				{ok, pending} ->
  					{reply, {ok, PlayerId, BcInputServ}, pending, UpdatedState};
  				{error, Reason} = Error ->
  					gen_event:notify(GameEventPid, {game_error, Reason}),
  					gen_event:stop(GameEventPid),
  