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

  
  ## "Content-MD5 valid?"
  decision v3b9a(conn, state) do
    {reply, conn, state} = resource_call(conn, state, :validate_content_checksum)
    case reply do
      :not_validated ->
        case Base.decode64(get_header_val(conn, "content-md5")) do
          {:ok, checksum} ->
            body_hash = compute_body_md5(conn)
            if body_hash == checksum do
	      v3b9b(conn, state)
	    else
	      respond(conn, state, 400)
	    end
          _ ->
	    respond(conn, state, 400)
        end
      false ->
	respond(conn, state, 400)
      _ ->
	v3b9b(conn, state)
    end
  end
  
  ## "Malformed?"
  decision v3b9b(conn, state) do
    {reply, conn, state} = resource_call(conn, state, :malformed_request)
    if reply do
      respond(conn, state, 400)
    else
      v3b8(conn, state)
    end
  end
  
  ## "Authorized?"
  decision v3b8(conn, state) do
    {reply, conn, state} = resource_call(conn, state, :is_authorized)
    case reply do
      true ->
	v3b7(conn, state)
      auth_head ->
        conn = set_resp_header(conn, "www-authenticate", to_string(auth_head))
	respond(conn, state, 401)
    end 
  end
  
  ## "Forbidden?"
  decision v3b7(conn, state) do
    {reply, conn, state} = resource_call(conn, state, :forbidden)
    if reply do
      respond(conn, state, 403)
    else
      v3b6(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)
