anchor.diff:  %% this function for such objects (except perhaps for "untyped", which indicates that no
   %% YANG type could be found).
   %% @end
  -check_type(_X, <<"object">> ) -> true;
  -check_type(_X, <<"array">>  ) -> true;
  -check_type(_X, <<"untyped">>) -> true;
  +check_type(X, <<"object">> ) -> {true, X};
  +check_type(X, <<"array">>  ) -> {true, X};
  +check_type(X, <<"untyped">>) -> {true, X};
   check_type(X, {type,_,<<"enumeration">>,En}) ->
  -    lists:any(fun({enum_,_,I}) ->
  -		      X == get_value(I)
  -	      end, En);
  -check_type(X, {type,_,<<"binary">>,_}) when is_binary(X) -> true;
  -check_type(X, {type,_,<<"bits">>,_}) when is_bitstring(X) -> true;
  -check_type(X, {type,_,<<"boolean">>,_}) -> X == <<"1">> orelse X == <<"0">>;
  -check_type(X, {type,_,<<"empty">>,_} ) -> is_empty(X);
  +    case [E || {E,V} <- [{E1,get_value(I)} || {enum,_,E1,I} <- En],
  +	       V == X] of
  +	[] -> false;
  +	[Val] ->
  +	    {true, Val}
  +    end;
  +check_type(X, {type,_,<<"binary">>,_}) when is_binary(X) -> {true, X};
  +check_type(X, {type,_,<<"bits">>,_}) when is_bitstring(X) -> {true, X};
  +check_type(X, {type,_,<<"string">>,_}) -> {true, to_list(X)};
  +check_type(<<"1">>, {type,_,<<"boolean">>,_}) -> {true, true};
  +check_type(<<"0">>, {type,_,<<"boolean">>,_}) -> {true, false};
  +check_type(X, {type,_,<<"empty">>,_} ) ->
  +    case is_empty(X) of
  +	true -> {true, []};
  +	false -> false
  +    end;
   check_type(X, {type,_,<<"decimal64">>,_}) ->
       case re:split(X, "\\.", [{return,list}]) of
  -	[Ib, Fb]  ->
  -	    %% For now, we ignore fraction-digits and range checking, but at least
  -	    %% verify that it's a decimal number
  -	    try   _ = list_to_integer(Ib),
  -		  _ = list_to_integer(Fb),
  -		     %% TODO: range checking
  -		 true
  -	    catch
  -		error:_ ->
  +	[_Ib, _Fb]  ->
  +	    case io_lib:fread("~f", binary_to_list(X)) of
  +		{ok, [F], []} ->
  +		    {true, F};
  +		_ ->
   		    false
   	    end;
   	_ ->
  
positive.code: check_type(X, {type,_,<<"uint", _/binary>> = T,_}) when is_integer(X) ->
      check_uint_type(X, T);
  check_type(X, {type,_,<<"uint", _/binary>> = T,_}) ->
      try check_uint_type(list_to_integer(binary_to_list(X)), T)
      catch
  	error:_ ->
  	    false
      end;
  check_type(_, _) ->
      %% TODO: cover all types
      true.
  
  check_int_type(N, T) when is_integer(N) ->
      if 	T == <<"uint8">>, 08 =< N, N =< 255 -> true;
  	T == <<"uint16">>, 0 =< N, N =< 65535 -> true;
  	T == <<"uint32">>, 0 =< N, N =< 4294967295 -> true;
  	T == <<"uint64">>, 0 =< N, N =< 18446744073709551615 -> true;
  	true -> false
      end.
  
  check_uint_type(N, T) when is_integer(N) ->
      if T == <<"uint8">>, 08 =< N, N =< 255 -> true;
         T == <<"uint16">>, 0 =< N, N =< 65535 -> true;
         T == <<"uint32">>, 0 =< N, N =< 4294967295 -> true;
         T == <<"uint64">>, 0 =< N, N =< 18446744073709551615 -> true;
         true -> false
      end.
  
  
  get_value(I) ->
  
negative.code: check_type(X, {type,_,<<"int", _/binary>> = T,_}) when is_integer(X) ->
      check_int_type(X, T);
  check_type(X, {type,_,<<"int", _/binary>> = T,_}) ->
      try check_int_type(list_to_integer(to_list(X)), T)
      catch
  	error:_ ->
  	    false
  