anchor.diff:      Remaining = [{Key, string:join(Value, " ")} || {Key, Value} <- RawRemaining],
       {Values, Remaining}.
   
  -format_field([], []) ->
  -    [];
  -format_field([Metadata|Values], [metadata|Fields]) ->
  -    FormattedMetadata =
  -	[io_lib:format("metadata[~p]: ~ts", [Key, Value]) || {Key, Value} <- Metadata],
  -    string:join(FormattedMetadata, "~n") ++ format_field(Values, Fields);
  -format_field([Value|Values], [Field|Fields]) when is_list(Value) ->
  -    io_lib:format("~p: ~ts~n", [Field, unicode:characters_to_binary(Value)]) ++ format_field(Values, Fields);
  -format_field([Value|Values], [Field|Fields]) ->
  -    io_lib:format("~p: ~p~n", [Field, Value]) ++ format_field(Values, Fields).
  -
  -format(Record, Fields) ->
  +json_escape(String) when is_list(String) ->
  +    re:replace(String, "\"", "\\\"", [{return, list}]);
  +json_escape(Integer) when is_integer(Integer) ->
  +    Integer.
  +
  +display_metadata(json, []) ->
  +    [];
  +display_metadata(json, [{Key, Value}|Tail]) ->
  +    io:format("        ~p: ~p", [json_escape(Key), json_escape(Value)]),
  +    case Tail of
  +	[] ->
  +	    io:format("~n");
  +	_ ->
  +	    io:format(",~n")
  +    end,
  +   display_metadata(json, Tail).
  +
  +display_field(json, [], []) ->
  +    [];
  +display_field(json, [Value|Values], [Field|Fields]) ->
  +    case Field of
  +	metadata ->
  +	    io:format("    \"metadata\": {~n"),
  +	    display_metadata(json, Value),
  +	    io:format("    }");
  +	_ ->
  +	    io:format("    ~p: ~p", [json_escape(atom_to_list(Field)),
  +					     json_escape(Value)])
  +    end,
  +    case Fields of
  +	[] ->
  +	    io:format("~n");
  +	_ ->
  +	    io:format(",~n")
  +    end,
  +    display_field(json, Values, Fields).
  +
  +display(json, Records, Fields) when is_list(Records) ->
  +    io:format("["),
  +    [display(json, Record, Fields) || Record <- Records],
  +    io:format("]");
  +display(json, Record, Fields) ->
       [_|Values] = tuple_to_list(Record),
  -    format_field(Values, Fields).
  -	    
  +    io:format("{~n"),
  +    display_field(json, Values, Fields),
  +    io:format("}");
  +
  +display(erlang, Record, _) ->
  +    io:format("~p~n", [Record]).    
  +    
   call(Object, Action, Args) ->
       Module = list_to_atom("uce_" ++ atom_to_list(Object)),
       NodeStr = "ucengine@localhost",
  
positive.code: action(meeting, add, Args) ->
      {[[Name], [Org], Start, End], Metadata} =
  	getopt(["name", "org", "start", "end"], Args),
      call(meeting, add, [#uce_meeting{id=[Org, Name],
  				     start_date=parse_date(Start),
  				     end_date=parse_date(End),
  				     metadata=Metadata}]);
  
  action(meeting, delete, Args) ->
      {[[Name], [Org]], _} = getopt(["name", "org"], Args),
      call(meeting, delete, [{Org, Name}]);
  
  action(meeting, get, Args) ->
      {[[Name], [Org]], _} = getopt(["name", "org"], Args),
      call(meeting, get, [{Org, Name}]);
  
  action(meeting, update, Args) ->
      {[[Name], [Org], Start, End], Metadata} =
  	getopt(["name", "org", "start", "end"], Args),
      call(meeting, update, [#uce_meeting{id=[Org, Name],
  					start_date=parse_date(Start),
  					end_date=parse_date(End),
  					metadata=Metadata}]);
  
  action(meeting, list, Args) ->
      case getopt([name, status], Args) of
  	{[[Name], [Status]], _} ->
  	    call(meeting, list, [Name, Status]);
  	{[[Name]], _} ->
  	    call(meeting, list, [Name, "all"])
      end;
  
  %%
  %% Utils
  
negative.code: 	    {error, bad_date}
      end.
  
  success(Result) ->
      io:format("Success: ~p", [Result]),
      ok.
  
  error(Reason) ->
      io:format("Error: ~p", [Reason]),
      error.
  
  %%
  %% Org
  %%
  action(org, add, Args) ->
      {[[Name]], Metadata} = getopt(["name"], Args),
      case call(org, add, [#uce_org{name=Name, metadata=Metadata}]) of
  	{ok, created} ->
  	    success(created);
  	{error, Reason} ->
  	    error(Reason)
      end;
  
  action(org, get, Args) ->
      {[[Name]], _} = getopt(["name"], Args),
      case call(org, get, [Name]) of
  	{ok, Record} ->
  	    display(json, Record, record_info(fields, uce_org));
  	{error, Reason} ->
  	    error(Reason)
      end;
  
  action(org, update, Args) ->
      {[[Name]], Metadata} = getopt(["name"], Args),
      case call(org, update, [#uce_org{name=Name, metadata=Metadata}]) of
  	{ok, updated} ->
  	    success(updated);
  	{error, Reason} ->
  	    error(Reason)
      end;
  
  action(org, delete, Args) ->
      {[[Name]], _} = getopt(["name"], Args),
      case call(org, delete, [Name]) of
  	{ok, deleted} ->
  	    success(deleted);
  	{error, Reason} ->
  	   error(Reason)
      end;
  
  action(org, list, _Args) ->
      case call(org, list, []) of
  	{ok, Records} ->
  	    display(json, Records, record_info(fields, uce_org));
  	{error, Reason} ->
  	    error(Reason)
      end;
  
  %%
  %% Meeting
  