anchor.diff:  			ignore;
   		24 -> % key activation (has key)
   			% it's more than one 0f0a event actually... @todo hack
  -			send_1205(CSocket, GID, 244, 0),
  -			send_1205(CSocket, GID, 54, 0),
  -			send_1213(CSocket, GID, 0, 1);
  +			send_1205(244, 0),
  +			send_1205(54, 0),
  +			send_1213(0, 1);
   		25 -> % sit on chair
  -			send_1211(CSocket, GID, A, B, 8, 0);
  +			send_1211(A, B, 8, 0);
   		26 -> % sit out of chair
  -			send_1211(CSocket, GID, A, B, 8, 2);
  +			send_1211(A, B, 8, 2);
   		%~ 30 -> % @todo (phantom ruins block 4)
   			%~ ignore;
   		_ ->
  -			log(GID, "object event ~b", [Action])
  +			log("object event ~b", [Action])
   	end;
   
   %% @doc Party information recap request.
   %% @todo Handle when the party already exists! And stop doing it wrong.
   
  -handle(16#1705, CSocket, GID, _, _) ->
  -	User = egs_db:users_select(GID),
  -	send_1706(CSocket, GID, User#users.charname);
  +handle(16#1705, _) ->
  +	User = egs_db:users_select(get(gid)),
  +	send_1706(User#users.charname);
   
   %% @doc Mission selected handler. Send the currently selected mission.
   %% @todo Probably need to dispatch that info to other party members in the same counter.
   
  -handle(16#1707, _, _, _, _) ->
  +handle(16#1707, _) ->
   	ignore;
   
   %% @doc Party settings request handler. Item distribution is random for now.
   %% @todo Handle correctly.
   
  -handle(16#1709, CSocket, GID, _, _) ->
  -	send_170a(CSocket, GID);
  +handle(16#1709, _) ->
  +	send_170a();
   
   %% @doc Counter-related handler.
   
  -handle(16#170b, CSocket, GID, _, _) ->
  -	send_170c(CSocket, GID);
  +handle(16#170b, _) ->
  +	send_170c();
   
   %% @doc Counter initialization handler? Send the code for the background image to use.
   %% @todo Handle correctly.
   
  -handle(16#1710, CSocket, GID, _, _) ->
  -	User = egs_db:users_select(GID),
  +handle(16#1710, _) ->
  +	User = egs_db:users_select(get(gid)),
   	[{quests, _}, {bg, Background}, {options, _}] = proplists:get_value(User#users.entryid, ?COUNTERS),
  -	send_1711(CSocket, GID, Background);
  +	send_1711(Background);
   
   %% @doc Dialog request handler. Do what we can.
   %% @todo Handle correctly.
   
  -handle(16#1a01, CSocket, GID, _, Data) ->
  +handle(16#1a01, Data) ->
   	<< _:32, A:8, B:8, _:16, C:8, _/bits >> = Data,
   	case [A, B, C] of
   		[ 0, 0, 2] ->
  -			log(GID, "lumilass (and more?)"),
  -			send_1a03(CSocket, GID);
  +			log("lumilass (and more?)"),
  +			send_1a03();
   		[ 0, 0, 3] ->
  -			log(GID, "pp cube"),
  -			send_1a04(CSocket, GID);
  +			log("pp cube"),
  +			send_1a04();
   		[ 0, 0, 9] ->
  -			log(GID, "types menu"),
  -			send_1a07(CSocket, GID);
  +			log("types menu"),
  +			send_1a07();
   		[80, 0, _] ->
  -			log(GID, "npc dialog choice"),
  -			send_1a02(CSocket, GID, 0, 17, 17, 3, 9);
  +			log("npc dialog choice"),
  +			send_1a02(0, 17, 17, 3, 9);
   		[90, 0, _] -> % All the replies from here are consistent but their effect is unknown.
  -			log(GID, "1a01 unknown (~b ~b ~b)", [A, B, C]),
  -			send_1a02(CSocket, GID, 0, 5, 1, 4, 5);
  +			log("1a01 unknown (~b ~b ~b)", [A, B, C]),
  +			send_1a02(0, 5, 1, 4, 5);
   		[91, 0, _] ->
  -			log(GID, "1a01 unknown (~b ~b ~b)", [A, B, C]),
  -			send_1a02(CSocket, GID, 0, 5, 5, 4, 7);
  +			log("1a01 unknown (~b ~b ~b)", [A, B, C]),
  +			send_1a02(0, 5, 5, 4, 7);
   		[92, 0, _] ->
  -			log(GID, "1a01 unknown (~b ~b ~b)", [A, B, C]),
  -			send_1a02(CSocket, GID, 0, 5, 0, 4, 0);
  +			log("1a01 unknown (~b ~b ~b)", [A, B, C]),
  +			send_1a02(0, 5, 0, 4, 0);
   		[93, 0, _] ->
  -			log(GID, "1a01 unknown (~b ~b ~b)", [A, B, C]),
  -			send_1a02(CSocket, GID, 0, 5, 18, 4, 0);
  +			log("1a01 unknown (~b ~b ~b)", [A, B, C]),
  +			send_1a02(0, 5, 18, 4, 0);
   		[ _, 2, _] ->
  -			log(GID, "1a01 unknown (~b ~b ~b)", [A, B, C]),
  -			send_1a02(CSocket, GID, 0, 0, 1, 0, 0);
  +			log("1a01 unknown (~b ~b ~b)", [A, B, C]),
  +			send_1a02(0, 0, 1, 0, 0);
   		_ ->
  -			log(GID, "1a01 unknown (~b ~b ~b) - do nothing", [A, B, C])
  +			log("1a01 unknown (~b ~b ~b) - do nothing", [A, B, C])
   	end;
   
   %% @doc Unknown command handler. Do nothing.
   
  -handle(Command, _, GID, _, _) ->
  -	log(GID, "dismissed packet ~4.16.0b", [Command]).
  +handle(Command, _) ->
  +	log("dismissed packet ~4.16.0b", [Command]).
   
   %% @doc Handle all hits received.
   %% @todo Finish the work on it.
   
  -%~ log_hits(GID, Data) ->
  +%~ log_hits(Data) ->
   	%~ <<	A:32/unsigned-integer, B:32/unsigned-integer, C:32/unsigned-integer, D:32/unsigned-integer,
   		%~ E:32/unsigned-integer, F:32/unsigned-integer, G:32/unsigned-integer, H:32/unsigned-integer,
   		%~ I:32/unsigned-integer, J:32/unsigned-integer, K:32/unsigned-integer, L:32/unsigned-integer,
   		%~ M:32/unsigned-integer, N:32/unsigned-integer, O:32/unsigned-integer, P:32/unsigned-integer,
   		%~ Q:32/unsigned-integer, R:32/unsigned-integer, S:32/unsigned-integer, T:32/unsigned-integer, _/bits >> = Data,
  -	%~ log(GID, "hit!~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b", [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]).
  -
  -handle_hits(_, _, << >>) ->
  +	%~ log("hit!~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b~n    ~8.16.0b ~8.16.0b ~8.16.0b ~8.16.0b", [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]).
  +
  +handle_hits(<< >>) ->
   	ok;
  -handle_hits(CSocket, GID, Data) ->
  +handle_hits(Data) ->
   	%~ log_hits(GID, Data),
   	<< A:224/bits, B:128/bits, _:288/bits, Rest/bits >> = Data,
  +	GID = get(gid),
   	PlayerHP = 4401,
   	TargetHP = 0,
   	Damage = 58008,
  -	Packet = << 16#0e070300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64,
  +	send(<< 16#0e070300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64,
   		1:32/little-unsigned-integer, 16#01050000:32, Damage:32/little-unsigned-integer,
   		A/binary, 0:64, PlayerHP:32/little-unsigned-integer, 0:32, 16#01000200:32,
  -		0:32, TargetHP:32, 0:32, B/binary, 16#04320000:32, 16#80000000:32, 16#26030000:32, 16#89068d00:32, 16#0c1c0105:32 >>,
  -	egs_proto:packet_send(CSocket, Packet),
  -	handle_hits(CSocket, GID, Rest).
  +		0:32, TargetHP:32, 0:32, B/binary, 16#04320000:32, 16#80000000:32, 16#26030000:32, 16#89068d00:32, 16#0c1c0105:32 >>),
  +	handle_hits(Rest).
  +
  +%% @doc Send the given packet to the client.
  +%% @todo Consolidate the receive and send functions better.
  +
  +send(Packet) ->
  +	egs_proto:packet_send(get(socket), Packet).
   
   %% @todo Possibly related to 010d. Just send seemingly safe values.
   
  -send_0111(CSocket, GID) ->
  -	Packet = << 16#01110300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64,
  -		GID:32/little-unsigned-integer, 0:32, 6:32/little-unsigned-integer, 0:32 >>,
  -	egs_proto:packet_send(CSocket, Packet).
  +send_0111() ->
  +	GID = get(gid),
  +	send(<< 16#01110300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64,
  +		GID:32/little-unsigned-integer, 0:32, 6:32/little-unsigned-integer, 0:32 >>).
   
   %% @todo Types capability list.
   
  -send_0113(CSocket, GID) ->
  +send_0113() ->
   	{ok, File} = file:read_file("p/typesinfo.bin"),
  -	Packet = << 16#01130300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, GID:32/little-unsigned-integer, File/binary >>,
  -	egs_proto:packet_send(CSocket, Packet).
  +	GID = get(gid),
  +	send(<< 16#01130300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, GID:32/little-unsigned-integer, File/binary >>).
   
   %% @doc Send the zone initialization notification.
   
  -send_0200(CSocket, GID, ZoneType) ->
  +send_0200(ZoneType) ->
   	case ZoneType of
   		mission ->
   			Var = << 16#06000500:32, 16#01000000:32, 0:64, 16#00040000:32, 16#00010000:32, 16#00140000:32 >>;
  
positive.code: 			ignore;
  		12 -> % key
  			% it's more than one 0f0a event actually... @todo hack
  			send_1205(CSocket, GID, 215, 0),
  			send_1213(CSocket, GID, 8, 1),
  			send_1205(CSocket, GID, 202, 0);
  		13 -> % button on
  			ignore;
  		14 -> % button off
  
negative.code: 		_ ->
  			Var = << 16#00040000:32, 0:160, 16#00140000:32 >>
  	end,
  	GID = get(gid),
  	send(<< 16#02000300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:96, 16#01000000:32,
  		16#ffffffff:32, Var/binary, 16#ffffffff:32, 16#ffffffff:32 >>).
  
  %% @todo Figure out what the other things are.
  
  send_0201(User, Char) ->
  	#users{gid=CharGID, lid=CharLID, questid=QuestID, zoneid=ZoneID, mapid=MapID, entryid=EntryID} = User,
  	{ok, File} = file:read_file("p/packet0201.bin"),
  	<< _:96, A:32/bits, _:96, B:32/bits, _:256, D:32/bits, _:2656, After/bits >> = File,
  	GID = get(gid),
  	send(<< 16#02010300:32, 0:32, A/binary, CharGID:32/little-unsigned-integer, 0:64, B/binary, GID:32/little-unsigned-integer,
  		0:64, CharLID:32/little-unsigned-integer, CharGID:32/little-unsigned-integer, 0:96, D/binary, QuestID:32/little-unsigned-integer,
  		ZoneID:32/little-unsigned-integer, MapID:32/little-unsigned-integer, EntryID:32/little-unsigned-integer, 0:192, QuestID:32/little-unsigned-integer,
  		ZoneID:32/little-unsigned-integer, MapID:32/little-unsigned-integer, EntryID:32/little-unsigned-integer, Char/binary, After/binary >>).
  
  %% @doc Hello packet, always sent on client connection.
  
  send_0202() ->
  	send(<< 16#02020300:32, 0:352 >>).
  
  %% @todo Not sure. Used for unspawning, and more.
  
  send_0204(PlayerGID, PlayerLID, Action) ->
  	GID = get(gid),
  	send(<< 16#02040300:32, 0:32, 16#00001200:32, PlayerGID:32/little-unsigned-integer, 0:64,
  		16#00011300:32, GID:32/little-unsigned-integer, 0:64, PlayerGID:32/little-unsigned-integer,
  		PlayerLID:32/little-unsigned-integer, Action:32/little-unsigned-integer >>).
  
  %% @doc Send the map ID to be loaded by the client.
  %% @todo Last two values are unknown.
  
  send_0205(MapType, MapNumber, MapEntry, IsSeasonal) ->
  	send(<< 16#02050300:32, 0:288, 16#ffffffff:32, MapType:32/little-unsigned-integer,
  		MapNumber:32/little-unsigned-integer, MapEntry:32/little-unsigned-integer, 0:56, IsSeasonal >>).
  
  %% @doc Indicate to the client that loading should finish.
  %% @todo Last value seems to be 2 most of the time. Never 0 though. Apparently counters have it at 4.
  
  send_0208() ->
  	GID = get(gid),
  	send(<< 16#02080300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, 2:32/little-unsigned-integer >>).
  
  %% @todo No idea what this one does. For unknown reasons it uses channel 2.
  
  send_020c() ->
  	send(<< 16#020c020c:32, 16#fffff20c:32, 0:256 >>).
  
  %% @doc Send the quest file to be loaded.
  %% @todo Probably should try sending the checksum like value (right before the file) and see if it magically fixes anything.
  
  send_020e(Filename) ->
  	{ok, File} = file:read_file(Filename),
  	Size = byte_size(File),
  	send(<< 16#020e0300:32, 0:288, Size:32/little-unsigned-integer, 0:32, File/binary, 0:32 >>).
  
  %% @doc Send the zone file to be loaded.
  
  send_020f(Filename, Layout, Season) ->
  	{ok, File} = file:read_file(Filename),
  	Size = byte_size(File),
  	send(<< 16#020f0300:32, 0:288, Layout, Season, 0:16, Size:32/little-unsigned-integer, File/binary >>).
  
  %% @todo No idea what this do. Nor why it's sent twice when loading a counter.
  
  send_0215(N) ->
  	GID = get(gid),
  	send(<< 16#02150300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, N:32/little-unsigned-integer >>).
  
  %% @todo End of character loading. Just send it.
  
  send_021b() ->
  	GID = get(gid),
  	send(<< 16#021b0300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64 >>).
  
  %% @doc Send the list of available universes.
  
  send_021e() ->
  	{ok, << File:1184/bits, _/bits >>} = file:read_file("p/unicube.bin"),
  	[StrCount] = io_lib:format("~b", [egs_db:users_count()]),
  	UCS2Count = << << X:8, 0:8 >> || X <- StrCount >>,
  	PaddingSize = (12 - byte_size(UCS2Count)) * 8,
  	send(<< 16#021e0300:32, 0:288, File/binary, UCS2Count/binary, 0:PaddingSize >>).
  
  %% @doc Send the current universe name and number.
  %% @todo Currently only have universe number 2, named EGS Test.
  
  send_0222() ->
  	UCS2Name = << << X:8, 0:8 >> || X <- "EGS Test" >>,
  	GID = get(gid),
  	send(<< 16#02220300:32, 0:32, 16#00001200:32, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64,
  		2:32/little-unsigned-integer, 0:32, UCS2Name/binary, 0:16 >>).
  
  %% @todo Not sure. Sent when going to or from room.
  
  send_0230() ->
  	GID = get(gid),
  	send(<< 16#02300300:32, 0:32, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64 >>).
  
  %% @todo Figure out what the other things are.
  
  send_0233(Users) ->
  	NbUsers = length(Users),
  	case NbUsers of
  		0 ->
  			ignore;
  		_ ->
  			GID = get(gid),
  			Header = << 16#02330300:32, 0:32, 16#00001200:32, GID:32/little-unsigned-integer, 0:64, 16#00011300:32,
  				GID:32/little-unsigned-integer, 0:64, NbUsers:32/little-unsigned-integer >>,
  			Contents = build_0233_contents(Users),
  			send(<< Header/binary, Contents/binary >>)
  	end.
  
  build_0233_contents([]) ->
  