   
   ## "Moved temporarily?"
   decision v3l5(conn, state) do
-    {moved, conn, state} = resource_call(conn, state, :moved_temporarily)
-    case moved do
-      {true, moved_uri} ->
-	set_resp_header(conn, "location", moved_uri)
+    case resource_call(conn, state, :moved_temporarily) do
+      {{true, moved_uri}, conn, state} ->
+	conn = set_resp_header(conn, "location", moved_uri)
 	respond(conn, state, 307)
-      false ->
+      {false, conn, state} ->
 	v3m5(conn, state)
     end
   end

  
  ## "Conflict?"
  decision v3o14(conn, state) do
    {conflict, conn, state} = resource_call(conn, state, :is_conflict)
    case conflict do
      true ->
	respond(conn, state, 409)
      _ -> 
        conn = accept_helper(conn, state)
        v3p11(conn, state)
    end
  end

  def encode_body_if_set(conn, state) do
    if has_resp_body(conn) do
      body = resp_body(conn)
      {body, conn, state} = encode_body(conn, state, body)
      conn = set_resp_body(conn, body)
      {:ok, conn, state}
    else
      {:ok, conn, state}
    end
  end
  
  def encode_body(conn, state, body) do
    chosen_cset = get_metadata(conn, :'chosen-charset')
    {charsetter, conn, state} = case resource_call(conn, state, :charsets_provided) do
				  {:no_charset, c, s} ->
				    {&(&1), c, s}
				  {cp, c, s} ->
				    cs = Enum.find_value(cp, fn {c, f} ->
				      (to_string(c) == chosen_cset) && f
				    end) || &(&1)
				    {cs, c, s}
				end
    chosen_enc = get_metadata(conn, :'content-encoding')
    {enc_provided, conn, state} = resource_call(conn, state, :encodings_provided)
    encoder = Enum.find_value(enc_provided,
      fn {enc,f} -> (to_string(enc) == chosen_enc) && f end) || &(&1)
    body = case body do
	     body when is_binary(body) or is_list(body) ->
	       body |> IO.iodata_to_binary |> charsetter.() |> encoder.()
	     _->
	       body |> Stream.map(&IO.iodata_to_binary/1) |> Stream.map(charsetter) |> Stream.map(encoder)
	   end
    {body, conn, state}
  end
  
  def choose_encoding(conn, state, acc_enc_hdr) do
    {enc_provided, conn, state} = resource_call(conn, state, :encodings_provided)
    encs = for {enc, _} <- enc_provided, do: to_string(enc)
    chosen_enc = choose_encoding(encs, acc_enc_hdr)
    conn = if chosen_enc !== "identity" do
      set_resp_header(conn, "content-encoding", chosen_enc)
