anchor.diff:    if  ((lParams.Length > 0)  and  (length(lParams[lParams.Length-1].GetCustomAttributes(typeOf(ParamArrayAttribute), false)) > 0)) then 
       lParamStart := lParams.Length -1;
   
  -  for  j: Int32  :=  0  to  length(aArgs)-1  do  begin
  +  for  j: Int32  :=  0  to  length(parameters)-1  do  begin
       if  ((lParamStart <> -1)  and  (j >= lParamStart))  then  begin
         if  (j = lParamStart)  then
  -        lReal[j] := Array.CreateInstance(lParams[lParams.Length-1].ParameterType.GetElementType, length(aArgs) - lParamStart);
  -
  -      Array(lReal[lParamStart]).SetValue(ConvertTo(aArgs[j], lParams[lParams.Length-1].ParameterType.GetElementType()), j - lParamStart);
  +        lReal[j] := Array.CreateInstance(lParams[lParams.Length-1].ParameterType.GetElementType, length(parameters) - lParamStart);
  +
  +      Array(lReal[lParamStart]).SetValue(ConvertTo(parameters[j], lParams[lParams.Length-1].ParameterType.GetElementType()), j - lParamStart);
       end
       else  begin
  -      lReal[j] := ConvertTo(aArgs[j], lParams[j].ParameterType);
  +      lReal[j] := ConvertTo(parameters[j], lParams[j].ParameterType);
       end;
     end;
   
     try
       if  (lMeth  is  ConstructorInfo)  then
  -      exit  (EcmaScriptScope.DoTryWrap(aRoot, ConstructorInfo(lMeth).Invoke(lReal)));
  -
  -    exit  (EcmaScriptScope.DoTryWrap(aRoot, lMeth.Invoke(aSelf, lReal)));
  +      exit  (EcmaScriptScope.DoTryWrap(root, ConstructorInfo(lMeth).Invoke(lReal)));
  +
  +    exit  (EcmaScriptScope.DoTryWrap(root, lMeth.Invoke(&self, lReal)));
     except
  -    on  e: TargetInvocationException  do  begin
  -      if  (e.InnerException is RemObjects.Script.ScriptRuntimeException)  then
  -        raise e.InnerException;
  -
  -      raise  new RemObjects.Script.ScriptRuntimeException(EcmaScriptScope.DoTryWrap(aRoot, e.InnerException) as EcmaScriptObject);
  -    end;
  -    on  e: Exception where e is not RemObjects.Script.ScriptRuntimeException  do
  -      raise new RemObjects.Script.ScriptRuntimeException(EcmaScriptScope.DoTryWrap(aRoot, e) as EcmaScriptObject);
  -  end;
  -end;
  -
  -
  -class method EcmaScriptObjectWrapper.IsCompatibleType(aInput: &Type;  aTarget: &Type): Boolean;
  -begin
  -  if  ((aInput = nil)  or  (aInput = typeOf(Undefined)))  then
  -    exit  (not aTarget.IsValueType);
  -
  -  if  (aTarget.IsAssignableFrom(aInput))  then
  +    on  ex: TargetInvocationException  do  begin
  +      if  (ex.InnerException is RemObjects.Script.ScriptRuntimeException)  then
  +        raise ex.InnerException;
  +
  +      raise  new RemObjects.Script.ScriptRuntimeException(EcmaScriptScope.DoTryWrap(root, ex.InnerException) as EcmaScriptObject);
  +    end;
  +    on  ex: Exception where ex is not RemObjects.Script.ScriptRuntimeException  do
  +      raise new RemObjects.Script.ScriptRuntimeException(EcmaScriptScope.DoTryWrap(root, ex) as EcmaScriptObject);
  +  end;
  +end;
  +
  +
  +class method EcmaScriptObjectWrapper.IsCompatibleType(sourceType: &Type;  targetType: &Type): Boolean;
  +begin
  +  if  ((sourceType = nil)  or  (sourceType = typeOf(Undefined)))  then
  +    exit  (not sourceType.IsValueType);
  +
  +  if  (targetType.IsAssignableFrom(sourceType))  then
       exit  (true);
   
  -  if  (((aInput = typeOf(Double))  or  (aInput = typeOf(Int32))) 
  -                   and  (&Type.GetTypeCode(aTarget)  in  [TypeCode.Byte, TypeCode.Char, TypeCode.DateTime, TypeCode.Decimal,
  +  if  (((sourceType = typeOf(Double))  or  (sourceType = typeOf(Int32)))
  +                   and  (&Type.GetTypeCode(targetType)  in  [ TypeCode.Byte, TypeCode.Char, TypeCode.DateTime, TypeCode.Decimal,
                                          TypeCode.Double, TypeCode.Int16, TypeCode.Int32, TypeCode.Int64, TypeCode.SByte,
  -                                       TypeCode.Single, TypeCode.UInt16, TypeCode.UInt32, TypeCode.UInt64]))  then
  +                                       TypeCode.Single, TypeCode.UInt16, TypeCode.UInt32, TypeCode.UInt64 ]))  then
       exit  (true);
   
  -  if  (aTarget = typeOf(String))  then
  +  if  (targetType = typeOf(String))  then
       exit  (true);
   
     exit  (false);
  
positive.code:     var lParams := lMeth.GetParameters();
      var lParamStart := -1;
  
      if  (lParams.Length <> length(aArgs))  then  begin
        if  (not ((lParams.Length > 0)  and  (length(lParams[lParams.Length-1].GetCustomAttributes(typeOf(ParamArrayAttribute), false)) > 0)
                     and  (aArgs.Length >= lParams.Length-1)))  then  begin
          lMethods.RemoveAt(i);
  
          continue;
  
negative.code: end;
  
  
  class method EcmaScriptObjectWrapper.FindAndCallBestOverload(methods: array of MethodBase;  root: GlobalObject;  methodName: String;
                     &self: Object;  parameters: array of Object): Object;
  begin
    var lMethods := new List<MethodBase>(methods);
  
    for  i: Int32  :=  0  to  length(parameters)-1  do  begin
      if  (parameters[i] is EcmaScriptObjectWrapper)  then
        parameters[i] := EcmaScriptObjectWrapper(parameters[i]).Value; // if these were wrapped before, we should unwrap
    end;
  
    for  i: Int32  :=  lMethods.Count-1  downto  0  do  begin
  