anchor.diff:  
   del_entity_t(#occi_resource{id=Id}=Res) ->
       sets:fold(fun (MixinId, _) ->
  -		      del_from_collection_t(MixinId, [Id])
  -		  end, ok, occi_resource:get_mixins(Res)),
  +					  del_from_collection_t(MixinId, [Id])
  +			  end, ok, occi_resource:get_mixins(Res)),
       mnesia:delete({occi_resource, Id});
   
   del_entity_t(#occi_link{id=Id}=Link) ->
       sets:fold(fun (MixinId, _) ->
  -		      del_from_collection_t(MixinId, [Id])
  -	      end, ok, occi_link:get_mixins(Link)),
  +					  del_from_collection_t(MixinId, [Id])
  +			  end, ok, occi_link:get_mixins(Link)),
       mnesia:delete({occi_link, Id}).
   
   del_from_collection_t(#uri{}=Id, Uri) ->
       case mnesia:wread({occi_node, Id}) of
  -	[] ->
  -	    mnesia:abort({unkown_collection, Id});
  -	[#occi_node{type=occi_collection, data=Col}=Node] ->
  -	    Col1 = occi_collection:del_entity(Col, {entity, Uri}),
  -	    case occi_collection:is_empty(Col1) of
  -		true ->
  -		    mnesia:delete({occi_node, Id});
  -		false ->
  -		    mnesia:write(Node#occi_node{data=Col1})
  -	    end;
  -	_ ->
  -	    mnesia:abort({not_a_collection, Id})
  +		[] ->
  +			mnesia:abort({unkown_collection, Id});
  +		[#occi_node{type=occi_collection, data=Col}=Node] ->
  +			Col1 = occi_collection:del_entity(Col, {entity, Uri}),
  +			case occi_collection:is_empty(Col1) of
  +				true ->
  +					mnesia:delete({occi_node, Id});
  +				false ->
  +					mnesia:write(Node#occi_node{data=Col1})
  +			end;
  +		_ ->
  +			mnesia:abort({not_a_collection, Id})
       end;
   
   del_from_collection_t(#occi_cid{class=mixin}=Cid, Uris) ->
       case mnesia:wread({occi_collection, Cid}) of
  -	[#occi_collection{}=C] ->
  -	    mnesia:write(occi_collection:del_entities(C, Uris));
  -	[] ->
  -	    mnesia:abort({unknown_collection, Cid})
  +		[#occi_collection{}=C] ->
  +			mnesia:write(occi_collection:del_entities(C, Uris));
  +		[] ->
  +			mnesia:abort({unknown_collection, Cid})
       end.
   
   del_collection_t(#occi_collection{id=#occi_cid{class=kind}}=Coll) ->
       F = fun (#uri{}=Id, Acc) ->
  -		case mnesia:wread({occi_node, Id}) of
  -		    [#occi_node{type=Type, objid=ObjId}=N] ->
  -			Node = load_node_t(N, []),
  -			mnesia:delete({Type, ObjId}),
  -			del_entity_t(Node#occi_node.data),
  -			mnesia:delete({occi_node, Id}),
  -			sets:fold(fun (MixinId, Acc2) ->
  -					  dict:append(MixinId, Id, Acc2)
  -				  end, 
  -				  dict:append(occi_node:get_parent(Node), Id, Acc),
  -				  occi_entity:get_mixins(Node#occi_node.data));
  -		    [] ->
  -			mnesia:abort({unknown_object, Id})
  -		end
  -	end,
  +				case mnesia:wread({occi_node, Id}) of
  +					[#occi_node{type=Type, objid=ObjId}=N] ->
  +						Node = load_node_t(N, []),
  +						mnesia:delete({Type, ObjId}),
  +						del_entity_t(Node#occi_node.data),
  +						mnesia:delete({occi_node, Id}),
  +						sets:fold(fun (MixinId, Acc2) ->
  +										  dict:append(MixinId, Id, Acc2)
  +								  end, 
  +								  dict:append(occi_node:get_parent(Node), Id, Acc),
  +								  occi_entity:get_mixins(Node#occi_node.data));
  +					[] ->
  +						mnesia:abort({unknown_object, Id})
  +				end
  +		end,
       Uris = occi_collection:get_entities(Coll),
       Colls = lists:foldl(F, dict:new(), Uris),
       dict:map(fun (Key, Values) ->
  -		     del_from_collection_t(Key, Values)
  -	     end, Colls),
  +					 del_from_collection_t(Key, Values)
  +			 end, Colls),
       ok;
   
   del_collection_t(#occi_collection{id=#occi_cid{class=mixin}=Cid}=Coll) ->
  
positive.code: init_schema(Opts) ->
      application:load(mnesia),
      case application:get_env(mnesia, dir, "") of
  	"" ->
  	    init_db(Opts);
  	Path ->
  	    case filelib:is_file(filename:join([Path, "schema.DAT"])) of
  		true ->
  		    ?debug("mnesia schema already exists on this node", []),
  		    init_db(Opts);
  		false ->
  		    ?debug("Creating mnesia schema on ~s", [Path]),
  		    case mnesia:create_schema([node()]) of
  			ok ->
  			    init_db(Opts);
  			{error, {_, {already_exists,_}}} ->
  			    init_db(Opts);
  			{error, Err} ->
  			    ?error("Error creating mnesia schema on node ~p: ~p", [node(), Err]),
  			    {error, Err}
  		    end
  	    end
      end.
  
  init_db(Opts) ->
      application:start(mnesia, permanent),
      Tables = [{occi_collection, [{disc_copies, [node()]},
  				 {attributes, record_info(fields, occi_collection)}]},
  	      {occi_resource, [{disc_copies, [node()]},
  			       {attributes, record_info(fields, occi_resource)},
  			       {index, [#occi_resource.cid]}]},
  	      {occi_link, [{disc_copies, [node()]},
  			   {attributes, record_info(fields, occi_link)},
  			   {index, [#occi_link.cid]}]},
  	      {occi_mixin, [{disc_copies, [node()]},
  			    {attributes, record_info(fields, occi_mixin)}]},
  	      {occi_node, [{disc_copies, [node()]}, 
  			   {attributes, record_info(fields, occi_node)},
  			   {index, [#occi_node.objid]},
  			   {type, 'ordered_set'}]},
  	      {occi_user, [{disc_copies, [node()]},
  			   {attributes, record_info(fields, occi_user)}]}],
      case init_tables(Tables) of
  	ok ->
  	    mnesia:wait_for_tables([occi_collection, occi_resource, occi_link,
  				    occi_mixin, occi_node, occi_user], 5000),
  	    init_backend(Opts);
  	{error, Err} ->
  	    ?error("Error creating mnesia tables: ~p", [Err]),
  	    {error, Err}
      end.
  
  init_tables([]) ->
      ok;
  init_tables([{Name, TabDef} | Tables]) ->
      case mnesia:create_table(Name, TabDef) of
  	{atomic, ok} ->
  	    ?debug("mnesia: created table: ~p~n", [Name]),
  	    init_tables(Tables);
  	{aborted, {already_exists, Name}} ->
  	    ?debug("mnesia: table ~p already exists~n", [Name]),
  	    init_tables(Tables);
  	{aborted, Reason} ->
  	    {error, Reason}
      end.
  
  init_backend(Opts) ->
      Schemas = lists:map(fun ({path, _Path}=S) -> 
  				S;
  			    ({priv_dir, Path}) -> 
  				Fullpath = filename:join([code:priv_dir(occi_backend_mnesia), Path]),
  				{path, Fullpath}
  			end, 
  		       proplists:get_value(schemas, Opts, []) 
  			++ application:get_env(occi_backend_mnesia, schemas, [])),
      F = fun() -> mnesia:match_object(#occi_node{type=capabilities, _='_'}) end,
      case mnesia:transaction(F) of
  	{atomic, []} -> 
  	    {ok, [{schemas, Schemas}], #state{}};
  	{atomic, MixinsNodes} ->
  	    Mixins = [ Mixin || #occi_node{data=Mixin} <- MixinsNodes],
  	    {ok, [{schemas, lists:flatten([Schemas, Mixins])}], #state{}};
  	{aborted, Reason} ->
  	    {error, Reason}
      end.
  
negative.code:     add_link_t(Id, occi_link:get_target(Link)),
      mnesia:write(Link),
      sets:fold(fun (#occi_cid{}=MixinId, _) ->
  					  add_to_collection_t(MixinId, [Id])
  			  end, ok, occi_link:get_mixins(Link)),
      ok.
  
  add_link_t(LinkId, Id) ->
      case get_resource_t(Id) of
  		false ->
  			mnesia:abort({unknown_resource, Id});
  		{ok, Res} ->
  			mnesia:write(occi_resource:add_link(Res, LinkId))
      end.
  
  save_node_t(#occi_node{id=Id}=Node) ->
      case mnesia:wread({occi_node, Id}) of
  		[_] -> 	
  			mnesia:write(Node#occi_node{data=undefined});
  		[] -> 
  			mnesia:write(Node#occi_node{data=undefined}),
  			add_to_collection_t(occi_uri:get_parent(Id), {entity, Id})
      end.
  
  update_t(#occi_node{type=capabilities}=Node) ->
  