anchor.diff:  			end;
   		{reply, {Pid, StreamID}, Status, Headers}
   				when Pid =:= self() ->
  -			Child = #child{output=nofin} = lists:keyfind(StreamID,
  -				#child.streamid, Children),
  +			Child = #child{output=nofin} = get_child(StreamID, State),
   			syn_reply(State, StreamID, true, Status, Headers),
  -			Children2 = lists:keyreplace(StreamID,
  -				#child.streamid, Children, Child#child{output=fin}),
  -			loop(State#state{children=Children2});
  +			loop(out_fin_child(Child, State));
   		{reply, {Pid, StreamID}, Status, Headers, Body}
   				when Pid =:= self() ->
  -			Child = #child{output=nofin} = lists:keyfind(StreamID,
  -				#child.streamid, Children),
  +			Child = #child{output=nofin} = get_child(StreamID, State),
   			syn_reply(State, StreamID, false, Status, Headers),
   			data(State, StreamID, true, Body),
  -			Children2 = lists:keyreplace(StreamID,
  -				#child.streamid, Children, Child#child{output=fin}),
  -			loop(State#state{children=Children2});
  +			loop(out_fin_child(Child, State));
   		{stream_reply, {Pid, StreamID}, Status, Headers}
   				when Pid =:= self() ->
  -			#child{output=nofin} = lists:keyfind(StreamID,
  -				#child.streamid, Children),
  +			#child{output=nofin} = get_child(StreamID, State),
   			syn_reply(State, StreamID, false, Status, Headers),
   			loop(State);
   		{stream_data, {Pid, StreamID}, Data}
   				when Pid =:= self() ->
  -			#child{output=nofin} = lists:keyfind(StreamID,
  -				#child.streamid, Children),
  +			#child{output=nofin} = get_child(StreamID, State),
   			data(State, StreamID, false, Data),
   			loop(State);
   		{stream_close, {Pid, StreamID}}
   				when Pid =:= self() ->
  -			Child = #child{output=nofin} = lists:keyfind(StreamID,
  -				#child.streamid, Children),
  +			Child = #child{output=nofin} = get_child(StreamID, State),
   			data(State, StreamID, true, <<>>),
  -			Children2 = lists:keyreplace(StreamID,
  -				#child.streamid, Children, Child#child{output=fin}),
  -			loop(State#state{children=Children2});
  +			loop(out_fin_child(Child, State));
   		{sendfile, {Pid, StreamID}, Filepath}
   				when Pid =:= self() ->
  -			Child = #child{output=nofin} = lists:keyfind(StreamID,
  -				#child.streamid, Children),
  +			Child = #child{output=nofin} = get_child(StreamID, State),
   			data_from_file(State, StreamID, Filepath),
  -			Children2 = lists:keyreplace(StreamID,
  -				#child.streamid, Children, Child#child{output=fin}),
  -			loop(State#state{children=Children2});
  +			loop(out_fin_child(Child, State));
   		{'EXIT', Parent, Reason} ->
   			exit(Reason);
   		{'EXIT', Pid, _} ->
   			%% @todo Report the error if any.
  -			Children2 = lists:keydelete(Pid, #child.pid, Children),
  -			loop(State#state{children=Children2});
  +			loop(delete_child(Pid, State));
   		{system, From, Request} ->
   			sys:handle_system_msg(Request, From, Parent, ?MODULE, [], State);
   		%% Calls from the supervisor module.
  
positive.code: 		{recv, FromSocket = {Pid, StreamID}, FromPid, Length, _Timeout}
  				when Pid =:= self() ->
  			Child = #child{in_buffer=InBuffer, is_recv=false}
  				= lists:keyfind(StreamID, #child.streamid, Children),
  			if
  				Length =:= 0, InBuffer =/= <<>> ->
  					FromPid ! {recv, FromSocket, {ok, InBuffer}},
  
negative.code: %% Erlang does not allow us to control the priority of processes
  %% so we ignore that value entirely.
  handle_frame(State=#state{middlewares=Middlewares, env=Env,
  		onrequest=OnRequest, onresponse=OnResponse, peer=Peer},
  		{syn_stream, StreamID, _, IsFin, _, _,
  		Method, _, Host, Path, Version, Headers}) ->
  	Pid = spawn_link(?MODULE, request_init, [
  		{self(), StreamID}, Peer, OnRequest, OnResponse,
  		Env, Middlewares, Method, Host, Path, Version, Headers
  	]),
  	loop(new_child(State, StreamID, Pid, IsFin));
  %% RST_STREAM.
  handle_frame(State, {rst_stream, StreamID, Status}) ->
  	error_logger:error_msg("Received RST_STREAM frame ~p ~p",
  