anchor.diff:                 {_, undefined} ->
                                  fail(<<"missing stream">>, Id, State);
                  {Bucket, Stream} ->
  -                               Action = ?PERM_STREAM_GET,
  -                               {ok, Info1} = ioriol_access:update_req(Info,
  -                                        [{bucket, Bucket}, {stream, Stream}]),
  -                               case ioriol_access:is_authorized_for_stream(Access, Info1, Action) of
  -                                   {ok, Info2} ->
  -                                       {FBody, State1} = Fn(Bucket, Stream),
  -                                       State2 = State1#state{info=Info2},
  -                                       {FBody, State2};
  -                                   _Other -> fail(<<"unauthorized">>, Id, State)
  -                               end
  +                               Fn(Bucket, Stream)
              end,
   
       {reply, Body, Req, NewState}.
  +
  +if_has_permission(Bucket, Stream, Action, Id, Fn, State=#state{access=Access, info=Info}) ->
  +    {ok, Info1} = ioriol_access:update_req(Info,
  +                                           [{bucket, Bucket}, {stream, Stream}]),
  +    case ioriol_access:is_authorized_for_stream(Access, Info1, Action) of
  +        {ok, Info2} ->
  +            {FBody, State1} = Fn(Bucket, Stream),
  +            State2 = State1#state{info=Info2},
  +            {FBody, State2};
  +        _Other -> fail(<<"unauthorized">>, Id, State)
  +    end.
   
   contains(_, []) -> false;
   contains(H, [H|_]) -> true;
  
positive.code: fail(Msg, Id, State) ->
      {encode_error(Msg, Id), State}.
  
  with_stream(Fn, Msg, Id, Req, State=#state{access=Access, info=Info}) ->
      {Body, NewState} = case get_channel_args(Msg) of
                 {undefined, undefined} ->
                                 fail(<<"missing bucket and stream">>, Id, State);
  
negative.code: remove(V, [H|T], Accum) -> remove(V, T, [H|Accum]).
  
  subscribe_all(Subs, State) ->
      Action = ?PERM_STREAM_GET,
      Fun = fun ({Bucket, Stream}, State0) ->
                    Fn = fun (B, S) ->
                                 State1 = subscribe(B, S, nil, State0),
                                 {nil, State1}
                         end,
                    {_, FState} = if_has_permission(Bucket, Stream, Action, 0,
                                                    Fn, State),
                    FState;
                ({Bucket, Stream, FromSeqNum}, State0) ->
                    Fn = fun (B, S) ->
                                 State1 = subscribe(B, S, FromSeqNum, State0),
                                 {nil, State1}
                         end,
                    {_, FState} = if_has_permission(Bucket, Stream, Action, 0,
                                                    Fn, State),
                    FState;
                (Sub, State0) ->
                    lager:warning("malformed sub? ~p", [Sub]),
                    State0
            end,
      lists:foldl(Fun, State, Subs).
  
  subscribe(Bucket, Stream, FromSeqNum, State=#state{channels=Channels, iorio=Iorio}) ->
      Key = {Bucket, Stream},
  