anchor.diff:      check_fold(S, Names, fun do_checkc/3).
   
   do_checkc(S, Name, Class) ->
  -    case is_classname(Name) of
  -	false ->
  -	    return_asn1_error(S, {illegal_class_name,Name});
  -	true ->
  -	    do_checkc_1(S, Name, Class)
  +    try
  +	case is_classname(Name) of
  +	    false ->
  +		asn1_error(S, {illegal_class_name,Name});
  +	    true ->
  +		do_checkc_1(S, Name, Class)
  +	end
  +    catch {error,Reason} -> Reason
       end.
   
   do_checkc_1(S, Name, #classdef{}=Class) ->
  -    try check_class(S, Class) of
  -	C ->
  -	    store_class(S, true, Class#classdef{typespec=C}, Name),
  -	    ok
  -    catch
  -	{error,Reason} ->
  -	    error({class,Reason,S})
  -    end;
  +    C = check_class(S, Class),
  +    store_class(S, true, Class#classdef{typespec=C}, Name),
  +    ok;
   do_checkc_1(S, Name, #typedef{typespec=#type{def=Def}=TS}) ->
  -    try check_class(S, TS) of
  -	C ->
  -	    {Mod,Pos} = case Def of
  -			    #'Externaltypereference'{module=M, pos=P} ->
  -				{M,P};
  -			    {pt, #'Externaltypereference'{module=M, pos=P}, _} ->
  -				{M,P}
  -			end,
  -	    Class = #classdef{name=Name, typespec=C, pos=Pos, module=Mod},
  -	    store_class(S, true, Class, Name),
  -	    ok
  -    catch
  -	{error,Reason} ->
  -	    error({class,Reason,S})
  -    end.
  +    C = check_class(S, TS),
  +    {Mod,Pos} = case Def of
  +		    #'Externaltypereference'{module=M, pos=P} ->
  +			{M,P};
  +		    {pt, #'Externaltypereference'{module=M, pos=P}, _} ->
  +			{M,P}
  +		end,
  +    Class = #classdef{name=Name, typespec=C, pos=Pos, module=Mod},
  +    store_class(S, true, Class, Name),
  +    ok.
   
   %% is_classname(Atom) -> true|false.
   is_classname(Name) when is_atom(Name) ->
  
positive.code: checko(S0,[Name|Os],Acc,ExclO,ExclOS) ->
      Item = asn1_db:dbget(S0#state.mname, Name),
      S = S0#state{error_context=Item},
      Result = 
  	case Item of
  	    Object when is_record(Object,typedef) ->
  		NewS = S#state{type=Object,tname=Name},
  		case catch(check_object(NewS,Object,Object#typedef.typespec)) of
  		    {error,Reason} ->
  			error({type,Reason,NewS});
  		    {'EXIT',Reason} ->
  			error({type,{internal_error,Reason},NewS});
  		    O ->
  			NewObj = Object#typedef{checked=true,typespec=O},
  			asn1_db:dbput(NewS#state.mname,Name,NewObj),
  			if
  			    is_record(O,'Object') ->
  				case O#'Object'.gen of
  				    true ->
  					{ok,ExclO,ExclOS};
  				    false ->
  					{ok,[Name|ExclO],ExclOS}
  				end;
  			    is_record(O,'ObjectSet') ->
  				case O#'ObjectSet'.gen of
  				    true ->
  					{ok,ExclO,ExclOS};
  				    false ->
  					{ok,ExclO,[Name|ExclOS]}
  				end
  			end
  		end;
  	    PObject when is_record(PObject,pobjectdef) ->
  		NewS = S#state{type=PObject,tname=Name},
  		case (catch check_pobject(NewS,PObject)) of
  		    {error,Reason} ->
  			error({type,Reason,NewS});
  		    {'EXIT',Reason} ->
  			error({type,{internal_error,Reason},NewS});
  		    PO ->
  			NewPObj = PObject#pobjectdef{def=PO},
  			asn1_db:dbput(NewS#state.mname,Name,NewPObj),
  			{ok,[Name|ExclO],ExclOS}
  		end;
  	    PObjSet when is_record(PObjSet,pvaluesetdef) ->
  		%% this is a parameterized object set. Might be a parameterized
  		%% value set, couldn't it?
  		NewS = S#state{type=PObjSet,tname=Name},
  		case (catch check_pobjectset(NewS,PObjSet)) of
  		    {error,Reason} ->
  			error({type,Reason,NewS});
  		    {'EXIT',Reason} ->
  			error({type,{internal_error,Reason},NewS});
  		    POS ->
  			%%NewPObjSet = PObjSet#pvaluesetdef{valueset=POS},
  			asn1_db:dbput(NewS#state.mname,Name,POS),
  			{ok,ExclO,[Name|ExclOS]}
  		end
  	end,
      case Result of
  	{ok,NewExclO,NewExclOS} ->
  	    checko(S,Os,Acc,NewExclO,NewExclOS);
  	_ ->
  	    checko(S,Os,[Result|Acc],ExclO,ExclOS)
      end;
  checko(_S,[],Acc,ExclO,ExclOS) ->
      {lists:reverse(Acc),lists:reverse(ExclO),lists:reverse(ExclOS)}.
  
  check_class(S,CDef=#classdef{checked=Ch,name=Name,typespec=TS}) ->
      case Ch of
  
negative.code: %% Main Module for ASN.1 compile time functions
  
  %-compile(export_all).
  -export([check/2,storeindb/2,format_error/1]).
  %-define(debug,1).
  -include("asn1_records.hrl").
  