<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,26 +25,26 @@ namespace IronRuby.StandardLibrary.Yaml {
             IronRuby.Builtins.RubyClass classRef1 = GetClass(typeof(IronRuby.Builtins.RubyObject));
             
             
-            ExtendModule(typeof(IronRuby.Builtins.FalseClass), LoadIronRuby__Builtins__FalseClass_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendClass(typeof(IronRuby.Builtins.Hash), null, LoadIronRuby__Builtins__Hash_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.Integer), LoadIronRuby__Builtins__Integer_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.MutableString), LoadIronRuby__Builtins__MutableString_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.Range), LoadIronRuby__Builtins__Range_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.RubyArray), LoadIronRuby__Builtins__RubyArray_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendClass(typeof(IronRuby.Builtins.RubyClass), null, LoadIronRuby__Builtins__RubyClass_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendClass(typeof(IronRuby.Builtins.RubyModule), null, LoadIronRuby__Builtins__RubyModule_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.RubyRegex), LoadIronRuby__Builtins__RubyRegex_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.RubyStruct), LoadIronRuby__Builtins__RubyStruct_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.TrueClass), LoadIronRuby__Builtins__TrueClass_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendClass(typeof(IronRuby.StandardLibrary.Yaml.Node), null, LoadIronRuby__StandardLibrary__Yaml__Node_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(Microsoft.Scripting.Math.BigInteger), LoadMicrosoft__Scripting__Math__BigInteger_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(Microsoft.Scripting.Runtime.DynamicNull), LoadMicrosoft__Scripting__Runtime__DynamicNull_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(Microsoft.Scripting.SymbolId), LoadMicrosoft__Scripting__SymbolId_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.FalseClass), 0x00000000, LoadIronRuby__Builtins__FalseClass_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendClass(typeof(IronRuby.Builtins.Hash), 0x00000000, null, LoadIronRuby__Builtins__Hash_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.Integer), 0x00000000, LoadIronRuby__Builtins__Integer_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.MutableString), 0x00000000, LoadIronRuby__Builtins__MutableString_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.Range), 0x00000000, LoadIronRuby__Builtins__Range_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.RubyArray), 0x00000000, LoadIronRuby__Builtins__RubyArray_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendClass(typeof(IronRuby.Builtins.RubyClass), 0x00000000, null, LoadIronRuby__Builtins__RubyClass_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendClass(typeof(IronRuby.Builtins.RubyModule), 0x00000000, null, LoadIronRuby__Builtins__RubyModule_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.RubyRegex), 0x00000000, LoadIronRuby__Builtins__RubyRegex_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.RubyStruct), 0x00000000, LoadIronRuby__Builtins__RubyStruct_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.TrueClass), 0x00000000, LoadIronRuby__Builtins__TrueClass_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendClass(typeof(IronRuby.StandardLibrary.Yaml.Node), 0x00000000, null, LoadIronRuby__StandardLibrary__Yaml__Node_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(Microsoft.Scripting.Math.BigInteger), 0x00000000, LoadMicrosoft__Scripting__Math__BigInteger_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(Microsoft.Scripting.Runtime.DynamicNull), 0x00000000, LoadMicrosoft__Scripting__Runtime__DynamicNull_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(Microsoft.Scripting.SymbolId), 0x00000000, LoadMicrosoft__Scripting__SymbolId_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
             DefineGlobalClass(&quot;Out&quot;, typeof(IronRuby.StandardLibrary.Yaml.RubyRepresenter), 0x00000100, classRef0, LoadOut_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(System.DateTime), LoadSystem__DateTime_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(System.Double), LoadSystem__Double_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(System.Exception), LoadSystem__Exception_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendClass(typeof(System.Object), null, LoadSystem__Object_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(System.DateTime), 0x00000000, LoadSystem__DateTime_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(System.Double), 0x00000000, LoadSystem__Double_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(System.Exception), 0x00000000, LoadSystem__Exception_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendClass(typeof(System.Object), 0x00000000, null, LoadSystem__Object_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
             IronRuby.Builtins.RubyModule def1 = DefineGlobalModule(&quot;YAML&quot;, typeof(IronRuby.StandardLibrary.Yaml.RubyYaml), 0x00000100, null, LoadYAML_Class, null, IronRuby.Builtins.RubyModule.EmptyArray);
             IronRuby.Builtins.RubyModule def2 = DefineModule(&quot;YAML::BaseNode&quot;, typeof(IronRuby.StandardLibrary.Yaml.RubyYaml.BaseNode), 0x00000100, null, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
             IronRuby.Builtins.RubyClass def3 = DefineClass(&quot;YAML::Stream&quot;, typeof(IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream), 0x00000100, classRef1, LoadYAML__Stream_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray, </diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Initializer.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -229,7 +229,8 @@ namespace IronRuby.StandardLibrary.Yaml {
                         throw new ConstructorException(&quot;Unknown regular expression option: '&quot; + c + &quot;'&quot;);
                 }
             }            
-            return new RubyRegex(match.Groups[&quot;expr&quot;].Value, options);            
+            // TODO: encoding (ignore kcode on 1.9, string enc?):
+            return new RubyRegex(MutableString.CreateMutable(match.Groups[&quot;expr&quot;].Value, RubyEncoding.UTF8), options);            
         }
 
         private static object ConstructPrivateObject(RubyConstructor/*!*/ ctor, string className, Node node) {</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/RubyConstructor.cs</filename>
    </modified>
    <modified>
      <diff>@@ -321,12 +321,11 @@ namespace IronRuby.StandardLibrary.Yaml {
                 throw RubyExceptions.NoBlockGiven();
             }
 
-            MutableString pattern = typeRegex.GetPattern();
-            MutableString tag = MutableString.CreateMutable(pattern.Encoding).
+            MutableString tag = MutableString.CreateMutable(typeRegex.Encoding).
                 Append(&quot;tag:&quot;).
                 Append(domainAndDate).
                 Append(':').
-                Append(pattern);
+                Append(typeRegex.Pattern);
 
             RubyConstructor.AddExternalMultiConstructor(tag.ConvertToString(), block);
             return null;</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/RubyYaml.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1 @@
-fails:String#rindex with Regexp behaves the same as String#rindex(string) for escaped string regexps
-fails:String#rindex with Regexp returns the index of the first match from the end of string of regexp
-fails:String#rindex with Regexp starts the search at the given offset
 fails:String#rindex with Regexp supports \G which matches at the given start offset</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/ironruby-tags/core/string/rindex_tags.txt</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1 @@
-fails:The defined? keyword returns 'super' when Subclass#no_args uses defined?
-fails:The defined? keyword returns 'super' when Subclass#args uses defined?
 fails:The defined? keyword returns 'local-variable(in-block)' when defined? is called on a block var</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/ironruby-tags/language/defined_tags.txt</filename>
    </modified>
    <modified>
      <diff>@@ -2,5 +2,30 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe &quot;Kernel#inspect&quot; do
+  it &quot;displays class name&quot; do
+    KernelSpecs::IVars.new.inspect.include?(&quot;KernelSpecs::IVars&quot;).should == true
+  end
+
+  it &quot;displays instance variables when called on an instance of a user class or Object&quot; do
+    KernelSpecs::IVars.new.inspect.include?(&quot;@secret=99&quot;).should == true
+    
+    obj = Object.new
+    obj.instance_variable_set(:@foo, 1)
+    obj.inspect.include?(&quot;@foo=1&quot;).should == true
+  end
+
+  it &quot;does not display instance variables when called on an instance of a builtin class&quot; do
+    [1, 1.2, true, nil, 1..2, &quot;&quot;, 1**200, binding, Proc.new {}, Class.new, Module.new, Time.new, 
+     Struct.new(:f), $stdin, [], {}].each do |obj|
+     
+      obj.instance_variable_set(:@bar, 1)
+      begin
+        obj.inspect.include?(&quot;@secret=99&quot;).should == false
+      rescue
+        obj.instance_variable_remove(:@bar)      
+      end
+    end
+  end
+
   it &quot;needs to be reviewed for spec completeness&quot;
 end</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/core/kernel/inspect_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -70,6 +70,7 @@ namespace Microsoft.Scripting.Debugging {
         private static readonly MSAst.ParameterExpression _caughtException = Ast.Variable(typeof(Exception), &quot;$caughtException&quot;);
         private static readonly MSAst.ParameterExpression _retValAsObject = Ast.Variable(typeof(object), &quot;$retVal&quot;);
         private static readonly MSAst.ParameterExpression _retValFromGeneratorLoop = Ast.Variable(typeof(object), &quot;$retValFromGen&quot;);
+        private static readonly MSAst.ParameterExpression _frameExitException = Expression.Parameter(typeof(bool), &quot;$frameExitException&quot;);
 
         internal DebuggableLambdaBuilder(DebugContext debugContext, DebugLambdaInfo lambdaInfo) {
             _debugContext = debugContext;
@@ -115,7 +116,7 @@ namespace Microsoft.Scripting.Debugging {
         private MSAst.LambdaExpression TransformLambda(MSAst.LambdaExpression lambda) {
             MSAst.Expression body = lambda.Body;
 
-            _lambdaVars.AddRange(new[] { _thread, _framePushed, _caughtException, _funcInfo, _traceLocations, _debugMarker });
+            _lambdaVars.AddRange(new[] { _thread, _framePushed, _caughtException, _funcInfo, _traceLocations, _debugMarker, _frameExitException });
 
             _generatorParams.Add(_frame);
             _generatorVars.Add(_caughtException);
@@ -490,10 +491,28 @@ namespace Microsoft.Scripting.Debugging {
                 typeof(RuntimeOps).GetMethod(&quot;OnFrameEnterTraceEvent&quot;),
                 _thread
             ));
+            
+            var frameExit = AstUtils.If(
+                Ast.Equal(
+                    _debugMarkerLocationMap.Length &gt; 0 ?
+                        Ast.Property(_sourceFilesMap[_debugMarkerLocationMap[0].SourceFile], &quot;Mode&quot;) :
+                        _globalDebugMode,
+                    AstUtils.Constant((int)DebugMode.FullyEnabled)
+                ),
+                Ast.Call(
+                    typeof(RuntimeOps).GetMethod(&quot;OnFrameExitTraceEvent&quot;),
+                    _thread,
+                    _debugMarker,
+                    _retVal != null ? (MSAst.Expression)Ast.Convert(_retVal, typeof(object)) : Ast.Constant(null)
+                )
+            );
 
-
+            // normal exit
             tryExpressions.Add(
-                _retVal != null ? Ast.Assign(_retVal, debuggableBody) : debuggableBody
+                Ast.Block(
+                    _retVal != null ? Ast.Assign(_retVal, debuggableBody) : debuggableBody, 
+                    Ast.Assign(_frameExitException, Expression.Constant(true)),
+                    frameExit) 
             );
 
             tryExpressions.Add(
@@ -501,32 +520,15 @@ namespace Microsoft.Scripting.Debugging {
             );
 
             MSAst.Expression[] popFrame = new MSAst.Expression[] {
-                AstUtils.Try(
-                    AstUtils.If(
-                        Ast.Equal(
-                            _debugMarkerLocationMap.Length &gt; 0 ? 
-                                Ast.Property(_sourceFilesMap[_debugMarkerLocationMap[0].SourceFile], &quot;Mode&quot;) :
-                                _globalDebugMode,
-                            AstUtils.Constant((int)DebugMode.FullyEnabled)
-                        ),
-                        Ast.Call(
-                            typeof(RuntimeOps).GetMethod(&quot;OnFrameExitTraceEvent&quot;),
-                            _thread,
-                            _debugMarker,
-                            _retVal != null ? (MSAst.Expression)Ast.Convert(_retVal, typeof(object)) : Ast.Constant(null)
-                        )
-                    )
-                ).Finally(
-                    AstUtils.If(
-                        // Fire thead-exit event if PopFrame returns true
-                        Ast.AndAlso(
-                            Ast.Equal(Ast.Call(typeof(RuntimeOps).GetMethod(&quot;PopFrame&quot;), _thread), Ast.Constant(true)),
-                            Ast.Equal(_globalDebugMode, AstUtils.Constant((int)DebugMode.FullyEnabled))
-                        ),
-                        Ast.Call(
-                            typeof(RuntimeOps).GetMethod(&quot;OnThreadExitEvent&quot;),
-                            _thread
-                        )
+                AstUtils.If(
+                    // Fire thead-exit event if PopFrame returns true
+                    Ast.AndAlso(
+                        Ast.Equal(Ast.Call(typeof(RuntimeOps).GetMethod(&quot;PopFrame&quot;), _thread), Ast.Constant(true)),
+                        Ast.Equal(_globalDebugMode, AstUtils.Constant((int)DebugMode.FullyEnabled))
+                    ),
+                    Ast.Call(
+                        typeof(RuntimeOps).GetMethod(&quot;OnThreadExitEvent&quot;),
+                        _thread
                     )
                 )
             };
@@ -551,27 +553,31 @@ namespace Microsoft.Scripting.Debugging {
                     Ast.Catch(
                         _caughtException, 
                         Ast.Block(
-                            // Let ForceToGeneratorLoopException exceptions bubble up to the next catch
-                            AstUtils.If(
-                                Ast.TypeIs(
-                                    _caughtException,
-                                    typeof(ForceToGeneratorLoopException)
-                                ),
-                                Ast.Throw(_caughtException)
-                            ),
-
                             // The expressions below will always throw.
                             // If the exception needs to be cancelled then OnTraceEvent will throw ForceToGeneratorLoopException.
                             // If the exception is not being cancelled then we'll just rethrow at the end of the catch block.
                             AstUtils.If(
-                                Ast.NotEqual(_globalDebugMode, AstUtils.Constant((int)DebugMode.Disabled)),
-                                _noPushFrameOptimization ? Ast.Empty() : _conditionalPushFrame,
-                                Ast.Call(
-                                    typeof(RuntimeOps).GetMethod(&quot;OnTraceEventUnwind&quot;),
-                                    _thread,
-                                    _debugMarker,
-                                    _caughtException
-                                )
+                                Ast.Not(
+                                    Ast.TypeIs(
+                                        _caughtException,
+                                        typeof(ForceToGeneratorLoopException)
+                                    )
+                                ),
+                                AstUtils.If(
+                                    Ast.NotEqual(_globalDebugMode, AstUtils.Constant((int)DebugMode.Disabled)),
+                                    _noPushFrameOptimization ? Ast.Empty() : _conditionalPushFrame,
+                                    Ast.Call(
+                                        typeof(RuntimeOps).GetMethod(&quot;OnTraceEventUnwind&quot;),
+                                        _thread,
+                                        _debugMarker,
+                                        _caughtException
+                                    )
+                                ),
+                                // exception exit
+                                AstUtils.If(
+                                    Expression.Not(_frameExitException),
+                                    frameExit
+                                )                                
                             ),
 
                             Ast.Rethrow(),</diff>
      <filename>Merlin/Main/Debugging/Microsoft.Scripting.Debugging/DebuggableLambdaBuilder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -991,7 +991,7 @@ namespace IronPython.Compiler {
             return ret;
         }
 
-        public string SetPrivatePrefix(string name) {
+        private string SetPrivatePrefix(string name) {
             string oldPrefix = _privatePrefix;
 
             _privatePrefix = GetPrivatePrefix(name);</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Compiler/Parser.cs</filename>
    </modified>
    <modified>
      <diff>@@ -115,8 +115,10 @@ namespace IronPython.Compiler.Ast {
             }
 
             ConstantInfo ci;
-            if (!_allConstants.TryGetValue(value, out ci)) {
-                _allConstants[value] = _constants[value] = ci = NextConstant(_constants.Count, CompilerHelpers.GetType(value));
+            lock (_allConstants) {
+                if (!_allConstants.TryGetValue(value, out ci)) {
+                    _allConstants[value] = _constants[value] = ci = NextConstant(_constants.Count, CompilerHelpers.GetType(value));
+                }
             }
 
             return ci.Expression;</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Compiler/SharedGlobalAllocator.cs</filename>
    </modified>
    <modified>
      <diff>@@ -753,9 +753,7 @@ namespace IronPython.Runtime.Binding {
                 }
 
                 public bool Target(CodeContext context, object self, out object result) {
-                    throw PythonOps.AttributeErrorForMissingAttribute(
-                        DynamicHelpers.GetPythonType(self).Name,
-                        _name);
+                    throw PythonOps.AttributeErrorForObjectMissingAttribute(self, _name);
                 }
             }
         }</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/MetaPythonType.Members.cs</filename>
    </modified>
    <modified>
      <diff>@@ -126,6 +126,7 @@ namespace IronPython.Runtime.Binding {
                     switch (Name) {
                         case &quot;__str__&quot;:
                         case &quot;__repr__&quot;:
+                        case &quot;__doc__&quot;:
                             // need to return the built in method descriptor for these...
                             break;
                         case &quot;__file__&quot;:
@@ -181,7 +182,7 @@ namespace IronPython.Runtime.Binding {
 
             public object GetError(CallSite site, TSelfType target, CodeContext context) {
                 if (target != null &amp;&amp; target.GetType() == _type) {
-                    throw PythonOps.AttributeErrorForMissingAttribute(DynamicHelpers.GetPythonType(target).Name, _name);
+                    throw PythonOps.AttributeErrorForObjectMissingAttribute(target, _name);
                 }
 
                 return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/PythonGetMemberBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -2422,14 +2422,31 @@ namespace IronPython.Runtime.Binding {
         /// &lt;/summary&gt;
         public static DynamicMetaObject/*!*/ TypeError(DynamicMetaObjectBinder/*!*/ action, string message, params DynamicMetaObject[] types) {
             if (action is IPythonSite) {
+                Expression[] formatArgs;
+                Type[] typeArgs;
+
                 // produce our custom errors for Python...
-                Expression[] formatArgs = new Expression[types.Length + 1];
-                for (int i = 1; i &lt; formatArgs.Length; i++) {
-                    formatArgs[i] = AstUtils.Constant(MetaPythonObject.GetPythonType(types[i - 1]).Name);
+                if (types.Length &lt;= 3) {
+                    // String.Format only has overloads for up to 3 objects following the format string
+                    formatArgs = new Expression[types.Length + 1];
+                    for (int i = 1; i &lt; formatArgs.Length; i++) {
+                        formatArgs[i] = AstUtils.Constant(MetaPythonObject.GetPythonType(types[i - 1]).Name);
+                    }
+                    formatArgs[0] = AstUtils.Constant(message);
+                    typeArgs = CompilerHelpers.MakeRepeatedArray&lt;Type&gt;(typeof(object), types.Length + 1);
+                    typeArgs[0] = typeof(string);
+                } else {
+                    // Use the params overload for String.Format
+                    formatArgs = new Expression[types.Length];
+                    for (int i = 0; i &lt; formatArgs.Length; i++) {
+                        formatArgs[i] = AstUtils.Constant(MetaPythonObject.GetPythonType(types[i]).Name);
+                    }
+                    formatArgs = new Expression[] {
+                        AstUtils.Constant(message),
+                        Expression.NewArrayInit(typeof(object), formatArgs)
+                    };
+                    typeArgs = new Type[] { typeof(string), typeof(object[]) };
                 }
-                formatArgs[0] = AstUtils.Constant(message);
-                Type[] typeArgs = CompilerHelpers.MakeRepeatedArray&lt;Type&gt;(typeof(object), types.Length + 1);
-                typeArgs[0] = typeof(string);
 
                 Expression error = Ast.Throw(
                     Ast.Call(</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/PythonProtocol.Operations.cs</filename>
    </modified>
    <modified>
      <diff>@@ -102,7 +102,7 @@ namespace IronPython.Runtime.Operations {
                     if (self is OldInstance) {
                         if (((OldInstance)self)._class.TryLookupSlot(s, out attrVal)) {
                             attrSlot = attrVal as PythonTypeSlot;
-                        } else {
+                        } else if (!((OldInstance)self).Dictionary.TryGetValue(s, out attrVal)) {
                             attrVal = ObjectOps.__getattribute__(DefaultContext.DefaultCLS, self, s);
                         }
                     } else {</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/CustomTypeDescHelpers.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1010,7 +1010,7 @@ namespace IronPython.Runtime.Operations {
                 return value;
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(PythonTypeOps.GetName(o), name);
+            throw PythonOps.AttributeErrorForObjectMissingAttribute(o, name);
         }
 
         internal static IList&lt;string&gt; GetStringMemberList(IPythonMembersList pyMemList) {
@@ -4072,10 +4072,28 @@ namespace IronPython.Runtime.Operations {
             return PythonOps.TypeError(&quot;exceptions must be classes or instances, not {0}&quot;, PythonTypeOps.GetName(type));
         }
 
+        public static Exception AttributeErrorForObjectMissingAttribute(object obj, string attributeName) {
+            if (obj is OldInstance) {
+                return AttributeErrorForOldInstanceMissingAttribute(((OldInstance)obj)._class.Name, attributeName);
+            } else if (obj is OldClass) {
+                return AttributeErrorForOldClassMissingAttribute(((OldClass)obj).Name, attributeName);
+            } else {
+                return AttributeErrorForMissingAttribute(PythonTypeOps.GetName(obj), attributeName);
+            }
+        }
+
         public static Exception AttributeErrorForMissingAttribute(string typeName, string attributeName) {
             return PythonOps.AttributeError(&quot;'{0}' object has no attribute '{1}'&quot;, typeName, attributeName);
         }
 
+        public static Exception AttributeErrorForOldInstanceMissingAttribute(string typeName, string attributeName) {
+            return PythonOps.AttributeError(&quot;{0} instance has no attribute '{1}'&quot;, typeName, attributeName);
+        }
+
+        public static Exception AttributeErrorForOldClassMissingAttribute(string typeName, string attributeName) {
+            return PythonOps.AttributeError(&quot;class {0} has no attribute '{1}'&quot;, typeName, attributeName);
+        }
+
         public static Exception UncallableError(object func) {
             return PythonOps.TypeError(&quot;{0} is not callable&quot;, PythonTypeOps.GetName(func));
         }</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/PythonOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -210,7 +210,7 @@ namespace IronPython.Runtime.Types {
                 return PythonOps.CallWithContext(context, value);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__len__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__len__&quot;);
         }
 
         public object __pos__(CodeContext context) {
@@ -220,7 +220,7 @@ namespace IronPython.Runtime.Types {
                 return PythonOps.CallWithContext(context, value);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__pos__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__pos__&quot;);
         }
 
         [SpecialName]
@@ -241,7 +241,7 @@ namespace IronPython.Runtime.Types {
                 return PythonCalls.Call(context, value, item);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__delitem__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__delitem__&quot;);
         }
 
         public object __getslice__(CodeContext context, int i, int j) {
@@ -296,7 +296,7 @@ namespace IronPython.Runtime.Types {
                 return PythonOps.CallWithContext(context, value);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__neg__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__neg__&quot;);
         }
 
         public object __abs__(CodeContext context) {
@@ -306,7 +306,7 @@ namespace IronPython.Runtime.Types {
                 return PythonOps.CallWithContext(context, value);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__abs__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__abs__&quot;);
         }
 
         public object __invert__(CodeContext context) {
@@ -316,7 +316,7 @@ namespace IronPython.Runtime.Types {
                 return PythonOps.CallWithContext(context, value);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__invert__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__invert__&quot;);
         }
 
         public object __contains__(CodeContext context, object index) {
@@ -412,7 +412,7 @@ namespace IronPython.Runtime.Types {
                 return PythonOps.CallWithContext(context, value);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__hex__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__hex__&quot;);
         }
 
         public object __oct__(CodeContext context) {
@@ -421,7 +421,7 @@ namespace IronPython.Runtime.Types {
                 return PythonOps.CallWithContext(context, value);
             }
 
-            throw PythonOps.AttributeErrorForMissingAttribute(_class.Name, &quot;__oct__&quot;);
+            throw PythonOps.AttributeErrorForOldInstanceMissingAttribute(_class.Name, &quot;__oct__&quot;);
         }
 
         public object __int__(CodeContext context) {</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/OldInstance.cs</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,7 @@ namespace IronPython.Runtime.Types {
         private readonly PythonOperationKind _operator;
         private readonly string _name;
         private readonly string _altName;
+        private readonly Type _altExpectedType;
 
         private OperatorMapping(PythonOperationKind op, string name, string altName) {
             _operator = op;
@@ -20,6 +21,13 @@ namespace IronPython.Runtime.Types {
             _altName = altName;
         }
 
+        private OperatorMapping(PythonOperationKind op, string name, string altName, Type alternateExpectedType) {
+            _operator = op;
+            _name = name;
+            _altName = altName;
+            _altExpectedType = alternateExpectedType;
+        }
+
         /// &lt;summary&gt;
         /// Given an operator returns the OperatorMapping associated with the operator or null
         /// &lt;/summary&gt;
@@ -62,6 +70,18 @@ namespace IronPython.Runtime.Types {
             get { return _altName; }
         }
 
+        /// &lt;summary&gt;
+        /// The return type that must match for the alternate operator to be valid.
+        /// 
+        /// This is available alternate operators don't have special names and therefore
+        /// could be confused for a normal method which isn't fulfilling the contract.
+        /// &lt;/summary&gt;
+        public Type AlternateExpectedType {
+            get {
+                return _altExpectedType;
+            }
+        }
+
         private static OperatorMapping[] MakeOperatorTable() {
             List&lt;OperatorMapping&gt; res = new List&lt;OperatorMapping&gt;();
 
@@ -111,7 +131,7 @@ namespace IronPython.Runtime.Types {
             res.Add(new OperatorMapping(PythonOperationKind.DeleteItem, &quot;del_Item&quot;, &quot;DeleteItem&quot;));        // not defined
 
             // DLR Extended operators:
-            res.Add(new OperatorMapping(PythonOperationKind.Compare, &quot;op_Compare&quot;, &quot;Compare&quot;));        // not defined
+            res.Add(new OperatorMapping(PythonOperationKind.Compare, &quot;op_Compare&quot;, &quot;Compare&quot;, typeof(int)));        // not defined
 
             res.Add(new OperatorMapping(PythonOperationKind.CallSignatures, &quot;GetCallSignatures&quot;, null));
             res.Add(new OperatorMapping(PythonOperationKind.Documentation, &quot;GetDocumentation&quot;, null));</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/OperatorMapping.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,13 +25,13 @@ namespace IronPython.Runtime.Types {
     public class PythonTypeDataSlot : PythonTypeSlot {
         public virtual void __set__(CodeContext/*!*/ context, object instance, object value) {
             if (!TrySetValue(context, instance, DynamicHelpers.GetPythonType(instance), value)) {
-                throw PythonOps.AttributeErrorForMissingAttribute(DynamicHelpers.GetPythonType(instance).Name, &quot;__set__&quot;);
+                throw PythonOps.AttributeErrorForObjectMissingAttribute(instance, &quot;__set__&quot;);
             }
         }
 
         public virtual void __delete__(CodeContext/*!*/ context, object instance) {
             if (!TryDeleteValue(context, instance, DynamicHelpers.GetPythonType(instance))) {
-                throw PythonOps.AttributeErrorForMissingAttribute(DynamicHelpers.GetPythonType(instance).Name, &quot;__delete__&quot;);
+                throw PythonOps.AttributeErrorForObjectMissingAttribute(instance, &quot;__delete__&quot;);
             }
         }
 </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/PythonTypeDataSlot.cs</filename>
    </modified>
    <modified>
      <diff>@@ -85,7 +85,7 @@ namespace IronPython.Runtime.Types {
 
         public void __delete__(CodeContext/*!*/ context, object instance) {
             if (!TryDeleteValue(context, instance, DynamicHelpers.GetPythonType(instance))) {
-                throw PythonOps.AttributeErrorForMissingAttribute(DynamicHelpers.GetPythonType(instance).Name, &quot;__delete__&quot;);
+                throw PythonOps.AttributeErrorForObjectMissingAttribute(instance, &quot;__delete__&quot;);
             }
         }
 </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/ReflectedExtensionProperty.cs</filename>
    </modified>
    <modified>
      <diff>@@ -307,6 +307,8 @@ namespace IronPython.Runtime.Types {
                                         // doesn't define it on object we need to filter it out.  
                                         res = FilterObjectEquality(res);
                                     }
+
+                                    res = FilterAlternateMethods(opInfo, res);
                                 }
 
                                 if (res.Count &gt; 0) {
@@ -328,6 +330,30 @@ namespace IronPython.Runtime.Types {
             }
 
             /// &lt;summary&gt;
+            /// Filters alternative methods out that don't match the expected signature and therefore
+            /// are just sharing a common method name.
+            /// &lt;/summary&gt;
+            private static MemberGroup FilterAlternateMethods(OperatorMapping opInfo, MemberGroup res) {
+                if (res.Count &gt; 0 &amp;&amp; opInfo.AlternateExpectedType != null) {
+                    List&lt;MemberTracker&gt; matchingMethods = new List&lt;MemberTracker&gt;();
+                    for (int i = 0; i &lt; res.Count; i++) {
+                        MemberTracker mt = res[i];
+                        if (mt.MemberType == TrackerTypes.Method &amp;&amp;
+                            ((MethodTracker)mt).Method.ReturnType == opInfo.AlternateExpectedType) {
+                            matchingMethods.Add(mt);
+                        }
+                    }
+
+                    if (matchingMethods.Count == 0) {
+                        res = MemberGroup.EmptyGroup;
+                    } else {
+                        res = new MemberGroup(matchingMethods.ToArray());
+                    }
+                }
+                return res;
+            }
+
+            /// &lt;summary&gt;
             /// Removes Object.Equals methods as we never return these for PythonOperationKind.
             /// &lt;/summary&gt;
             private static MemberGroup/*!*/ FilterObjectEquality(MemberGroup/*!*/ group) {
@@ -526,6 +552,10 @@ namespace IronPython.Runtime.Types {
                 // The operator resolver maps standard .NET operator methods into Python operator
                 // methods
                 new OperatorResolver(),
+
+                // Runs after operator resolver to map default members to __getitem__/__setitem__
+                new OneOffResolver(&quot;__getitem__&quot;, GetItemResolver),
+                new OneOffResolver(&quot;__setitem__&quot;, SetItemResolver),
                 
                 // Runs after operator resolver to map __ne__ -&gt; !__eq__
                 new OneOffResolver(&quot;__ne__&quot;, FallbackInequalityResolver),
@@ -602,6 +632,32 @@ namespace IronPython.Runtime.Types {
         }
         private static Func&lt;MemberBinder/*!*/, Type/*!*/, MemberGroup/*!*/&gt; _BigIntegerResolver;
 
+        /// &lt;summary&gt;
+        /// Provides a resolution for __getitem__
+        /// &lt;/summary&gt;
+        private static Func&lt;MemberBinder/*!*/, Type/*!*/, MemberGroup/*!*/&gt;/*!*/ GetItemResolver {
+            get {
+                if (_GetItemResolver == null) {
+                    _GetItemResolver = MakeIndexerResolver(false);
+                }
+                return _GetItemResolver;
+            }
+        }
+        private static Func&lt;MemberBinder/*!*/, Type/*!*/, MemberGroup/*!*/&gt; _GetItemResolver;
+
+        /// &lt;summary&gt;
+        /// Provides a resolution for __setitem__
+        /// &lt;/summary&gt;
+        private static Func&lt;MemberBinder/*!*/, Type/*!*/, MemberGroup/*!*/&gt;/*!*/ SetItemResolver {
+            get {
+                if (_SetItemResolver == null) {
+                    _SetItemResolver = MakeIndexerResolver(true);
+                }
+                return _SetItemResolver;
+            }
+        }
+        private static Func&lt;MemberBinder/*!*/, Type/*!*/, MemberGroup/*!*/&gt; _SetItemResolver;
+
         #endregion
 
         /// &lt;summary&gt;
@@ -1515,6 +1571,38 @@ namespace IronPython.Runtime.Types {
         }
 
         /// &lt;summary&gt;
+        /// Helper for creating __getitem__/__setitem__ resolvers
+        /// &lt;/summary&gt;
+        /// &lt;param name=&quot;set&quot;&gt;false for a getter, true for a setter&lt;/param&gt;
+        private static Func&lt;MemberBinder/*!*/, Type/*!*/, MemberGroup/*!*/&gt;/*!*/ MakeIndexerResolver(bool set) {
+            return delegate(MemberBinder/*!*/ binder, Type/*!*/ type) {
+                List&lt;MemberInfo&gt; members = null;
+
+                foreach (MemberInfo member in type.GetDefaultMembers()) {
+                    PropertyInfo property = member as PropertyInfo;
+                    if (property != null) {
+                        MethodInfo accessor;
+                        if (!set) {
+                            accessor = property.GetGetMethod();
+                        } else {
+                            accessor = property.GetSetMethod();
+                        }
+                        if (accessor != null) {
+                            members = members ?? new List&lt;MemberInfo&gt;();
+                            members.Add(accessor);
+                        }
+                    }
+                }
+
+                if (members == null) {
+                    return MemberGroup.EmptyGroup;
+                } else {
+                    return new MemberGroup(members.ToArray());
+                }
+            };
+        }
+
+        /// &lt;summary&gt;
         /// Filters out methods which are present on standard .NET types but shouldn't be there in Python
         /// &lt;/summary&gt;
         internal static bool IncludeOperatorMethod(Type/*!*/ t, PythonOperationKind op) {</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/TypeInfo.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1199,4 +1199,10 @@ namespace IronPythonTest {
             return DynamicHelpers.GetPythonTypeFromType(typeof(T));
         }
     }
+
+    public class WithCompare {
+        public static bool Compare(object x, object y) {
+            return true;
+        }
+    }
 }
\ No newline at end of file</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPythonTest/BindTest.cs</filename>
    </modified>
    <modified>
      <diff>@@ -999,8 +999,9 @@ internal class LibraryDef {
 #endif
 
                 if (def.IsExtension) {
-                    _output.Write(&quot;ExtendClass(typeof({0}), {1}, {2}, &quot;,
+                    _output.Write(&quot;ExtendClass(typeof({0}), {1}, {2}, {3}, &quot;,
                         TypeName(def.Extends),
+                        def.GetModuleAttributes(),
                         def.Super != null ? def.Super.RefName : &quot;null&quot;,
                         def.GetInitializerDelegates()
                     );
@@ -1034,7 +1035,11 @@ internal class LibraryDef {
                 }
 
                 if (def.IsExtension) {
-                    _output.Write(&quot;ExtendModule(typeof({0}), {1}, &quot;, TypeName(def.Extends), def.GetInitializerDelegates());
+                    _output.Write(&quot;ExtendModule(typeof({0}), {1}, {2}, &quot;, 
+                        TypeName(def.Extends),
+                        def.GetModuleAttributes(),
+                        def.GetInitializerDelegates()
+                    );
                 } else {
                     _output.Write(&quot;Define{0}Module(\&quot;{1}\&quot;, typeof({2}), {3}, {4}, &quot;,
                         def.IsGlobal ? &quot;Global&quot; : &quot;&quot;,</diff>
      <filename>Merlin/Main/Languages/Ruby/ClassInitGenerator/Libraries/LibraryDef.cs</filename>
    </modified>
    <modified>
      <diff>@@ -433,7 +433,9 @@ namespace IronRuby.Tests {
                 if (!_partialTrust) { 
                     Console.Write(&quot;Repro: {0}&quot;, Environment.CommandLine);
                 } else {
-                    Console.Write(&quot;Repro: IronRuby.Tests.exe /partial&quot;);
+                    Console.Write(&quot;Repro: IronRuby.Tests.exe /partial{0}{1}&quot;, 
+                        _noAdaptiveCompilation ? &quot; /noadaptive&quot; : &quot;&quot;,
+                        _isDebug ? &quot; /debug&quot; : &quot;&quot;);
                 }
                 if (largs.Count == 0) {
                     Console.Write(&quot; {0}&quot;, String.Join(&quot; &quot;, failedCases.ToArray()));</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Driver.cs</filename>
    </modified>
    <modified>
      <diff>@@ -24,8 +24,24 @@ namespace IronRuby.Tests {
             _methods = new Action[] {
                 Scenario_Startup, // must be the first test
                 
-                MutableString1,
-                MutableString2,
+                MutableString_Factories,
+                MutableString_GetHashCode,
+                MutableString_IsAscii,
+                MutableString_Length,
+                MutableString_Append_Byte,
+                MutableString_Append_Char,
+                MutableString_Insert_Byte,
+                MutableString_Insert_Char,
+                MutableString_Remove_Byte,
+                MutableString_Remove_Char,
+                MutableString_SwitchRepr,
+                MutableString_Concatenate,
+                MutableString_Reverse,
+                MutableString_Translate1,
+                MutableString_IndexOf1,
+                MutableString_LastIndexOf1,
+                MutableString_Index1,
+                MutableString_IndexRegex1,
                 RubyArray_Ctors,
                 RubyArray_Basic,
                 RubyArray_Add,
@@ -64,6 +80,7 @@ namespace IronRuby.Tests {
                 Interpreter2,
                 Interpreter3,
                 Interpreter4,
+                Interpreter5,
 
                 Scenario_RubySimpleCall1,
                 Scenario_RubySimpleCall2, 
@@ -123,6 +140,7 @@ namespace IronRuby.Tests {
                 Inspect2,
                 File1,
                 File2,
+                File3,
                 
                 Regex1,
                 Regex2,
@@ -131,6 +149,8 @@ namespace IronRuby.Tests {
                 RegexEscape1,
                 RegexCondition1,
                 RegexCondition2,
+                RegexEncoding1,
+                RegexEncoding2,
                 
                 Scenario_RubyScopeParsing,
                 Scenario_RubyScopes1,
@@ -275,6 +295,7 @@ namespace IronRuby.Tests {
                 Scenario_RubyInitializers4B,
                 Scenario_RubyInitializers4C,
                 Scenario_RubyInitializers5,
+                Scenario_RubyInitializers6,
                 RubyInitializersCaching1,
                 RubyInitializersCaching2,
                 RubyInitializersCaching3,
@@ -404,14 +425,16 @@ namespace IronRuby.Tests {
                 ClrGenericMethods1,
                 ClrOverloadSelection1,
                 ClrOverloadSelection2,
+                ClrNewSlot1,
                 ClrInterfaces1,
-                ClrInterfaces2,
+                ClrExplicitInterfaces1,
                 ClrInclude1,
                 ClrNew1,
                 ClrNew2,
                 ClrAlias1,
                 ClrEnums1, 
                 ClrEnums2, 
+                ClrEnums3, 
                 ClrDelegates1,
                 ClrDelegates2,
                 ClrEvents1,
@@ -549,19 +572,20 @@ namespace IronRuby.Tests {
                 SuperInTopLevelCode1,
                 SuperInAliasedDefinedMethod1,
 
-                Scenario_RubyDefinedOperator_Globals1,
-                Scenario_RubyDefinedOperator_Globals2,
-                Scenario_RubyDefinedOperator_Methods1,
-                Scenario_RubyDefinedOperator_Methods2,
-                Scenario_RubyDefinedOperator_Constants1,
-                Scenario_RubyDefinedOperator_Constants2,
-                Scenario_RubyDefinedOperator_Constants3,
-                Scenario_RubyDefinedOperator_Expressions1,
-                Scenario_RubyDefinedOperator_InstanceVariables1,
-                Scenario_RubyDefinedOperator_ClassVariables1,
-                Scenario_RubyDefinedOperator_ClassVariables2,
-                Scenario_RubyDefinedOperator_Yield1,
-                Scenario_RubyDefinedOperator_Locals1,
+                DefinedOperator_Globals1,
+                DefinedOperator_Globals2,
+                DefinedOperator_Methods1,
+                DefinedOperator_Methods2,
+                DefinedOperator_Constants1,
+                DefinedOperator_Constants2,
+                DefinedOperator_Constants3,
+                DefinedOperator_Expressions1,
+                DefinedOperator_InstanceVariables1,
+                DefinedOperator_ClassVariables1,
+                DefinedOperator_ClassVariables2,
+                DefinedOperator_Yield1,
+                DefinedOperator_Locals1,
+                DefinedOperator_Super1,
 
                 Scenario_ModuleOps_Methods,
                 Scenario_MainSingleton,</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1064,6 +1064,43 @@ puts m.overload(System::Array[Object]).arity
 &quot;);
         }
 
+        public class ClassWithSlot1 {
+            public int Foo() {
+                return 1;
+            }
+
+            public override string ToString() {
+                return &quot;base&quot;;
+            }
+        }
+
+        public class ClassWithNewSlot1 : ClassWithSlot1 {
+            public new string ToString() {
+                return &quot;subclass&quot;;
+            }
+
+            public new int Foo() {
+                return 2;
+            }
+        }
+
+        public void ClrNewSlot1() {
+            Context.ObjectClass.SetConstant(&quot;NewSlot&quot;, Context.GetClass(typeof(ClassWithNewSlot1)));
+            Context.ObjectClass.SetConstant(&quot;Base&quot;, Context.GetClass(typeof(ClassWithSlot1)));
+            TestOutput(@&quot;
+c = NewSlot.new
+p c.to_string
+p c.clr_member(Object, :to_string).call
+p c.foo
+p c.clr_member(Base, :foo).call
+&quot;, @&quot;
+'subclass'
+'base'
+2
+1
+&quot;);
+        }
+
         #endregion
 
         #region Interfaces
@@ -1082,10 +1119,14 @@ puts m.overload(System::Array[Object]).arity
 
         public interface InterfaceFoo2 {
             int Foo();
+            int this[int i] { get; }
+            event Action Evnt;
+            int EvntValue { get; }
         }
 
         public interface InterfaceBar1 {
             int Bar();
+            int Bar(int i);
         }
 
         public interface InterfaceBaz1 {
@@ -1102,19 +1143,31 @@ puts m.overload(System::Array[Object]).arity
         }
 
         internal class InternalClass1 : InterfaceClassBase1, IEnumerable, IComparable, InterfaceBaz1, InterfaceFoo1, InterfaceFoo2, InterfaceBar1 {
+            int _evntValue;
+
             // simple:
-            public int Baz() { return 123; }
+            public int Baz() { return 0; }
 
             // simple explicit:
-            int IComparable.CompareTo(object obj) { return 0; }
+            int IComparable.CompareTo(object obj) { return 1; }
 
             // explicit + implicit
-            public int Bar() { return 0;}
-            int InterfaceBar1.Bar() { return 0; }
+            public int Bar() { return -1; }
+            int InterfaceBar1.Bar() { return 2; }
+            int InterfaceBar1.Bar(int i) { return 3; }
 
             // multiple explicit with the same signature 
-            int InterfaceFoo1.Foo() { return 1; }
-            int InterfaceFoo2.Foo() { return 2; }
+            int InterfaceFoo1.Foo() { return 4; }
+            int InterfaceFoo2.Foo() { return 5; }
+
+            // explicit default indexer:
+            int InterfaceFoo2.this[int i] { get { return 6; } }
+
+            // explicit property:
+            int InterfaceFoo2.EvntValue { get { return _evntValue; } }
+
+            // explicit event:
+            event Action InterfaceFoo2.Evnt { add { _evntValue++; } remove { _evntValue--; } }
         }
 
         public class ClassWithInterfaces2 : ClassWithInterfaces1, IComparable {
@@ -1148,24 +1201,37 @@ puts($obj2 &lt;=&gt; 1)
         /// Calling (explicit) interface methods on internal classes.
         /// A method that is accessible via any interface should be called. 
         /// If there is more than one then regular overload resolution should kick in.
-        /// 
         /// &lt;/summary&gt;
-        public void ClrInterfaces2() {
+        public void ClrExplicitInterfaces1() {
             Context.ObjectClass.SetConstant(&quot;Inst&quot;, new InternalClass1());
             Context.ObjectClass.SetConstant(&quot;InterfaceFoo1&quot;, Context.GetModule(typeof(InterfaceFoo1)));
             Context.ObjectClass.SetConstant(&quot;InterfaceFoo2&quot;, Context.GetModule(typeof(InterfaceFoo2)));
             Context.ObjectClass.SetConstant(&quot;InterfaceBar1&quot;, Context.GetModule(typeof(InterfaceBar1)));
 
-            // TODO: explicit interface impl
             TestOutput(@&quot;
 p Inst.GetEnumerator().nil?
-#p Inst.CompareTo(nil)
-#p Inst.Bar                               
-#p Inst.as(InterfaceFoo1).Foo   # or Inst.interface_method(InterfaceFoo1, :Foo).call ?
-#p Inst.as(InterfaceFoo2).Foo
-#p Inst.as(InterfaceBar1).Bar
+p Inst.baz
+p Inst.clr_member(System::IComparable, :compare_to).call(nil)
+p Inst.clr_member(InterfaceBar1, :bar).call
+p Inst.clr_member(InterfaceBar1, :bar).call(1)
+p Inst.clr_member(InterfaceFoo1, :foo).call
+p Inst.clr_member(InterfaceFoo2, :foo).call
+p Inst.clr_member(InterfaceFoo2, :[]).call(1)
+
+p Inst.clr_member(InterfaceFoo2, :evnt_value).call
+Inst.clr_member(InterfaceFoo2, :evnt).call { }
+p Inst.clr_member(InterfaceFoo2, :evnt_value).call
 &quot;, @&quot;
 false
+0
+1
+2
+3
+4
+5
+6
+0
+1
 &quot;);
         }
 
@@ -1837,7 +1903,7 @@ end
             var range = new Range(1, 2, true);
             Assert(range.ToString() == &quot;1...2&quot;);
 
-            var regex = new RubyRegex(&quot;hello&quot;, RubyRegexOptions.IgnoreCase | RubyRegexOptions.Multiline);
+            var regex = new RubyRegex(MutableString.CreateAscii(&quot;hello&quot;), RubyRegexOptions.IgnoreCase | RubyRegexOptions.Multiline);
             Assert(regex.ToString() == &quot;(?mi-x:hello)&quot;);
         }
 
@@ -2251,7 +2317,7 @@ p System::Char.new('9').to_i
 &quot;, @&quot;
 [System::Char, IronRuby::Clr::String, Enumerable, Comparable, System::ValueType, Object, Kernel]
 [System::String, IronRuby::Clr::String, Enumerable, Comparable, Object, Kernel]
-'a'
+'a' (Char)
 1
 0
 'foo'
@@ -2287,6 +2353,28 @@ Foo
 Bar        
 &quot;);
         }
+        
+        public void ClrEnums2() {
+            Context.ObjectClass.SetConstant(&quot;C&quot;, Context.GetClass(typeof(ClassWithEnum)));
+            Context.ObjectClass.SetConstant(&quot;E&quot;, Context.GetClass(typeof(ClassWithEnum.MyEnum)));
+
+            TestOutput(@&quot;
+class X
+  def to_int
+    E.Baz
+  end
+end
+
+p System::Array[E].new([1, E.Bar])
+
+# TODO: allow default protocol to convert to an enum?
+System::Array[E].new [X.new] rescue puts $!
+
+&quot;, @&quot;
+[Foo, Bar]
+can't convert X into IronRuby::Tests::Tests::ClassWithEnum::MyEnum
+&quot;);
+        }
 
         [Flags]
         public enum FlagsInt { A = 1, B = 2 }
@@ -2297,7 +2385,7 @@ Bar
         [Flags]
         public enum FlagsByte : byte { N = 0, E = 4, F = 8 }
         
-        public void ClrEnums2() {
+        public void ClrEnums3() {
             Context.ObjectClass.SetConstant(&quot;A&quot;, FlagsInt.A);
             Context.ObjectClass.SetConstant(&quot;B&quot;, FlagsInt.B);
             Context.ObjectClass.SetConstant(&quot;C&quot;, FlagsULong.C);</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ClrTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,7 @@
 
 namespace IronRuby.Tests {
     public partial class Tests {
-        public void Scenario_RubyDefinedOperator_Globals1() {
+        public void DefinedOperator_Globals1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 p defined? $+
@@ -31,7 +31,7 @@ nil
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Globals2() {
+        public void DefinedOperator_Globals2() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 alias $foo $bar
@@ -55,7 +55,7 @@ nil
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Methods1() {
+        public void DefinedOperator_Methods1() {
             CompilerTest(@&quot;
 module M
   def foo; end
@@ -81,8 +81,7 @@ C.new.foo_defined?
             AssertEquals(o, 1);
         }
 
-        public void Scenario_RubyDefinedOperator_Methods2() {
-            // TODO: visibility
+        public void DefinedOperator_Methods2() {
             AssertOutput(() =&gt; CompilerTest(@&quot;
 def foo
   puts 'foo'
@@ -92,7 +91,7 @@ end
 puts defined? 1.+
 puts defined? 1.method_that_doesnt_exist
 puts defined? raise.foo
-# TODO: puts defined? foo.foo should return nil (visibility)
+puts defined? foo.foo(puts(1))                  # foo is private
 public :foo
 puts defined? foo.foo
 &quot;), @&quot;
@@ -100,11 +99,13 @@ method
 nil
 nil
 foo
+nil
+foo
 method
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Constants1() {
+        public void DefinedOperator_Constants1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 W = 0
@@ -144,7 +145,7 @@ nil
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Constants2() {
+        public void DefinedOperator_Constants2() {
             TestOutput(@&quot;
 module M
   C = 1
@@ -172,7 +173,7 @@ constant
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Constants3() {
+        public void DefinedOperator_Constants3() {
             TestOutput(@&quot;
 print '1' unless defined? FOO
 print '2' unless defined? FOO
@@ -187,7 +188,7 @@ print '8' if defined? FOO or defined? Object
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Expressions1() {
+        public void DefinedOperator_Expressions1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 puts defined? true
@@ -216,7 +217,7 @@ expression
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_InstanceVariables1() {
+        public void DefinedOperator_InstanceVariables1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 p defined? @x
@@ -232,7 +233,7 @@ nil
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_ClassVariables1() {
+        public void DefinedOperator_ClassVariables1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 module M
@@ -263,7 +264,7 @@ class variable
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_ClassVariables2() {
+        public void DefinedOperator_ClassVariables2() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 @@x = 1
@@ -274,7 +275,7 @@ class variable
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Yield1() {
+        public void DefinedOperator_Yield1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 def foo
@@ -290,7 +291,7 @@ yield
 &quot;);
         }
 
-        public void Scenario_RubyDefinedOperator_Locals1() {
+        public void DefinedOperator_Locals1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
 def bob a
@@ -311,5 +312,35 @@ local-variable
 local-variable
 &quot;);
         }
+
+        public void DefinedOperator_Super1() {
+            AssertOutput(delegate() {
+                CompilerTest(@&quot;
+class C
+  def foo
+    defined?(super(puts(1)))
+  end
+end
+
+class D &lt; C
+  def foo
+    defined?(super(puts(1)))
+  end
+
+  def bar
+    defined?(super(puts(1)))
+  end
+end
+
+puts C.new.foo
+puts D.new.foo
+puts D.new.bar
+&quot;);
+            }, @&quot;
+nil
+super
+nil
+&quot;);
+        }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/DefinedTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -153,11 +153,32 @@ py_add
             Engine.Execute(&quot;def foo; 1; end&quot;);
             Assert(Context.ObjectClass.GetMethod(&quot;foo&quot;) != null);
 
-            // When executed against a scope top-level methods are defined on main singleton and also stored in the scope:
+            // The method is private and shouldn't be invokable via InvokeMember:
+            AssertExceptionThrown&lt;MissingMethodException&gt;(() =&gt; Engine.Operations.InvokeMember(new object(), &quot;foo&quot;));
+
+            // When executed against a scope top-level methods are defined on main singleton and also stored in the scope.
+            // This is equivalent to instance_evaling the code against the main singleton.
             var scope = Engine.CreateScope();
             Engine.Execute(&quot;def bar; 1; end&quot;, scope);
             Assert(Context.ObjectClass.GetMethod(&quot;bar&quot;) == null);
             Assert(scope.GetVariable(&quot;bar&quot;) != null);
+            
+            // we can invoke the method on a scope:
+            Assert((int)Engine.Operations.InvokeMember(scope, &quot;bar&quot;) == 1);
+            
+            // Since we don't define top-level methods on Object when executing against a scope, 
+            // executions against different scopes don&#8217;t step on each other:
+            var scope1 = Engine.CreateScope();
+            var scope2 = Engine.CreateScope();
+            Engine.Execute(&quot;def foo(a,b); a + b; end&quot;, scope1);
+            Engine.Execute(&quot;def foo(a,b); a - b; end&quot;, scope2);
+            Assert(Engine.Execute&lt;int&gt;(&quot;foo(1,2)&quot;, scope1) == 3);
+            Assert(Engine.Execute&lt;int&gt;(&quot;foo(1,2)&quot;, scope2) == -1);
+
+            // Contrary, last one wins when executing w/o scope:
+            Engine.Execute(&quot;def baz(a,b); a + b; end&quot;);
+            Engine.Execute(&quot;def baz(a,b); a - b; end&quot;);
+            Assert(Engine.Execute&lt;int&gt;(&quot;baz(1,2)&quot;) == -1);
         }
 
         public void RubyHosting2() {</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/HostingTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,7 @@
  *
  * ***************************************************************************/
 
+using IronRuby.Runtime;
 namespace IronRuby.Tests {
     public partial class Tests {
 
@@ -176,6 +177,24 @@ C: foo
 &quot;);
         }
 
+        public void Scenario_RubyInitializers6() {
+            TestOutput(@&quot;
+class C
+  undef :initialize rescue p $!
+
+  define_method(:initialize) { |*args| p args }
+  new(1,2,3)
+
+  def initialize; puts 'init'; end
+  new
+end
+&quot;, @&quot;
+#&lt;TypeError: Cannot undefine `initialize' method&gt;
+[1, 2, 3]
+init
+&quot;);
+        }
+
         public void RubyInitializersCaching1() {
             AssertOutput(delegate() {
                 CompilerTest(@&quot;</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/InitializerTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -32,6 +32,7 @@ namespace IronRuby.Tests {
     using AstUtils = Microsoft.Scripting.Ast.Utils;
 
     public partial class Tests {
+        [Options(NoRuntime = true)]
         public void Interpreter1() {
             var m_AddValue = new Action&lt;StrongBox&lt;int&gt;, int&gt;(Interpreter1_AddValue).Method;
             var m_ThrowNSE = new Action(Interpreter1_ThrowNSE).Method;
@@ -197,6 +198,7 @@ namespace IronRuby.Tests {
             return 20;
         }
 
+        [Options(NoRuntime = true)]
         public void Interpreter2() {
             Interpreter2_Test&lt;Func&lt;int&gt;&gt;(
                 (var) =&gt; Ast.Lambda&lt;Func&lt;int&gt;&gt;(var),
@@ -247,6 +249,7 @@ namespace IronRuby.Tests {
         /// &lt;summary&gt;
         /// ThreadAbortException handling.
         /// &lt;/summary&gt;
+        [Options(NoRuntime = true)]
         public void Interpreter3() {
             if (_driver.PartialTrust) return;
 
@@ -407,5 +410,67 @@ namespace IronRuby.Tests {
             Thread.ResetAbort();
             tracker.Add(e.ExceptionState);
         }
+
+        [Options(NoRuntime = true)]
+        public void Interpreter5() {
+            var strArray1 = new string[] { &quot;foo&quot; };
+            var strArray2 = new string[1, 1];
+            var strArray3 = new string[1, 1, 1];
+            var strArray8 = new string[1, 1, 1, 1, 1, 1, 1, 1];
+            strArray2[0, 0] = &quot;foo&quot;;
+            strArray3[0, 0, 0] = &quot;foo&quot;;
+            strArray8[0, 0, 0, 0, 0, 0, 0, 0] = &quot;foo&quot;;
+
+           // T[]::Get
+            Assert(&quot;foo&quot; == Ast.Lambda&lt;Func&lt;string&gt;&gt;(
+                Ast.Call(Ast.Constant(strArray1), typeof(string[]).GetMethod(&quot;Get&quot;), Ast.Constant(0))
+            ).LightCompile()());
+
+            // T[]::Set
+            Ast.Lambda&lt;Action&gt;(
+                Ast.Call(Ast.Constant(strArray1), typeof(string[]).GetMethod(&quot;Set&quot;), Ast.Constant(0), Ast.Constant(&quot;bar&quot;))
+            ).LightCompile()();
+            Assert(strArray1[0] == &quot;bar&quot;);
+
+            // T[,]::Get
+            Assert(&quot;foo&quot; == Ast.Lambda&lt;Func&lt;string&gt;&gt;(
+                Ast.Call(Ast.Constant(strArray2), typeof(string[,]).GetMethod(&quot;Get&quot;), Ast.Constant(0), Ast.Constant(0))
+            ).LightCompile()());
+
+            // T[,]::Set
+            Ast.Lambda&lt;Action&gt;(
+                Ast.Call(Ast.Constant(strArray2), typeof(string[,]).GetMethod(&quot;Set&quot;), Ast.Constant(0), Ast.Constant(0), Ast.Constant(&quot;bar&quot;))
+            ).LightCompile()();
+            Assert(strArray2[0, 0] == &quot;bar&quot;);
+
+            // T[,,]::Get
+            Assert(&quot;foo&quot; == Ast.Lambda&lt;Func&lt;string&gt;&gt;(
+                Ast.Call(Ast.Constant(strArray3), typeof(string[, ,]).GetMethod(&quot;Get&quot;), Ast.Constant(0), Ast.Constant(0), Ast.Constant(0))
+            ).LightCompile()());
+
+            // T[,,]::Set
+            Ast.Lambda&lt;Action&gt;(
+                Ast.Call(Ast.Constant(strArray3), typeof(string[, ,]).GetMethod(&quot;Set&quot;), Ast.Constant(0), Ast.Constant(0), Ast.Constant(0), Ast.Constant(&quot;bar&quot;))
+            ).LightCompile()();
+            Assert(strArray3[0, 0, 0] == &quot;bar&quot;);
+
+            // T[*]::Get
+            Assert(&quot;foo&quot; == Ast.Lambda&lt;Func&lt;string&gt;&gt;(
+                Ast.Call(Ast.Constant(strArray8), typeof(string[, , , , , , ,]).GetMethod(&quot;Get&quot;),
+                        Ast.Constant(0), Ast.Constant(0), Ast.Constant(0), Ast.Constant(0),
+                        Ast.Constant(0), Ast.Constant(0), Ast.Constant(0), Ast.Constant(0)
+                )
+            ).LightCompile()());
+
+            // T[*]::Set
+            Ast.Lambda&lt;Action&gt;(
+                Ast.Call(Ast.Constant(strArray8), typeof(string[, , , , , , ,]).GetMethod(&quot;Set&quot;),
+                        Ast.Constant(0), Ast.Constant(0), Ast.Constant(0), Ast.Constant(0),
+                        Ast.Constant(0), Ast.Constant(0), Ast.Constant(0), Ast.Constant(0),
+                        Ast.Constant(&quot;bar&quot;)
+                )
+            ).LightCompile()();
+            Assert(strArray8[0, 0, 0, 0, 0, 0, 0, 0] == &quot;bar&quot;);
+        }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/InterpreterTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -26,10 +26,6 @@ using Microsoft.Scripting.Utils;
 namespace IronRuby.Tests {
     public partial class Tests {
         public void File1() {
-            Test_Read1();
-        }
-
-        public void File2() {
             TestOutput(@&quot;
 stdout = IO.open(1, 'w', &amp;nil) 
 stdout.puts('hello')
@@ -55,7 +51,8 @@ hello
             return BinaryEncoding.Instance.GetBytes(str);
         }
 
-        private void Test_Read1() {
+        [Options(NoRuntime = true)]
+        public void File2() {
             string s;
             string crlf = &quot;\r\n&quot;;
             var stream = new TestStream(false, B(
@@ -97,5 +94,27 @@ hello
             Assert(io.AppendBytes(buffer, Int32.MaxValue, false) == s.Length - 2);
             Assert(buffer.ToString() == s + s.Replace(crlf, &quot;\n&quot;));
         }
+
+        [Options(NoRuntime = true)]
+        public void File3() {
+            var stream = new MemoryStream();
+            var io = new RubyBufferedStream(stream);
+
+            io.Write(new byte[] { 0, 1, 2, 3 }, 1, 2);
+            Assert(stream.ToArray().ValueEquals(new byte[] { 1, 2 }));
+            stream.Seek(0, SeekOrigin.Begin);
+
+            Assert(io.WriteBytes(new byte[] { 0, 1, 2, 3 }, 1, 2, true) == 2);
+            Assert(stream.ToArray().ValueEquals(new byte[] { 1, 2 }));
+            stream.Seek(0, SeekOrigin.Begin);
+
+            Assert(io.WriteBytes(new byte[] { 0, 1, 2, 3 }, 1, 2, false) == 2);
+            Assert(stream.ToArray().ValueEquals(new byte[] { 1, 2 }));
+            stream.Seek(0, SeekOrigin.Begin);
+
+            Assert(io.WriteBytes(new byte[] { 0, 1, (byte)'\n', 2 }, 1, 2, false) == 3);
+            Assert(stream.ToArray().ValueEquals(new byte[] { 1, (byte)'\r', (byte)'\n' }));
+            stream.Seek(0, SeekOrigin.Begin);
+        }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/IoTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -24,26 +24,6 @@ using Microsoft.Scripting.Utils;
 
 namespace IronRuby.Tests {
     public partial class Tests {
-        public void MutableString1() {
-            Test_Factories();
-            Test_GetHashCode();
-            Test_IsAscii();
-            Test_Length();
-            Test_Append_Byte();
-            Test_Append_Char();
-            Test_Insert_Byte();
-            Test_Insert_Char();
-            Test_Remove_Byte();
-            Test_Remove_Char();
-            Test_SwitchRepr();
-            Test_Concatenate();
-            Test_Reverse();
-        }
-
-        public void MutableString2() {
-            Test_Translate();
-        }
-
         private MutableString/*!*/ MS(string/*!*/ data) {
             return MutableString.CreateMutable(data.Length * 3, RubyEncoding.Binary).Append(data);
         }
@@ -60,7 +40,8 @@ namespace IronRuby.Tests {
             return MutableString.CreateBinary(data.Length * 3, e).Append(data);
         }
 
-        private void Test_Factories() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Factories() {
             var x = MutableString.CreateAscii(&quot;&quot;);
             Assert(!x.IsBinary &amp;&amp; x.IsEmpty);
 
@@ -92,7 +73,8 @@ namespace IronRuby.Tests {
             Assert(x.IsBinary &amp;&amp; x.GetByteCount() == 3 &amp;&amp; x.Encoding == RubyEncoding.UTF8);
         }
 
-        private void Test_GetHashCode() {
+        [Options(NoRuntime = true)]
+        public void MutableString_GetHashCode() {
             int h1, h2;
             MutableString s;
 
@@ -152,7 +134,8 @@ namespace IronRuby.Tests {
             Assert(a.GetHashCode() != b.GetHashCode());
         }
 
-        private void Test_IsAscii() {
+        [Options(NoRuntime = true)]
+        public void MutableString_IsAscii() {
             var a = MutableString.CreateBinary(new byte[] { 0x12, 0x34, 0x56 }, RubyEncoding.Binary);
             Assert(a.IsAscii());
             a.Remove(2);
@@ -167,7 +150,8 @@ namespace IronRuby.Tests {
             Assert(a.IsAscii());
         }
 
-        private void Test_Length() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Length() {
             MutableString x;
             x = MutableString.Create(&quot;a&quot;, RubyEncoding.Binary);
             Assert(MutableStringOps.GetLength(x) == 1);
@@ -179,7 +163,8 @@ namespace IronRuby.Tests {
             Assert(MutableStringOps.GetLength(x) == 2);
         }
 
-        private void Test_Append_Byte() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Append_Byte() {
             MutableString x;
             x = MutableString.CreateBinary(new byte[] { 1, 2 });
             Assert(x.GetByteCount() == 2);
@@ -214,7 +199,8 @@ namespace IronRuby.Tests {
             Assert(x.Equals(MS(new byte[] { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 15, 16, 17, 18, 19, 20 })));
         }
 
-        private void Test_Append_Char() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Append_Char() {
             var e = RubyEncoding.UTF8;
 
             MutableString x;
@@ -257,7 +243,8 @@ namespace IronRuby.Tests {
             Assert(x.Equals(MS(&quot;&#945;&#946;&#947;&#948;fghhhhhhhhij&#954;&#955;&#956;&#957;zzzz&quot;, e)));
         }
 
-        private void Test_Insert_Byte() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Insert_Byte() {
             MutableString x;
             x = MutableString.CreateBinary(new byte[] { 1, 2 });
             x.Insert(0, 3);
@@ -276,7 +263,8 @@ namespace IronRuby.Tests {
             Assert(x.CompareTo(MS(new byte[] { 8, 3, 5, 6, 7, 9, 10, 1, 2, 4 })) == 0);
         }
 
-        private void Test_Insert_Char() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Insert_Char() {
             var e = RubyEncoding.UTF8;
 
             MutableString x;
@@ -297,7 +285,8 @@ namespace IronRuby.Tests {
             Assert(x.CompareTo(MS(&quot;835679&#8486;124&quot;, e)) == 0);
         }
 
-        private void Test_Remove_Byte() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Remove_Byte() {
             MutableString x;
             x = MutableString.CreateBinary(new byte[] { });
             for (int i = 0; i &lt; 10; i++) {
@@ -321,7 +310,8 @@ namespace IronRuby.Tests {
             Assert(x.Equals(MS(new byte[] { })));
         }
 
-        private void Test_Remove_Char() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Remove_Char() {
             var e = RubyEncoding.UTF8;
 
             MutableString x;
@@ -382,7 +372,8 @@ namespace IronRuby.Tests {
             }
         }
 
-        private void Test_SwitchRepr() {
+        [Options(NoRuntime = true)]
+        public void MutableString_SwitchRepr() {
             // \u{12345} in UTF-8:
             var u12345 = new byte[] { 0xF0, 0x92, 0x8D, 0x85 };
             var u215c = new byte[] { 0xE2, 0x85, 0x9C };
@@ -405,7 +396,8 @@ namespace IronRuby.Tests {
             // var e = RubyEncoding.GetRubyEncoding(new NonInvertibleEncoding());
         }
 
-        private void Test_Concatenate() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Concatenate() {
             var utf8 = new byte[] { 0xe2, 0x85, 0x9c };
             var sjis = new byte[] { 0x82, 0xA0 };
             var ascii = new byte[] { 0x20 };
@@ -446,7 +438,8 @@ namespace IronRuby.Tests {
             Assert(b.ValueCompareTo(b.Length, ArrayUtils.AppendRange(b1, b2)) == 0);
         }
 
-        private void Test_Reverse() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Reverse() {
             var SJIS = RubyEncoding.GetRubyEncoding(RubyEncoding.CodePageSJIS);
             var utf8 = new byte[] { 0xe2, 0x85, 0x9c };
             var rev_bin_utf8 = new byte[] { 0x9c, 0x85, 0xe2};
@@ -478,7 +471,7 @@ namespace IronRuby.Tests {
             // TODO: KCODE
         }
 
-        private void Test_Reverse(byte[]/*!*/ b, RubyEncoding/*!*/ e, byte[]/*!*/ expected) {
+        public void Test_Reverse(byte[]/*!*/ b, RubyEncoding/*!*/ e, byte[]/*!*/ expected) {
             var s = MutableString.CreateBinary(b, e);
             MutableStringOps.Reverse(s);
             var actual = s.ToByteArray();
@@ -493,7 +486,8 @@ namespace IronRuby.Tests {
             return Encoding.GetEncoding(&quot;SJIS&quot;).GetBytes(str);
         }
 
-        private void Test_Translate() {
+        [Options(NoRuntime = true)]
+        public void MutableString_Translate1() {
             var SJIS = RubyEncoding.GetRubyEncoding(RubyEncoding.CodePageSJIS);
             var sjis = new byte[] { 0x82, 0xA0 };
             var u12345 = new byte[] { 0xF0, 0x92, 0x8D, 0x85 }; // \u{12345} in UTF-8
@@ -567,5 +561,230 @@ namespace IronRuby.Tests {
             var b = result.ToByteArray();
             Assert(b.ValueEquals(expected));
         }
+
+        [Options(NoRuntime = true)]
+        public void MutableString_IndexOf1() {
+            MutableString a;
+            string s = &quot;12123&quot;;
+
+            a = MutableString.CreateBinary(ArrayUtils.AppendRange(BinaryEncoding.Instance.GetBytes(s), new byte[] { 0, 0 }));
+            a.Remove(s.Length, 2);
+
+            Action&lt;string&gt; test1 = (value) =&gt; {
+                Assert(a.IndexOf(BinaryEncoding.Instance.GetBytes(value)) == s.IndexOf(value));
+            };
+
+            Action&lt;string, int&gt; test2 = (value, start) =&gt; {
+                Assert(a.IndexOf(BinaryEncoding.Instance.GetBytes(value), start) == s.IndexOf(value, start));
+            };
+
+            Action&lt;string, int, int&gt; test3 = (value, start, count) =&gt; {
+                Assert(a.IndexOf(BinaryEncoding.Instance.GetBytes(value), start, count) == s.IndexOf(value, start, count));
+            };
+
+            test1(&quot;&quot;);
+            test1(&quot;0&quot;);
+            test1(&quot;12&quot;);
+            test1(&quot;3&quot;);
+            test2(&quot;12&quot;, 0);
+            test2(&quot;12&quot;, 1);
+            test2(&quot;12&quot;, 2);
+            test2(&quot;30&quot;, 4);
+            test3(&quot;&quot;, 2, 0);
+            test3(&quot;12&quot;, 2, 1);
+            test3(&quot;12&quot;, 2, 2);
+        }
+
+        [Options(NoRuntime = true)]
+        public void MutableString_LastIndexOf1() {
+            MutableString a;
+            string s = &quot;12123&quot;;
+
+            a = MutableString.CreateBinary(ArrayUtils.AppendRange(BinaryEncoding.Instance.GetBytes(s), new byte[] { 0, 0 }));
+            a.Remove(s.Length, 2);
+
+            Action&lt;string&gt; test1 = (value) =&gt; {
+                Assert(a.LastIndexOf(BinaryEncoding.Instance.GetBytes(value)) == s.LastIndexOf(value));
+            };
+
+            Action&lt;string, int&gt; test2 = (value, start) =&gt; {
+                Assert(a.LastIndexOf(BinaryEncoding.Instance.GetBytes(value), start) == s.LastIndexOf(value, start));
+            };
+
+            Action&lt;string, int, int&gt; test3 = (value, start, count) =&gt; {
+                Assert(a.LastIndexOf(BinaryEncoding.Instance.GetBytes(value), start, count) == s.LastIndexOf(value, start, count));
+            };
+
+            test1(&quot;&quot;);
+            test1(&quot;0&quot;);
+            test1(&quot;12&quot;);
+            test1(&quot;3&quot;);
+            test2(&quot;12&quot;, 0);
+            test2(&quot;12&quot;, 1);
+            test2(&quot;12&quot;, 2);
+            test3(&quot;12&quot;, 4, 2);
+            test3(&quot;12&quot;, 4, 3);
+            test3(&quot;12&quot;, 0, 1);
+            test3(&quot;12&quot;, 0, 0);
+            test3(&quot;&quot;, 2, 0);
+
+            AssertExceptionThrown&lt;ArgumentOutOfRangeException&gt;(() =&gt; a.LastIndexOf(new byte[] { 6 }, 0, 2));
+            AssertExceptionThrown&lt;ArgumentOutOfRangeException&gt;(() =&gt; a.LastIndexOf(new byte[] { 6 }, 6, 2));
+        }
+
+        [Options(NoRuntime = true)]
+        public void MutableString_Index1() {
+            var SJIS = RubyEncoding.GetRubyEncoding(RubyEncoding.CodePageSJIS);
+            var sjis = new byte[] { 0x82, 0xA0 };
+            var u12345 = new byte[] { 0xF0, 0x92, 0x8D, 0x85 }; // \u{12345} in UTF-8
+            var invalid = MutableString.CreateBinary(new byte[] { 0x80 }, RubyEncoding.UTF8);
+
+            // SJIS non-ASCII string:
+            AssertExceptionThrown&lt;InvalidOperationException&gt;(
+                () =&gt; MutableStringOps.Index(MutableString.CreateBinary(sjis, SJIS), 0xA0, 0)
+            );
+
+            // binary encoding:
+            int i;
+            i = (int)MutableStringOps.Index(MutableString.CreateBinary(sjis, RubyEncoding.Binary), 0xA0, 0);
+            Assert(i == 1);
+
+            // ASCII-only are ok:
+            i = (int)MutableStringOps.Index(MutableString.CreateMutable(&quot;abc&quot;, RubyEncoding.UTF8), (int)'a', 0);
+            Assert(i == 0);
+
+            // k-coded are ok:
+            i = (int)MutableStringOps.Index(MutableString.CreateBinary(u12345, RubyEncoding.KCodeUTF8), 0x85, 0);
+            Assert(i == 3);
+
+            MutableString a, b;
+
+            // incompatible encodings:
+            a = MutableString.CreateBinary(sjis, SJIS);
+            b = MutableString.CreateBinary(u12345, RubyEncoding.UTF8);
+            AssertExceptionThrown&lt;EncodingCompatibilityError&gt;(() =&gt; MutableStringOps.Index(a, b, 0));
+
+            // invalid character:
+            AssertExceptionThrown&lt;ArgumentException&gt;(() =&gt; MutableStringOps.Index(invalid, MutableString.FrozenEmpty, 0));
+            AssertExceptionThrown&lt;ArgumentException&gt;(() =&gt; MutableStringOps.Index(MutableString.FrozenEmpty, invalid, 0));
+            
+            // returns character index:
+            i = (int)MutableStringOps.Index(
+                MutableString.CreateMutable(&quot;a&#945;b&quot;, RubyEncoding.UTF8),
+                MutableString.CreateMutable(&quot;b&quot;, SJIS), 
+                0
+            );
+            Assert(i == 2);
+
+            // returns character index:
+            i = (int)MutableStringOps.Index(
+                MutableString.CreateMutable(&quot;&#945;abbba&quot;, RubyEncoding.UTF8),
+                MutableString.CreateAscii(&quot;a&quot;),
+                2
+            );
+            Assert(i == 5);
+
+            // returns byte index for k-coded strings:
+            i = (int)MutableStringOps.Index(
+                MutableString.CreateMutable(&quot;&#945;a&#946;b&quot;, RubyEncoding.KCodeUTF8),
+                MutableString.CreateMutable(&quot;a&quot;, RubyEncoding.KCodeSJIS),
+                0
+            );
+            Assert(i == 2);
+
+            // returns byte index for k-coded strings:
+            i = (int)MutableStringOps.Index(
+                MutableString.CreateMutable(&quot;&#945;abbba&quot;, RubyEncoding.KCodeUTF8),
+                MutableString.CreateAscii(&quot;a&quot;),
+                2
+            );
+            Assert(i == 2);
+        }
+
+        public void MutableString_IndexRegex1() {
+            var SJIS = RubyEncoding.GetRubyEncoding(RubyEncoding.CodePageSJIS);
+            var sjis = new byte[] { 0x82, 0xA0 };
+            var u12345 = new byte[] { 0xF0, 0x92, 0x8D, 0x85 }; // \u{12345} in UTF-8
+            var invalid = MutableString.CreateBinary(new byte[] { 0x80 }, RubyEncoding.UTF8);
+            int i;
+            MutableString a;
+            RubyRegex r;
+            RubyScope scope = new RubyTopLevelScope(Context);
+
+            // incompatible encodings:
+            a = MutableString.CreateBinary(sjis, SJIS);
+            r = new RubyRegex(MutableString.CreateBinary(u12345, RubyEncoding.UTF8));
+            AssertExceptionThrown&lt;EncodingCompatibilityError&gt;(() =&gt; MutableStringOps.Index(scope, a, r, 0));
+
+            // invalid character:
+            AssertExceptionThrown&lt;ArgumentException&gt;(() =&gt; MutableStringOps.Index(scope, invalid, r, 0));
+
+            // returns character index:
+            i = (int)MutableStringOps.Index(
+                scope,
+                MutableString.CreateMutable(&quot;a&#945;b&quot;, RubyEncoding.UTF8),
+                new RubyRegex(MutableString.CreateMutable(&quot;b&quot;, SJIS)),
+                0
+            );
+            Assert(i == 2);
+
+            // &quot;start at&quot; counts chars in 1.9, returns character index
+            i = (int)MutableStringOps.Index(
+                scope,
+                MutableString.CreateMutable(&quot;&#945;abbba&quot;, RubyEncoding.UTF8),
+                new RubyRegex(MutableString.CreateAscii(&quot;a&quot;)),
+                2
+            );
+            Assert(i == 5);
+
+            // &quot;start at&quot; counts bytes in 1.8, returns byte index (regardless of KCODE)
+            i = (int)MutableStringOps.Index(
+                scope,
+                MutableString.CreateBinary(Encoding.UTF8.GetBytes(&quot;&#945;a&quot;), RubyEncoding.Binary),
+                new RubyRegex(MutableString.CreateAscii(&quot;a&quot;), RubyRegexOptions.UTF8),
+                2
+            );
+            Assert(i == 2);
+
+            // returns byte index for k-coded strings:
+            i = (int)MutableStringOps.Index(
+                scope,
+                MutableString.CreateMutable(&quot;&#945;a&#946;b&quot;, RubyEncoding.KCodeUTF8),
+                new RubyRegex(MutableString.CreateMutable(&quot;a&quot;, RubyEncoding.KCodeSJIS)),
+                0
+            );
+            Assert(i == 2);
+
+            // returns byte index for k-coded strings:
+            i = (int)MutableStringOps.Index(
+                scope,
+                MutableString.CreateMutable(&quot;&#945;abbba&quot;, RubyEncoding.KCodeUTF8),
+                new RubyRegex(MutableString.CreateAscii(&quot;a&quot;)),
+                2
+            );
+            Assert(i == 2);
+
+            // uses the current KCODE for match:
+            a = MutableString.CreateBinary(new byte[] { 0x82, 0xa1, 0x82, 0xa0, 0x82, 0xa0 }, RubyEncoding.Binary);
+            r = new RubyRegex(MutableString.CreateBinary(new byte[] { 0x82, 0xa0, (byte)'{', (byte)'2', (byte)'}' }, RubyEncoding.Binary));
+
+            Context.KCode = RubyEncoding.KCodeSJIS;
+            Assert((int)MutableStringOps.Index(scope, a, r, 0) == 2);
+
+            Context.KCode = null;
+            Assert(MutableStringOps.Index(scope, a, r, 0) == null);
+
+            // invalid characters:
+            a = MutableString.CreateBinary(new byte[] { 0x82, 0x82, 0xa0, 0xa0, 0x82 }, RubyEncoding.Binary);
+            r = new RubyRegex(MutableString.CreateBinary(new byte[] { 0x82, 0xa0, (byte)'{', (byte)'2', (byte)'}' }, RubyEncoding.Binary));
+
+            // TODO:
+            // We throw an exception here since we don't exactly know how MRI handles invalid characters.
+            Context.KCode = RubyEncoding.KCodeSJIS;
+            AssertExceptionThrown&lt;ArgumentException&gt;(() =&gt; MutableStringOps.Index(scope, a, r, 0));
+
+            Context.KCode = null;
+            Assert((int)MutableStringOps.Index(scope, a, r, 0) == 1);
+        }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/MutableStringTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -106,10 +106,18 @@ namespace IronRuby.Tests {
             }
         }
 
+        #endregion
+
+        #region Misc
+
         public class Overloads1 {
             public class X {
             }
 
+            public enum E {
+                A = 1, B = 2
+            }
+
             public void F1(int a) { }
             public void F2(BigInteger a) { }
             public void F3(double a) { }
@@ -138,6 +146,12 @@ namespace IronRuby.Tests {
             public void L1(SymbolId a, [DefaultProtocol, NotNull]string b) { }
             public void L2([NotNull]string a, [DefaultProtocol, NotNull]string b) { }
             public void L3([DefaultProtocol]MutableString a, [DefaultProtocol, NotNull]string b) { }
+
+            public void M1(int a) { }
+            public void M2(E e) { }
+
+            public void N1(string a) { }
+            public void N2(char a) { }
         }
 
         public void OverloadResolution_Numeric1() {
@@ -183,6 +197,13 @@ namespace IronRuby.Tests {
                 new { Args = new[] { MO(ms), MO(sym) }, Overloads = &quot;L*&quot;, Result = &quot;L3&quot; },
                 new { Args = new[] { MO(null), MO(sym) }, Overloads = &quot;L*&quot;, Result = &quot;L3&quot; },
                 new { Args = new[] { MO(c), MO(sym) }, Overloads = &quot;L*&quot;, Result = &quot;L3&quot; },
+
+                // M
+                new { Args = new[] { MO(1) }, Overloads = &quot;M*&quot;, Result = &quot;M1&quot; },
+                new { Args = new[] { MO(Overloads1.E.A) }, Overloads = &quot;M*&quot;, Result = &quot;M2&quot; },
+
+                // N
+                new { Args = new[] { MO(MutableString.CreateAscii(&quot;x&quot;)) }, Overloads = &quot;N*&quot;, Result = &quot;N1&quot; },
             };
 
             for (int i = 0; i &lt; cases.Length; i++) {</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/OverloadResolutionTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,7 @@
 using System;
 using System.Text.RegularExpressions;
 using IronRuby.Builtins;
+using System.Text;
 
 namespace IronRuby.Tests {
     public partial class Tests {
@@ -99,27 +100,39 @@ puts(/b#{/a/}/)
                 @&quot;\0&quot;,
                 @&quot;\0&quot;,
 
-                @&quot;\G&quot;,
-                @&quot;\G&quot;,
-
                 @&quot;[a\-z]&quot;,
                 @&quot;[a\-z]&quot;,
             };
 
+            string[] correctPatternsWithG = new string[] {
+                @&quot;\G&quot;,
+                @&quot;\G&quot;,
+            };
+
             for (int i = 0; i &lt; incorrectPatterns.Length; i += 2) {
+                bool hasGAnchor;
                 string expected = incorrectPatterns[i + 1];
-                string actual = StringRegex.TransformPattern(incorrectPatterns[i], RubyRegexOptions.NONE);
+                string actual = RegexpTransformer.Transform(incorrectPatterns[i], RubyRegexOptions.NONE, out hasGAnchor);
                 AreEqual(expected, actual);
             }
 
             for (int i = 0; i &lt; correctPatterns.Length; i += 2) {
-                string expected = correctPatterns[i + 1];
-                string actual = StringRegex.TransformPattern(correctPatterns[i], RubyRegexOptions.NONE);
-                AreEqual(expected, actual);
-                new Regex(expected);
+                TestCorrectPatternTranslation(correctPatterns[i], correctPatterns[i + 1], false);
+            }
+
+            for (int i = 0; i &lt; correctPatternsWithG.Length; i += 2) {
+                TestCorrectPatternTranslation(correctPatternsWithG[i], correctPatternsWithG[i + 1], true);
             }
         }
 
+        private void TestCorrectPatternTranslation(string/*!*/ pattern, string/*!*/ expected, bool expectedGAnchor) {
+            bool hasGAnchor;
+            string actual = RegexpTransformer.Transform(pattern, RubyRegexOptions.NONE, out hasGAnchor);
+            AreEqual(expected, actual);
+            new Regex(expected);
+            Assert(hasGAnchor == expectedGAnchor);
+        }
+
         public void RegexTransform2() {
             string e = @&quot;^
         ([a-zA-Z][-+.a-zA-Z\d]*):                     (?# 1: scheme)
@@ -140,8 +153,10 @@ puts(/b#{/a/}/)
         )
         (?:\#((?:[-_.!~*'()a-zA-Z\d;/?:@&amp;=+$,\[\]]|%[a-fA-F\d]{2})*))?            (?# 9: fragment)
       $&quot;;
-            string t = StringRegex.TransformPattern(e, RubyRegexOptions.Extended | RubyRegexOptions.Multiline);
+            bool hasGAnchor;
+            string t = RegexpTransformer.Transform(e, RubyRegexOptions.Extended | RubyRegexOptions.Multiline, out hasGAnchor);
             Assert(e == t);
+            Assert(!hasGAnchor);
             new Regex(t);
         }
 
@@ -162,7 +177,7 @@ puts(/b#{/a/}/)
 
             for (int i = 0; i &lt; patterns.Length; i += 2) {
                 string expected = patterns[i + 1];
-                string actual = StringRegex.Escape(patterns[i]);
+                string actual = RubyRegex.Escape(patterns[i]);
                 Assert(actual == expected);
             }
         }
@@ -205,6 +220,132 @@ puts(/foo/ =~ 'xxxfoo')
 3
 &quot;);
         }
+
+        [Options(NoRuntime = true)]
+        public void RegexEncoding1() {
+            MatchData m;
+            // the k-coding of the pattern string is irrelevant:
+            foreach (var pe in new[] { RubyEncoding.KCodeSJIS, RubyEncoding.KCodeUTF8, RubyEncoding.Binary }) {
+                var p = MutableString.CreateBinary(new byte[] { 0x82, 0xa0, (byte)'{', (byte)'2', (byte)'}' }, pe);
+
+                var r = new RubyRegex(p, RubyRegexOptions.NONE);
+                var rs = new RubyRegex(p, RubyRegexOptions.SJIS);
+
+                // the k-coding of the string is irrelevant:
+                foreach (var se in new[] { RubyEncoding.KCodeSJIS, RubyEncoding.KCodeUTF8, RubyEncoding.Binary }) {
+                    var s = MutableString.CreateBinary(new byte[] { 0x82, 0xa0, 0xa0 }, se);
+                    var t = MutableString.CreateBinary(new byte[] { 0x82, 0xa0, 0xa0, 0x82, 0xa0, 0xa0 }, se);
+
+                    // /&#12354;{2}/ does not match &quot;&#12354;\xa0&quot;
+                    m = r.Match(RubyEncoding.KCodeSJIS, s);
+                    Assert(m == null);
+
+                    // /\x82\xa0{2}/ matches &quot;\x82\xa0\xa0&quot;
+                    m = r.Match(null, s);
+                    Assert(m != null &amp;&amp; m.Index == 0);
+
+                    // /&#12354;{2}/ does not match &quot;&#12354;\xa0&quot;, current KCODE is ignored
+                    m = rs.Match(null, s);
+                    Assert(m == null);
+
+                    // /&#12354;{2}/ does not match &quot;&#12354;\xa0&quot;, current KCODE is ignored
+                    m = rs.Match(RubyEncoding.KCodeUTF8, s);
+                    Assert(m == null);
+
+
+                    // /&#12354;{2}/ does not match &quot;&#12354;\xa0&#12354;\xa0&quot;
+                    m = r.LastMatch(RubyEncoding.KCodeSJIS, t);
+                    Assert(m == null);
+
+                    // /\x82\xa0{2}/ matches &quot;\x82\xa0\xa0\x82\xa0\xa0&quot;
+                    m = r.LastMatch(null, t);
+                    Assert(m != null &amp;&amp; m.Index == 3);
+
+                    // /&#12354;{2}/ does not match &quot;&#12354;\xa0&#12354;\xa0&quot;, current KCODE is ignored
+                    m = rs.LastMatch(null, t);
+                    Assert(m == null);
+
+                    // /&#12354;{2}/ does not match &quot;&#12354;\xa0&#12354;\xa0&quot;, current KCODE is ignored
+                    m = rs.LastMatch(RubyEncoding.KCodeUTF8, t);
+                    Assert(m == null);
+                }
+            }
+        }
+
+        [Options(NoRuntime = true)]
+        public void RegexEncoding2() {
+            var SJIS = Encoding.GetEncoding(&quot;SJIS&quot;);
+
+            // 1.9 encodings:
+            var invalidUtf8 = MutableString.CreateBinary(new byte[] { 0x80 }, RubyEncoding.UTF8);
+            AssertExceptionThrown&lt;ArgumentException&gt;(() =&gt; new RubyRegex(invalidUtf8, RubyRegexOptions.NONE));
+
+            // LastMatch
+
+            MatchData m;
+            var u = MutableString.CreateBinary(SJIS.GetBytes(&quot;&#12354;&#12354;&#12354;&quot;), RubyEncoding.KCodeSJIS);
+            var p = MutableString.CreateBinary(SJIS.GetBytes(&quot;&#12354;{2}&quot;), RubyEncoding.KCodeSJIS);
+
+            var rs = new RubyRegex(p, RubyRegexOptions.SJIS);
+
+            // /&#12354;{2}/ matches &quot;&#12354;&#12354;&#12354;&quot;, the resulting index is in bytes:
+            m = rs.LastMatch(null, u);
+            Assert(m != null &amp;&amp; m.Index == 2);
+
+            rs = new RubyRegex(MutableString.CreateBinary(SJIS.GetBytes(&quot;&#12354;&quot;)), RubyRegexOptions.SJIS);
+
+            // &quot;start at&quot; in the middle of a character:
+            m = rs.LastMatch(null, u, 0);
+            Assert(m != null &amp;&amp; m.Index == 0);
+
+            m = rs.LastMatch(null, u, 1);
+            Assert(m != null &amp;&amp; m.Index == 0);
+
+            m = rs.LastMatch(null, u, 2);
+            Assert(m != null &amp;&amp; m.Index == 2);
+
+            m = rs.LastMatch(null, u, 3);
+            Assert(m != null &amp;&amp; m.Index == 2);
+
+            // Split
+            
+            u = MutableString.CreateBinary(SJIS.GetBytes(&quot;&#12354;&#12385;&#12354;&#12385;&#12354;&quot;), RubyEncoding.UTF8);
+            rs = new RubyRegex(MutableString.CreateBinary(SJIS.GetBytes(&quot;&#12385;&quot;)), RubyRegexOptions.SJIS);
+            var parts = rs.Split(null, u);
+            Assert(parts.Length == 3);
+            foreach (var part in parts) {
+                Assert(part.Encoding == RubyEncoding.KCodeSJIS);
+                Assert(part.ToString() == &quot;&#12354;&quot;);
+            }
+
+            // groups
+
+            rs = new RubyRegex(MutableString.CreateBinary(SJIS.GetBytes(&quot;&#12385;(a(&#12354;+)(b+))+&#12354;&quot;)), RubyRegexOptions.SJIS);
+            u = MutableString.CreateBinary(SJIS.GetBytes(&quot;&#12385;a&#12354;&#12354;ba&#12354;bbb&#12354;&quot;));
+
+            m = rs.Match(null, u);
+            Assert(m.GroupCount == 4);
+
+            int s, l;
+            Assert(m.GetGroupStart(0) == (s = 0));
+            Assert(m.GetGroupLength(0) == (l = u.GetByteCount()));
+            Assert(m.GetGroupEnd(0) == s + l);
+
+            // the group has 2 captures, the last one is its value:
+            Assert(m.GetGroupStart(1) == (s = SJIS.GetByteCount(&quot;&#12385;a&#12354;&#12354;b&quot;)));
+            Assert(m.GetGroupLength(1) == (l = SJIS.GetByteCount(&quot;a&#12354;bbb&quot;)));
+            Assert(m.GetGroupEnd(1) == s + l);
+
+            // the group has 2 captures, the last one is its value:
+            Assert(m.GetGroupStart(2) == (s = SJIS.GetByteCount(&quot;&#12385;a&#12354;&#12354;ba&quot;)));
+            Assert(m.GetGroupLength(2) == (l = SJIS.GetByteCount(&quot;&#12354;&quot;)));
+            Assert(m.GetGroupEnd(2) == s + l);
+
+            // the group has 2 captures, the last one is its value:
+            Assert(m.GetGroupStart(3) == (s = SJIS.GetByteCount(&quot;&#12385;a&#12354;&#12354;ba&#12354;&quot;)));
+            Assert(m.GetGroupLength(3) == (l = SJIS.GetByteCount(&quot;bbb&quot;)));
+            Assert(m.GetGroupEnd(3) == s + l);
+        }
     }
 }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/RegexTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -425,8 +425,9 @@ namespace IronRuby.Builtins {
         public static MutableString/*!*/ Inspect(UnaryOpStorage/*!*/ inspectStorage, ConversionStorage&lt;MutableString&gt;/*!*/ tosConversion,
             object self) {
 
+            RubyClass cls;
             var context = tosConversion.Context;
-            if (context.HasInstanceVariables(self)) {
+            if (context.HasInstanceVariables(self) &amp;&amp; ((cls = context.GetClassOf(self)).IsRubyClass || cls.IsObjectClass)) {
                 return RubyUtils.InspectObject(inspectStorage, tosConversion, self);
             } else {
                 var site = tosConversion.GetSite(ConvertToSAction.Make(context));
@@ -915,11 +916,13 @@ namespace IronRuby.Builtins {
         /// Includes CLR private members if PrivateBinding is on.
         /// &lt;/summary&gt;
         [RubyMethod(&quot;clr_member&quot;)]
-        public static RubyMethod/*!*/ GetClrMember(RubyContext/*!*/ context, object self, [DefaultProtocol, NotNull]string/*!*/ name) {
+        public static RubyMethod/*!*/ GetClrMember(RubyContext/*!*/ context, object self, [DefaultParameterValue(null), NotNull]object asType, 
+            [DefaultProtocol, NotNull]string/*!*/ name) {
             RubyMemberInfo info;
 
             RubyClass cls = context.GetClassOf(self);
-            if (!cls.TryGetClrMember(name, out info)) {
+            Type type = (asType != null) ? Protocols.ToType(context, asType) : null;
+            if (!cls.TryGetClrMember(name, type, out info)) {
                 throw RubyExceptions.CreateNameError(String.Format(&quot;undefined CLR method `{0}' for class `{1}'&quot;, name, cls.Name));
             }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/KernelOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -203,8 +203,7 @@ namespace IronRuby.Builtins {
             }
 
             private void WriteStringValue(MutableString/*!*/ value) {
-                // TODO: MutableString should be able to return a byte[] without converting the repr?
-                byte[] data = MutableString.Create(value).ConvertToBytes();
+                byte[] data = value.ToByteArray();
                 WriteInt32(data.Length);
                 _writer.Write(data);
             }
@@ -228,7 +227,7 @@ namespace IronRuby.Builtins {
             private void WriteRegex(RubyRegex/*!*/ value) {
                 SubclassData instanceWriter = new SubclassData(this, value, typeof(RubyRegex));
                 _writer.Write((byte)'/');
-                WriteStringValue(value.GetPattern());
+                WriteStringValue(value.Pattern);
                 _writer.Write((byte)value.Options);
             }
 
@@ -760,7 +759,7 @@ namespace IronRuby.Builtins {
                         RubyRegex rsc = (obj as RubyRegex);
                         if (rsc != null) {
                             RubyRegex regex = ReadRegex();
-                            rsc.Set(regex.GetPattern(), regex.Options);
+                            rsc.Set(regex.Pattern, regex.Options);
                             loaded = true;
                         }
                         break;</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs</filename>
    </modified>
    <modified>
      <diff>@@ -36,20 +36,20 @@ namespace IronRuby.Builtins {
         #region Public Instance Methods
 
         [RubyMethod(&quot;[]&quot;)]
-        public static MutableString GetGroup(RubyContext/*!*/ context, MatchData/*!*/ self, [DefaultProtocol]int index) {
-            index = IListOps.NormalizeIndex(self.Groups.Count, index);
-            return self.GetGroupValue(context, index);
+        public static MutableString GetGroup(MatchData/*!*/ self, [DefaultProtocol]int index) {
+            index = IListOps.NormalizeIndex(self.GroupCount, index);
+            return self.GetGroupValue(index);
         }
 
         [RubyMethod(&quot;[]&quot;)]
-        public static RubyArray GetGroup(RubyContext/*!*/ context, MatchData/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol]int length) {
-            if (!IListOps.NormalizeRange(self.Groups.Count, ref start, ref length)) {
+        public static RubyArray GetGroup(MatchData/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol]int length) {
+            if (!IListOps.NormalizeRange(self.GroupCount, ref start, ref length)) {
                 return null;
             }
 
             RubyArray result = new RubyArray();
             for (int i = 0; i &lt; length; i++) {
-                result.Add(self.GetGroupValue(context, start + i));
+                result.Add(self.GetGroupValue(start + i));
             }
 
             return result;
@@ -58,37 +58,37 @@ namespace IronRuby.Builtins {
         [RubyMethod(&quot;[]&quot;)]
         public static RubyArray GetGroup(ConversionStorage&lt;int&gt;/*!*/ fixnumCast, MatchData/*!*/ self, [NotNull]Range/*!*/ range) {
             int begin, count;
-            if (!IListOps.NormalizeRange(fixnumCast, self.Groups.Count, range, out begin, out count)) {
+            if (!IListOps.NormalizeRange(fixnumCast, self.GroupCount, range, out begin, out count)) {
                 return null;
             }
-            return GetGroup(fixnumCast.Context, self, begin, count);
+            return GetGroup(self, begin, count);
         }
 
         [RubyMethod(&quot;begin&quot;)]
         public static object Begin(MatchData/*!*/ self, [DefaultProtocol]int groupIndex) {
-            var group = self.GetExistingGroup(groupIndex);
-            return group.Success ? ScriptingRuntimeHelpers.Int32ToObject(group.Index) : null;
+            self.RequireExistingGroup(groupIndex);
+            return self.GroupSuccess(groupIndex) ? ScriptingRuntimeHelpers.Int32ToObject(self.GetGroupStart(groupIndex)) : null;
         }
 
         [RubyMethod(&quot;end&quot;)]
         public static object End(MatchData/*!*/ self, [DefaultProtocol]int groupIndex) {
-            var group = self.GetExistingGroup(groupIndex);
-            return group.Success ? ScriptingRuntimeHelpers.Int32ToObject(group.Index + group.Length) : null;
+            self.RequireExistingGroup(groupIndex);
+            return self.GroupSuccess(groupIndex) ? ScriptingRuntimeHelpers.Int32ToObject(self.GetGroupEnd(groupIndex)) : null;
         }
 
         [RubyMethod(&quot;length&quot;)]
         [RubyMethod(&quot;size&quot;)]
         public static int Length(MatchData/*!*/ self) {
-            return self.Groups.Count;
+            return self.GroupCount;
         }
 
         [RubyMethod(&quot;offset&quot;)]
         public static RubyArray/*!*/ Offset(MatchData/*!*/ self, [DefaultProtocol]int groupIndex) {
-            var group = self.GetExistingGroup(groupIndex);
+            self.RequireExistingGroup(groupIndex);
             RubyArray result = new RubyArray(2);
-            if (group.Success) {
-                result.Add(group.Index);
-                result.Add(group.Index + group.Length);
+            if (self.GroupSuccess(groupIndex)) {
+                result.Add(self.GetGroupStart(groupIndex));
+                result.Add(self.GetGroupEnd(groupIndex));
             } else {
                 result.Add(null);
                 result.Add(null);
@@ -106,28 +106,28 @@ namespace IronRuby.Builtins {
             return self.OriginalString.GetSlice(self.Index + self.Length).TaintBy(self, context);
         }
 
-        private static RubyArray/*!*/ ReturnMatchingGroups(RubyContext/*!*/ context, MatchData/*!*/ self, int groupIndex) {
+        private static RubyArray/*!*/ ReturnMatchingGroups(MatchData/*!*/ self, int groupIndex) {
             Debug.Assert(groupIndex &gt;= 0);
             
-            if (self.Groups.Count &lt; groupIndex) {
+            if (self.GroupCount &lt; groupIndex) {
                 return new RubyArray();
             }
 
-            RubyArray result = new RubyArray(self.Groups.Count - groupIndex);
-            for (int i = groupIndex; i &lt; self.Groups.Count; i++) {
-                result.Add(self.GetGroupValue(context, i));
+            RubyArray result = new RubyArray(self.GroupCount - groupIndex);
+            for (int i = groupIndex; i &lt; self.GroupCount; i++) {
+                result.Add(self.GetGroupValue(i));
             }
             return result;
         }
 
         [RubyMethod(&quot;captures&quot;)]
-        public static RubyArray/*!*/ Captures(RubyContext/*!*/ context, MatchData/*!*/ self) {
-            return ReturnMatchingGroups(context, self, 1);
+        public static RubyArray/*!*/ Captures(MatchData/*!*/ self) {
+            return ReturnMatchingGroups(self, 1);
         }
 
         [RubyMethod(&quot;to_a&quot;)]
-        public static RubyArray/*!*/ ToArray(RubyContext/*!*/ context, MatchData/*!*/ self) {
-            return ReturnMatchingGroups(context, self, 0);
+        public static RubyArray/*!*/ ToArray(MatchData/*!*/ self) {
+            return ReturnMatchingGroups(self, 0);
         }
 
         [RubyMethod(&quot;string&quot;)]
@@ -136,10 +136,10 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;select&quot;)]
-        public static object Select(RubyContext/*!*/ context, [NotNull]BlockParam/*!*/ block, MatchData/*!*/ self) {
+        public static object Select([NotNull]BlockParam/*!*/ block, MatchData/*!*/ self) {
             RubyArray result = new RubyArray();
-            for (int i = 0; i &lt; self.Groups.Count; i++) {
-                MutableString value = self.GetGroupValue(context, i);
+            for (int i = 0; i &lt; self.GroupCount; i++) {
+                MutableString value = self.GetGroupValue(i);
 
                 object blockResult;
                 if (block.Yield(value, out blockResult)) {
@@ -159,7 +159,7 @@ namespace IronRuby.Builtins {
 
             RubyArray result = new RubyArray();
             for (int i = 0; i &lt; indices.Length; i++) {
-                result.Add(GetGroup(conversionStorage.Context, self, indices[i]));
+                result.Add(GetGroup(self, indices[i]));
             }
             return result;
         }
@@ -170,8 +170,8 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;to_s&quot;)]
-        public static MutableString/*!*/ ToS(RubyContext/*!*/ context, MatchData/*!*/ self) {
-            return MutableString.Create(self.Value, self.Encoding).TaintBy(self, context);
+        public static MutableString/*!*/ ToS(MatchData/*!*/ self) {
+            return self.GetValue();
         }
 
         #endregion</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MatchDataOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -49,15 +49,11 @@ namespace IronRuby.Builtins {
 
         #region Helpers
 
-        internal static int NormalizeIndex(MutableString/*!*/ str, int index) {
-            return IListOps.NormalizeIndex(str.Length, index);
-        }
-
-        private static bool InExclusiveRangeNormalized(MutableString/*!*/ str, ref int index) {
+        internal static bool InExclusiveRangeNormalized(int length, ref int index) {
             if (index &lt; 0) {
-                index = index + str.Length;
+                index = index + length;
             }
-            return index &gt;= 0 &amp;&amp; index &lt; str.Length;
+            return index &gt;= 0 &amp;&amp; index &lt; length;
         }
 
         private static bool InInclusiveRangeNormalized(MutableString/*!*/ str, ref int index) {
@@ -66,6 +62,44 @@ namespace IronRuby.Builtins {
             }
             return index &gt;= 0 &amp;&amp; index &lt;= str.Length;
         }
+
+        internal static bool NormalizeSubstringRange(ConversionStorage&lt;int&gt;/*!*/ fixnumCast, Range/*!*/ range, int length, out int begin, out int count) {
+            begin = Protocols.CastToFixnum(fixnumCast, range.Begin);
+            int end = Protocols.CastToFixnum(fixnumCast, range.End);
+
+            begin = IListOps.NormalizeIndex(length, begin);
+            if (begin &lt; 0 || begin &gt; length) {
+                count = 0;
+                return false;
+            }
+
+            end = IListOps.NormalizeIndex(length, end); 
+
+            count = range.ExcludeEnd ? end - begin : end - begin + 1;
+            return true;
+        }
+
+        internal static bool NormalizeSubstringRange(int length, ref int start, ref int count) {
+            start = IListOps.NormalizeIndex(length, start);
+
+            if (start == length || start &lt; 0 || start &gt; length || count &lt; 0) {
+                return false;
+            }
+
+            if (start + count &gt; length) {
+                count = length - start;
+            }
+
+            return true;
+        }
+
+        internal static int NormalizeInsertIndex(int index, int length) {
+            int result = index &lt; 0 ? index + length + 1 : index;
+            if (result &gt; length || result &lt; 0) {
+                throw RubyExceptions.CreateIndexError(String.Format(&quot;index {0} out of string&quot;, index));
+            }
+            return result;
+        }
         
         // Parses interval strings that are of this form:
         //
@@ -438,32 +472,9 @@ namespace IronRuby.Builtins {
 
         #region slice!
 
-        private static Group MatchRegexp(RubyScope/*!*/ scope, MutableString/*!*/ self, RubyRegex/*!*/ regex, int occurrance) {
-            MatchData match = RegexpOps.Match(scope, regex, self); 
-            if (match == null || !match.Success)
-                return null;
-
-            // Normalize index against # Groups in Match
-            if (occurrance &lt; 0) {
-                occurrance += match.Groups.Count;
-                // Cannot refer to zero using negative indices 
-                if (occurrance == 0) {
-                    return null;
-                }
-            }
-
-            if (occurrance &lt; 0 || occurrance &gt; match.Groups.Count) {
-                return null;
-            }
-
-            return match.Groups[occurrance].Success ? match.Groups[occurrance] : null;
-        }
-
         [RubyMethod(&quot;slice!&quot;)]
-        public static object RemoveCharInPlace(RubyContext/*!*/ context, MutableString/*!*/ self, 
-            [DefaultProtocol]int index) {
-
-            if (!InExclusiveRangeNormalized(self, ref index)) {
+        public static object RemoveCharInPlace(RubyContext/*!*/ context, MutableString/*!*/ self, [DefaultProtocol]int index) {
+            if (!InExclusiveRangeNormalized(self.GetByteCount(), ref index)) {
                 return null;
             }
 
@@ -474,9 +485,7 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;slice!&quot;)]
-        public static MutableString RemoveSubstringInPlace(MutableString/*!*/ self,
-            [DefaultProtocol]int start, [DefaultProtocol]int length) {
-
+        public static MutableString RemoveSubstringInPlace(MutableString/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol]int length) {
             if (length &lt; 0) {
                 return null;
             }
@@ -504,7 +513,7 @@ namespace IronRuby.Builtins {
                 return null;
             }
 
-            end = NormalizeIndex(self, end);
+            end = IListOps.NormalizeIndex(self.Length, end);
 
             int count = range.ExcludeEnd ? end - begin : end - begin + 1;
             return count &lt; 0 ? self.CreateInstance() : RemoveSubstringInPlace(self, begin, count);
@@ -517,7 +526,7 @@ namespace IronRuby.Builtins {
             }
 
             MatchData match = RegexpOps.Match(scope, regex, self);
-            if (match == null || !match.Success) {
+            if (match == null) {
                 return null;
             }
 
@@ -532,8 +541,13 @@ namespace IronRuby.Builtins {
                 return self.Clone().TaintBy(regex, scope);
             }
 
-            Group group = MatchRegexp(scope, self, regex, occurrance);
-            return group == null ? null : RemoveSubstringInPlace(self, group.Index, group.Length).TaintBy(regex, scope);
+            MatchData match = RegexpOps.Match(scope, regex, self);
+            if (match == null || !RegexpOps.NormalizeGroupIndex(ref occurrance, match.GroupCount)) {
+                return null;
+            }
+
+            return match.GroupSuccess(occurrance) ?
+                RemoveSubstringInPlace(self, match.GetGroupStart(occurrance), match.GetGroupLength(occurrance)).TaintBy(regex, scope) : null;
         }
 
         [RubyMethod(&quot;slice!&quot;)]
@@ -558,56 +572,34 @@ namespace IronRuby.Builtins {
         [RubyMethod(&quot;[]&quot;)]
         [RubyMethod(&quot;slice&quot;)]
         public static object GetChar(MutableString/*!*/ self, [DefaultProtocol]int index) {
-            return InExclusiveRangeNormalized(self, ref index) ? (object)(int)self.GetByte(index) : null;
+            return InExclusiveRangeNormalized(self.GetByteCount(), ref index) ? ScriptingRuntimeHelpers.Int32ToObject(self.GetByte(index)) : null;
         }
 
         [RubyMethod(&quot;[]&quot;)]
         [RubyMethod(&quot;slice&quot;)]
-        public static MutableString GetSubstring(MutableString/*!*/ self, 
-            [DefaultProtocol]int start, [DefaultProtocol]int length) {
-
-            start = NormalizeIndex(self, start);
-
-            if (start == self.Length) {
-                return self.CreateInstance().TaintBy(self);
-            }
-
-            if (start &lt; 0 || start &gt; self.Length || length &lt; 0) {
-                return null;
-            }
-
-            if (start + length &gt; self.Length) {
-                length = self.Length - start;
+        public static MutableString GetSubstring(MutableString/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol]int count) {
+            int byteCount = self.GetByteCount();
+            if (!NormalizeSubstringRange(byteCount, ref start, ref count)) {
+                return (start == byteCount) ? self.CreateInstance().TaintBy(self) : null;
             }
 
-            return self.CreateInstance().Append(self, start, length).TaintBy(self);
+            return self.CreateInstance().Append(self, start, count).TaintBy(self);
         }
 
         [RubyMethod(&quot;[]&quot;)]
         [RubyMethod(&quot;slice&quot;)]
         public static MutableString GetSubstring(ConversionStorage&lt;int&gt;/*!*/ fixnumCast, MutableString/*!*/ self, [NotNull]Range/*!*/ range) {
-            int begin = Protocols.CastToFixnum(fixnumCast, range.Begin);
-            int end = Protocols.CastToFixnum(fixnumCast, range.End);
-
-            begin = NormalizeIndex(self, begin);
-            if (begin &lt; 0 || begin &gt; self.Length) {
+            int begin, count;
+            if (!NormalizeSubstringRange(fixnumCast, range, self.GetByteCount(), out begin, out count)) {
                 return null;
             }
-
-            end = NormalizeIndex(self, end);
-
-            int count = range.ExcludeEnd ? end - begin : end - begin + 1;
             return (count &lt; 0) ? self.CreateInstance().TaintBy(self) : GetSubstring(self, begin, count);
         }
 
         [RubyMethod(&quot;[]&quot;)]
         [RubyMethod(&quot;slice&quot;)]
         public static MutableString GetSubstring(MutableString/*!*/ self, [NotNull]MutableString/*!*/ searchStr) {
-            if (self.IndexOf(searchStr) != -1) {
-                return searchStr.Clone();
-            } else {
-                return null;
-            }
+            return (self.IndexOf(searchStr) != -1) ? searchStr.Clone() : null;
         }
 
         [RubyMethod(&quot;[]&quot;)]
@@ -622,8 +614,7 @@ namespace IronRuby.Builtins {
                 return null;
             }
 
-            string result = match.Value;
-            return (result.Length == 0) ? null : self.CreateInstance().TaintBy(self).Append(result).TaintBy(regex, scope);
+            return self.CreateInstance().TaintBy(self).Append(self, match.Index, match.Length).TaintBy(regex, scope);
         }
 
         [RubyMethod(&quot;[]&quot;)]
@@ -634,12 +625,13 @@ namespace IronRuby.Builtins {
                 return self.CreateInstance().TaintBy(self).TaintBy(regex, scope);
             }
 
-            Group group = MatchRegexp(scope, self, regex, occurrance);
-            if (group == null || !group.Success) {
+            MatchData match = RegexpOps.Match(scope, regex, self);
+            if (match == null || !RegexpOps.NormalizeGroupIndex(ref occurrance, match.GroupCount)) {
                 return null;
             }
 
-            return self.CreateInstance().Append(group.Value).TaintBy(self).TaintBy(regex, scope);
+            MutableString result = match.AppendGroupValue(occurrance, self.CreateInstance());
+            return result != null ? result.TaintBy(regex, scope) : null;
         }
 
         #endregion
@@ -746,11 +738,11 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;[]=&quot;)]
-        public static MutableString ReplaceSubstring(MutableString/*!*/ self,
+        public static MutableString ReplaceSubstring(RubyContext/*!*/ context, MutableString/*!*/ self,
             [NotNull]RubyRegex/*!*/ regex, [DefaultProtocol, NotNull]MutableString/*!*/ value) {
-            
-            Match match = regex.Match(self);
-            if (!match.Success) {
+
+            MatchData match = regex.Match(context.KCode, self);
+            if (match == null) {
                 throw RubyExceptions.CreateIndexError(&quot;regexp not matched&quot;);
             }
 
@@ -1225,7 +1217,7 @@ namespace IronRuby.Builtins {
 
             var matchScope = scope.GetInnerMostClosureScope();
             MatchData match = RegexpOps.Match(scope, pattern, input);
-            if (match == null || !match.Success) {
+            if (match == null) {
                 result = null;
                 blockResult = null;
                 matchScope.CurrentMatch = null;
@@ -1236,7 +1228,7 @@ namespace IronRuby.Builtins {
             result = input.Clone();
             matchScope.CurrentMatch = match;
 
-            if (block.Yield(MutableString.Create(match.Value, input.Encoding), out blockResult)) {
+            if (block.Yield(match.GetValue(), out blockResult)) {
                 return true;
             }
 
@@ -1261,7 +1253,7 @@ namespace IronRuby.Builtins {
 
             var matchScope = scope.GetInnerMostClosureScope();
 
-            MatchCollection matches = regex.Matches(input);
+            var matches = regex.Matches(tosConversion.Context.KCode, input);
             if (matches.Count == 0) {
                 result = null;
                 blockResult = null;
@@ -1273,12 +1265,11 @@ namespace IronRuby.Builtins {
             result = input.CreateInstance().TaintBy(input);
             
             int offset = 0;
-            foreach (Match match in matches) {
-                MatchData currentMatch = new MatchData(match, input);
-                matchScope.CurrentMatch = currentMatch;
+            foreach (MatchData match in matches) {
+                matchScope.CurrentMatch = match;
 
                 input.TrackChanges();
-                if (block.Yield(MutableString.Create(match.Value, input.Encoding), out blockResult)) {
+                if (block.Yield(match.GetValue(), out blockResult)) {
                     return true;
                 }
                 if (input.HasChanged) {
@@ -1286,7 +1277,7 @@ namespace IronRuby.Builtins {
                 }
 
                 // resets the $~ scope variable to the last match (skipd if block jumped):
-                matchScope.CurrentMatch = currentMatch;
+                matchScope.CurrentMatch = match;
 
                 MutableString replacement = Protocols.ConvertToString(tosConversion, blockResult);
                 result.TaintBy(replacement);
@@ -1313,32 +1304,35 @@ namespace IronRuby.Builtins {
             }
         }
 
-        private static void AppendReplacementExpression(MutableString input, GroupCollection/*!*/ groups, MutableString/*!*/ result, MutableString/*!*/ replacement) {
+        private static void AppendReplacementExpression(MutableString/*!*/ input, MatchData/*!*/ match, MutableString/*!*/ result, 
+            MutableString/*!*/ replacement) {
+
             int backslashCount = 0;
             for (int i = 0; i &lt; replacement.Length; i++) {
                 char c = replacement.GetChar(i);
-                if (c == '\\')
+                if (c == '\\') {
                     backslashCount++;
-                else if (backslashCount == 0)
+                } else if (backslashCount == 0) {
                     result.Append(c);
-                else {
+                } else {
                     AppendBackslashes(backslashCount, result, 0);
                     // Odd number of \'s + digit means insert replacement expression
                     if ((backslashCount &amp; 1) == 1) {
                         if (Char.IsDigit(c)) {
-                            AppendGroupByIndex(groups, c - '0', backslashCount, result);
+                            AppendGroupByIndex(match, c - '0', result);
                         } else if (c == '&amp;') {
-                            AppendGroupByIndex(groups, groups.Count - 1, backslashCount, result);
+                            AppendGroupByIndex(match, match.GroupCount - 1, result);
                         } else if (c == '`') {
                             // Replace with everything in the input string BEFORE the match
-                            result.Append(input, 0, groups[0].Index);
+                            result.Append(input, 0, match.Index);
                         } else if (c == '\'') {
                             // Replace with everything in the input string AFTER the match
-                            int start = groups[0].Index + groups[0].Length;
-                            result.Append(input, start, input.Length - start);
+                            int start = match.Index + match.Length;
+                            // TODO:
+                            result.Append(input, start, input.GetLength() - start);
                         } else if (c == '+') {
                             // Replace last character in last successful match group
-                            AppendLastCharOfLastMatchGroup(groups, result);
+                            AppendLastCharOfLastMatchGroup(match, result);
                         } else {
                             // unknown escaped replacement char, go ahead and replace untouched
                             result.Append('\\');
@@ -1355,36 +1349,31 @@ namespace IronRuby.Builtins {
             AppendBackslashes(backslashCount, result, 1);
         }
 
-        private static void AppendLastCharOfLastMatchGroup(GroupCollection groups, MutableString result) {
-            int i = groups.Count - 1;
+        private static void AppendLastCharOfLastMatchGroup(MatchData/*!*/ match, MutableString/*!*/ result) {
+            int i = match.GroupCount - 1;
             // move to last successful match group
-            while (i &gt; 0 &amp;&amp; !groups[i].Success) {
+            while (i &gt; 0 &amp;&amp; !match.GroupSuccess(i)) {
                 i--;
             }
 
-            if (i &gt; 0 &amp;&amp; groups[i].Value.Length &gt; 0) {
-                result.Append(groups[i].Value[groups[i].Length - 1]);
+            if (i &gt; 0 &amp;&amp; match.GroupSuccess(i)) {
+                int length = match.GetGroupLength(i);
+                if (length &gt; 0) {
+                   result.Append(match.OriginalString, match.GetGroupStart(i) + length - 1, 1);
+                }
             }
         }
 
-        private static void AppendGroupByIndex(GroupCollection/*!*/ groups, int index, int backslashCount, MutableString/*!*/ result) {
-            if (groups[index].Success) {
-                result.Append(groups[index].Value);
+        private static void AppendGroupByIndex(MatchData/*!*/ match, int index, MutableString/*!*/ result) {
+            var value = match.GetGroupValue(index);
+            if (value != null) {
+                result.Append(value);
             }
         }
 
-        private static void AppendReplacementExpression(MutableString/*!*/ input, MatchData/*!*/ match, MutableString/*!*/ result, MutableString/*!*/ replacement) {
-            AppendReplacementExpression(input, match.Groups, result, replacement);
-        }
-
-        // TODO: we have two overloads right now because we haven't unified Matches to return a List&lt;MatchData&gt; yet ...
-        private static void AppendReplacementExpression(MutableString/*!*/ input, Match/*!*/ match, MutableString/*!*/ result, MutableString/*!*/ replacement) {
-            AppendReplacementExpression(input, match.Groups, result, replacement);
-        }
-
         private static MutableString ReplaceFirst(RubyScope/*!*/ scope, MutableString/*!*/ input, MutableString/*!*/ replacement, RubyRegex/*!*/ pattern) {
             MatchData match = RegexpOps.Match(scope, pattern, input);
-            if (match == null || !match.Success) {
+            if (match == null) {
                 return null;
             }
 
@@ -1407,7 +1396,7 @@ namespace IronRuby.Builtins {
             var matchScope = scope.GetInnerMostClosureScope();
             
             // case of all
-            MatchCollection matches = regex.Matches(input);
+            IList&lt;MatchData&gt; matches = regex.Matches(scope.RubyContext.KCode, input);
             if (matches.Count == 0) {
                 matchScope.CurrentMatch = null;
                 return null;
@@ -1416,7 +1405,7 @@ namespace IronRuby.Builtins {
             MutableString result = input.CreateInstance().TaintBy(input).TaintBy(replacement);
 
             int offset = 0;
-            foreach (Match match in matches) {
+            foreach (MatchData match in matches) {
                 result.Append(input, offset, match.Index - offset);
                 AppendReplacementExpression(input, match, result, replacement);
                 offset = match.Index + match.Length;
@@ -1424,7 +1413,7 @@ namespace IronRuby.Builtins {
 
             result.Append(input, offset, input.Length - offset);
 
-            matchScope.CurrentMatch = new MatchData(matches[matches.Count - 1], input);
+            matchScope.CurrentMatch = matches[matches.Count - 1];
             return result;
         }
 
@@ -1459,7 +1448,8 @@ namespace IronRuby.Builtins {
 
             object blockResult;
             MutableString result;
-            var regex = new RubyRegex(Regex.Escape(matchString.ToString()), RubyRegexOptions.NONE);
+            // TODO:
+            var regex = new RubyRegex(MutableString.CreateMutable(Regex.Escape(matchString.ToString()), matchString.Encoding), RubyRegexOptions.NONE);
 
             return BlockReplaceFirst(tosConversion, scope, self, block, regex, out blockResult, out result) ? blockResult : (result ?? self.Clone());
         }
@@ -1471,7 +1461,8 @@ namespace IronRuby.Builtins {
 
             object blockResult;
             MutableString result;
-            var regex = new RubyRegex(Regex.Escape(matchString.ToString()), RubyRegexOptions.NONE);
+            // TODO:
+            var regex = new RubyRegex(MutableString.CreateMutable(Regex.Escape(matchString.ToString()), matchString.Encoding), RubyRegexOptions.NONE);
 
             self.TrackChanges();
             object r = BlockReplaceAll(tosConversion, scope, self, block, regex, out blockResult, out result) ? blockResult : (result ?? self.Clone());
@@ -1583,122 +1574,114 @@ namespace IronRuby.Builtins {
 
         #region index, rindex
 
+        // encoding aware
         [RubyMethod(&quot;index&quot;)]
         public static object Index(MutableString/*!*/ self, 
             [DefaultProtocol, NotNull]MutableString/*!*/ substring, [DefaultProtocol, Optional]int start) {
 
-            if (!NormalizeStart(self, ref start)) {
+            self.SwitchToCharacters();
+            if (!NormalizeStart(self.GetCharCount(), ref start)) {
                 return null;
             }
+
+            self.RequireCompatibleEncoding(substring);
+            substring.SwitchToCharacters();
+
             int result = self.IndexOf(substring, start);
             return (result != -1) ? ScriptingRuntimeHelpers.Int32ToObject(result) : null;
         }
 
+        // encoding aware
         [RubyMethod(&quot;index&quot;)]
         public static object Index(MutableString/*!*/ self, 
             int character, [DefaultProtocol, Optional]int start) {
 
-            if (!NormalizeStart(self, ref start) || character &lt; 0 || character &gt; 255) {
+            if (!self.IsBinaryEncoded &amp;&amp; !self.Encoding.IsKCoding &amp;&amp; !self.IsAscii()) {
+                throw RubyExceptions.CreateTypeError(&quot;type mismatch: Fixnum given&quot;);
+            }
+
+            if (!NormalizeStart(self.GetByteCount(), ref start) || character &lt; 0 || character &gt; 255) {
                 return null;
             }
+
             int result = self.IndexOf((byte)character, start);
             return (result != -1) ? ScriptingRuntimeHelpers.Int32ToObject(result) : null;
         }
 
+        // encoding aware
         [RubyMethod(&quot;index&quot;)]
         public static object Index(RubyScope/*!*/ scope, MutableString/*!*/ self, 
             [NotNull]RubyRegex/*!*/ regex, [DefaultProtocol, Optional]int start) {
 
-            if (!NormalizeStart(self, ref start)) {
-                return null;
-            }
-
-            var matchScope = scope.GetInnerMostClosureScope();
-
-            Match match = regex.Match(self, start);
-            if (match.Success) {
-                matchScope.CurrentMatch = new MatchData(match, self);
-                return ScriptingRuntimeHelpers.Int32ToObject(match.Index);
-            } else {
-                matchScope.CurrentMatch = null;
-                return null;
-            }
+            MatchData match = regex.Match(scope.RubyContext.KCode, self, start);
+            scope.GetInnerMostClosureScope().CurrentMatch = match;
+            return (match != null) ? ScriptingRuntimeHelpers.Int32ToObject(match.Index) : null;
         }
 
+        // encoding aware
         [RubyMethod(&quot;rindex&quot;)]
-        public static object ReverseIndex(MutableString/*!*/ self,
-            [DefaultProtocol, NotNull]MutableString/*!*/ substring) {
-            return ReverseIndex(self, substring, self.Length);
-        }
+        public static object LastIndexOf(MutableString/*!*/ self,
+            [DefaultProtocol, NotNull]MutableString/*!*/ substring, [DefaultProtocol, DefaultParameterValue(Int32.MaxValue)]int start) {
 
-        [RubyMethod(&quot;rindex&quot;)]
-        public static object ReverseIndex(MutableString/*!*/ self,
-            [DefaultProtocol, NotNull]MutableString/*!*/ substring, [DefaultProtocol]int start) {
-            start = NormalizeIndex(self, start);
+            self.SwitchToCharacters();
+            int charCount = self.GetCharCount();
 
+            start = IListOps.NormalizeIndex(charCount, start);
             if (start &lt; 0) {
                 return null;
             }
 
             if (substring.IsEmpty) {
-                return ScriptingRuntimeHelpers.Int32ToObject((start &gt;= self.Length) ? self.Length : start);
+                return ScriptingRuntimeHelpers.Int32ToObject((start &gt;= charCount) ? charCount : start);
             }
 
-            start += substring.Length - 1;
+            self.RequireCompatibleEncoding(substring);
+            substring.SwitchToCharacters();
+            int subCharCount = substring.GetCharCount();
 
-            if (start &gt;= self.Length) {
-                start = self.Length - 1;
+            // LastIndexOf has CLR semantics: no characters of the substring are matched beyond start position.
+            // Hence we need to increase start by the length of the substring - 1.
+            if (start &gt; charCount - subCharCount) {
+                start = charCount - 1;
+            } else {
+                start += subCharCount - 1;
             }
 
             int result = self.LastIndexOf(substring, start);
             return (result != -1) ? ScriptingRuntimeHelpers.Int32ToObject(result) : null;
         }
 
+        // encoding aware
         [RubyMethod(&quot;rindex&quot;)]
-        public static object ReverseIndex(MutableString/*!*/ self,
-            int character, [DefaultProtocol, DefaultParameterValue(-1)]int start) {
+        public static object LastIndexOf(MutableString/*!*/ self,
+            int character, [DefaultProtocol, DefaultParameterValue(Int32.MaxValue)]int start) {
+
+            if (!self.IsBinaryEncoded &amp;&amp; !self.Encoding.IsKCoding &amp;&amp; !self.IsAscii()) {
+                throw RubyExceptions.CreateTypeError(&quot;type mismatch: Fixnum given&quot;);
+            }
 
-            start = NormalizeIndex(self, start);
+            int byteCount = self.GetByteCount();
+            start = IListOps.NormalizeIndex(byteCount, start);
             if (start &lt; 0 || character &lt; 0 || character &gt; 255) {
                 return null;
             }
 
-            if (start &gt;= self.Length) {
-                start = self.Length - 1;
+            if (start &gt;= byteCount) {
+                start = byteCount - 1;
             }
             
             int result = self.LastIndexOf((byte)character, start);
             return (result != -1) ? ScriptingRuntimeHelpers.Int32ToObject(result) : null;
         }
 
-        // TODO: note that .NET regex semantics don't line up well in these cases - so some specs do fail. There are 4 failures in rindex that are due to regex differences.
-
-        [RubyMethod(&quot;rindex&quot;)]
-        public static object ReverseIndex(RubyScope/*!*/ scope, MutableString/*!*/ self,
-            [NotNull]RubyRegex/*!*/ regex) {
-            return ReverseIndex(scope, self, regex, self.Length);
-        }
-
+        // encoding aware
         [RubyMethod(&quot;rindex&quot;)]
-        public static object ReverseIndex(RubyScope/*!*/ scope, MutableString/*!*/ self, 
-            [NotNull]RubyRegex/*!*/ regex, [DefaultProtocol]int start) {
-
-            start = NormalizeIndex(self, start);
-            if (start &lt; 0) {
-                return null;
-            }
-            start = (start &gt; self.Length) ? self.Length : start;
+        public static object LastIndexOf(RubyScope/*!*/ scope, MutableString/*!*/ self, 
+            [NotNull]RubyRegex/*!*/ regex, [DefaultProtocol, DefaultParameterValue(Int32.MaxValue)]int start) {
 
-            var matchScope = scope.GetInnerMostClosureScope();
-            
-            Match match = regex.ReverseMatch(self, start);
-            if (match.Success) {
-                matchScope.CurrentMatch = new MatchData(match, self);
-                return ScriptingRuntimeHelpers.Int32ToObject(match.Index);
-            } else {
-                matchScope.CurrentMatch = null;
-                return null;
-            }
+            MatchData match = regex.LastMatch(scope.RubyContext.KCode, self, start);
+            scope.GetInnerMostClosureScope().CurrentMatch = match;
+            return (match != null) ? ScriptingRuntimeHelpers.Int32ToObject(match.Index) : null;
         }
 
         // Start in range ==&gt; search range from the first character towards the end.
@@ -1708,9 +1691,9 @@ namespace IronRuby.Builtins {
         // [0, length)      ==&gt; [start, length)
         // start &gt; length   ==&gt; false
         //
-        private static bool NormalizeStart(MutableString/*!*/ self, ref int start) {
-            start = NormalizeIndex(self, start);
-            if (start &lt; 0 || start &gt; self.Length) {
+        private static bool NormalizeStart(int length, ref int start) {
+            start = IListOps.NormalizeIndex(length, start);
+            if (start &lt; 0 || start &gt; length) {
                 return false;
             }
             return true;
@@ -1771,8 +1754,9 @@ namespace IronRuby.Builtins {
             BitArray map = new RangeParser(ranges).Parse();
             int count = 0;
             for (int i = 0; i &lt; self.Length; i++) {
-                if (map.Get(self.GetChar(i)))
+                if (map.Get(self.GetChar(i))) {
                     count++;
+                }
             }
             return ScriptingRuntimeHelpers.Int32ToObject(count);
         }
@@ -1807,12 +1791,7 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;insert&quot;)]
         public static MutableString Insert(MutableString/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol, NotNull]MutableString/*!*/ value) {
-            int offset = start &lt; 0 ? start + self.Length + 1 : start;
-            if (offset &gt; self.Length || offset &lt; 0) {
-                throw RubyExceptions.CreateIndexError(String.Format(&quot;index {0} out of string&quot;, start));
-            }
-
-            return self.Insert(offset, value).TaintBy(value);
+            return self.Insert(NormalizeInsertIndex(start, self.GetLength()), value).TaintBy(value);
         }
 
         #endregion
@@ -1858,7 +1837,7 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;scan&quot;)]
         public static RubyArray/*!*/ Scan(RubyScope/*!*/ scope, MutableString/*!*/ self, [DefaultProtocol, NotNull]RubyRegex/*!*/ regex) {
-            MatchCollection matches = regex.Matches(self);
+            IList&lt;MatchData&gt; matches = regex.Matches(scope.RubyContext.KCode, self);
 
             var matchScope = scope.GetInnerMostClosureScope();
             
@@ -1868,51 +1847,46 @@ namespace IronRuby.Builtins {
                 return result;
             } 
 
-            foreach (Match match in matches) {
+            foreach (MatchData match in matches) {
                 result.Add(MatchToScanResult(scope, self, regex, match));
             }
 
-            matchScope.CurrentMatch = new MatchData(matches[matches.Count - 1], self);
+            matchScope.CurrentMatch = matches[matches.Count - 1];
             return result;
         }
 
         [RubyMethod(&quot;scan&quot;)]
         public static object/*!*/ Scan(RubyScope/*!*/ scope, [NotNull]BlockParam/*!*/ block, MutableString/*!*/ self, [DefaultProtocol, NotNull]RubyRegex regex) {
             var matchScope = scope.GetInnerMostClosureScope();
-            
-            MatchCollection matches = regex.Matches(self);
+
+            IList&lt;MatchData&gt; matches = regex.Matches(scope.RubyContext.KCode, self);
             if (matches.Count == 0) {
                 matchScope.CurrentMatch = null;
                 return self;
             } 
 
-            foreach (Match match in matches) {
-                var currentMatch = new MatchData(match, self);
-
-                matchScope.CurrentMatch = currentMatch;
+            foreach (MatchData match in matches) {
+                matchScope.CurrentMatch = match;
 
                 object blockResult;
                 if (block.Yield(MatchToScanResult(scope, self, regex, match), out blockResult)) {
                     return blockResult;
                 }
 
-                // resets the $~ scope variable to the last match (skipd if block jumped):
-                matchScope.CurrentMatch = currentMatch;
+                // resets the $~ scope variable to the last match (skipped if block jumped):
+                matchScope.CurrentMatch = match;
             }
             return self;
         }
 
-        private static object MatchToScanResult(RubyScope/*!*/ scope, MutableString/*!*/ self, RubyRegex/*!*/ regex, Match/*!*/ match) {
-            if (match.Groups.Count == 1) {
-                return MutableString.Create(match.Value, self.Encoding).TaintBy(self).TaintBy(regex, scope);
+        private static object MatchToScanResult(RubyScope/*!*/ scope, MutableString/*!*/ self, RubyRegex/*!*/ regex, MatchData/*!*/ match) {
+            if (match.GroupCount == 1) {
+                return match.GetValue().TaintBy(regex, scope);
             } else {
-                var result = new RubyArray(match.Groups.Count - 1);
-                for (int i = 1; i &lt; match.Groups.Count; i++) {
-                    if (match.Groups[i].Success) {
-                        result.Add(MutableString.Create(match.Groups[i].Value, self.Encoding).TaintBy(self).TaintBy(regex, scope));
-                    } else {
-                        result.Add(null);
-                    }
+                var result = new RubyArray(match.GroupCount - 1);
+                for (int i = 1; i &lt; match.GroupCount; i++) {
+                    MutableString value = match.GetGroupValue(i);
+                    result.Add(value != null ? value.TaintBy(regex, scope) : value);
                 }
                 return result;
             }
@@ -2021,10 +1995,11 @@ namespace IronRuby.Builtins {
         // InternalSplit method which also flows taint
 
         private static int IndexOf(MutableString/*!*/ str, MutableString/*!*/ separator, int index) {
-            if (separator.Length &gt; 0)
+            if (separator.Length &gt; 0) {
                 return str.IndexOf(separator, index);
-            else
+            } else {
                 return index + 1;
+            }
         }
 
         private static RubyArray/*!*/ WhitespaceSplit(MutableString/*!*/ self, int maxComponents) {
@@ -2060,7 +2035,6 @@ namespace IronRuby.Builtins {
             int i = 0;
             int next;
             while (maxComponents &gt; 1 &amp;&amp; i &lt; selfLength &amp;&amp; (next = IndexOf(self, separator, i)) != -1) {
-
                 if (next &gt; i || keepEmpty) {
                     result.Add(self.CreateInstance().Append(self, i, next - i).TaintBy(self));
                     maxComponents--;
@@ -2136,7 +2110,7 @@ namespace IronRuby.Builtins {
 
             if (limit == 0) {
                 // suppress trailing empty fields
-                RubyArray array = MakeRubyArray(self, regexp.Split(self));
+                RubyArray array = MakeRubyArray(self, regexp.Split(stringCast.Context.KCode, self));
                 while (array.Count != 0 &amp;&amp; ((MutableString)array[array.Count - 1]).Length == 0) {
                     array.RemoveAt(array.Count - 1);
                 }
@@ -2148,10 +2122,10 @@ namespace IronRuby.Builtins {
                 return result;
             } else if (limit &lt; 0) {
                 // does not suppress trailing fields when negative 
-                return MakeRubyArray(self, regexp.Split(self));
+                return MakeRubyArray(self, regexp.Split(stringCast.Context.KCode, self));
             } else {
                 // limit &gt; 1 limits to N fields
-                return MakeRubyArray(self, regexp.Split(self, limit));
+                return MakeRubyArray(self, regexp.Split(stringCast.Context.KCode, self, limit));
             }
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,27 @@ using Microsoft.Scripting.Utils;
 namespace IronRuby.Builtins {
     [RubyClass(&quot;Regexp&quot;, Extends = typeof(RubyRegex), Inherits = typeof(Object)), Includes(typeof(Enumerable))]
     public static class RegexpOps {
+        #region Helpers
+
+        internal static bool NormalizeGroupIndex(ref int index, int groupCount) {
+            // Normalize index against # Groups in Match
+            if (index &lt; 0) {
+                index += groupCount;
+                // Cannot refer to zero using negative indices 
+                if (index == 0) {
+                    return false;
+                }
+            }
+
+            if (index &lt; 0 || index &gt; groupCount) {
+                return false;
+            }
+
+            return true;
+        }
+
+        #endregion
+
         #region constructors, compile
 
         [RubyConstructor]
@@ -69,7 +90,7 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;initialize&quot;, RubyMethodAttributes.PrivateInstance)]
         public static RubyRegex/*!*/ Reinitialize(RubyRegex/*!*/ self, [NotNull]RubyRegex/*!*/ other) {
-            self.Set(other.GetPattern(), other.Options);
+            self.Set(other.Pattern, other.Options);
             return self;
         }
 
@@ -175,8 +196,8 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;kcode&quot;)]
-        public static MutableString GetEncoding(RubyRegex/*!*/ self) {
-            switch (self.Options &amp; RubyRegexOptions.EncodingMask) {
+        public static MutableString GetKCode(RubyRegex/*!*/ self) {
+            switch (self.Options &amp; RubyRegexOptions.CompleteEncodingMask) {
                 case RubyRegexOptions.NONE: return null;
                 case RubyRegexOptions.EUC: return MutableString.CreateAscii(&quot;euc&quot;);
                 case RubyRegexOptions.FIXED: return MutableString.CreateAscii(&quot;none&quot;);
@@ -186,6 +207,11 @@ namespace IronRuby.Builtins {
             }
         }
 
+        [RubyMethod(&quot;encoding&quot;)]
+        public static RubyEncoding/*!*/ GetEncoding(RubyRegex/*!*/ self) {
+            return self.Encoding;
+        }
+
         [RubyMethod(&quot;casefold?&quot;)]
         public static bool IsCaseInsensitive(RubyRegex/*!*/ self) {
             return (self.Options &amp; RubyRegexOptions.IgnoreCase) != 0;
@@ -200,7 +226,7 @@ namespace IronRuby.Builtins {
         public static int GetHash(RubyRegex/*!*/ self) {
             return self.GetHashCode();
         }
-        
+
         [RubyMethod(&quot;==&quot;), RubyMethod(&quot;eql?&quot;)]
         public static bool Equals(RubyRegex/*!*/ self, object other) {
             return false;
@@ -220,12 +246,7 @@ namespace IronRuby.Builtins {
         [RubyMethod(&quot;===&quot;)]
         public static bool CaseCompare(ConversionStorage&lt;MutableString&gt;/*!*/ stringTryCast, RubyScope/*!*/ scope, RubyRegex/*!*/ self, object obj) {
             MutableString str = Protocols.TryCastToString(stringTryCast, obj);
-            if (str == null) {
-                return false;
-            } 
-            
-            MatchData match = Match(scope, self, str);
-            return (match != null &amp;&amp; match.Success) ? true : false;
+            return str != null &amp;&amp; Match(scope, self, str) != null;
         }
 
         [RubyMethod(&quot;~&quot;)]
@@ -235,7 +256,7 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;source&quot;)]
         public static MutableString/*!*/ Source(RubyRegex/*!*/ self) {
-            return self.GetPattern();
+            return self.Pattern.Clone();
         }
 
         [RubyMethod(&quot;escape&quot;, RubyMethodAttributes.PublicSingleton)]
@@ -251,14 +272,14 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;last_match&quot;, RubyMethodAttributes.PublicSingleton)]
         public static MutableString/*!*/ LastMatch(RubyScope/*!*/ scope, RubyClass/*!*/ self, [DefaultProtocol]int groupIndex) {
-            return scope.GetInnerMostClosureScope().CurrentMatch.GetGroupValue(scope.RubyContext, groupIndex);
+            return scope.GetInnerMostClosureScope().CurrentMatch.GetGroupValue(groupIndex);
         }
 
         [RubyMethod(&quot;union&quot;, RubyMethodAttributes.PublicSingleton)]
         public static RubyRegex/*!*/ Union(ConversionStorage&lt;MutableString&gt;/*!*/ stringCast, RubyClass/*!*/ self, [NotNull]params object[]/*!*/ strings) {
 
             if (strings.Length == 0) {
-                return new RubyRegex(&quot;(?!)&quot;, RubyRegexOptions.NONE);
+                return new RubyRegex(MutableString.CreateAscii(&quot;(?!)&quot;), RubyRegexOptions.NONE);
             }
 
             MutableString result = MutableString.CreateMutable(RubyEncoding.Binary);</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyRegexOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -57,5 +57,10 @@ namespace IronRuby.Builtins {
 
             return str.GetChar(0);
         }
+
+        [RubyMethod(&quot;inspect&quot;)]
+        public static MutableString/*!*/ Inspect(char self) {
+            return MutableString.CreateMutable(&quot;'&quot; + self + &quot;' (Char)&quot;, RubyEncoding.UTF8);
+        }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Extensions/CharOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -24,11 +24,18 @@ using Microsoft.Scripting;
 using System.Runtime.CompilerServices;
 using IronRuby.Runtime.Calls;
 using Microsoft.Scripting.Utils;
+using System.Text.RegularExpressions;
+using System.Diagnostics;
 
 namespace IronRuby.Builtins {
 
     [RubyClass(Extends = typeof(string), Restrictions = ModuleRestrictions.None)]
     [Includes(typeof(ClrString), typeof(Enumerable), typeof(Comparable))]
+    [HideMethod(&quot;[]&quot;)]
+    [HideMethod(&quot;==&quot;)]
+    [HideMethod(&quot;insert&quot;)]
+    [HideMethod(&quot;split&quot;)]
+    [HideMethod(&quot;clone&quot;)]
     public static class ClrStringOps {
         [RubyConstructor]
         public static string/*!*/ Create(RubyClass/*!*/ self, [DefaultProtocol]MutableString/*!*/ str) {
@@ -125,7 +132,72 @@ namespace IronRuby.Builtins {
 
         #endregion
 
-        #region  TODO: [], slice
+        #region [], slice
+
+        [RubyMethod(&quot;[]&quot;)]
+        [RubyMethod(&quot;slice&quot;)]
+        public static object GetChar(string/*!*/ self, [DefaultProtocol]int index) {
+            return MutableStringOps.InExclusiveRangeNormalized(self.Length, ref index) ? RubyUtils.CharToObject(self[index]) : null;
+        }
+
+        [RubyMethod(&quot;[]&quot;)]
+        [RubyMethod(&quot;slice&quot;)]
+        public static string GetSubstring(string/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol]int count) {
+            if (!MutableStringOps.NormalizeSubstringRange(self.Length, ref start, ref count)) {
+                return (start == self.Length) ? self : null;
+            }
+
+            return self.Substring(start, count);
+        }
+
+        [RubyMethod(&quot;[]&quot;)]
+        [RubyMethod(&quot;slice&quot;)]
+        public static string GetSubstring(ConversionStorage&lt;int&gt;/*!*/ fixnumCast, string/*!*/ self, [NotNull]Range/*!*/ range) {
+            int begin, count;
+            if (!MutableStringOps.NormalizeSubstringRange(fixnumCast, range, self.Length, out begin, out count)) {
+                return null;
+            }
+            return (count &lt; 0) ? self : GetSubstring(self, begin, count);
+        }
+
+        [RubyMethod(&quot;[]&quot;)]
+        [RubyMethod(&quot;slice&quot;)]
+        public static string GetSubstring(string/*!*/ self, [NotNull]string/*!*/ searchStr) {
+            return (self.IndexOf(searchStr) != -1) ? searchStr : null;
+        }
+
+        [RubyMethod(&quot;[]&quot;)]
+        [RubyMethod(&quot;slice&quot;)]
+        public static string GetSubstring(RubyScope/*!*/ scope, string/*!*/ self, [NotNull]RubyRegex/*!*/ regex) {
+            if (regex.IsEmpty) {
+                return String.Empty;
+            }
+
+            // TODO (opt): don't create a new mutable string:
+            MatchData match = RegexpOps.Match(scope, regex, MutableString.Create(self, RubyEncoding.UTF8));
+            if (match == null) {
+                return null;
+            }
+
+            var result = match.GetValue();
+            return result != null ? result.ToString() : null;
+        }
+
+        [RubyMethod(&quot;[]&quot;)]
+        [RubyMethod(&quot;slice&quot;)]
+        public static string GetSubstring(RubyScope/*!*/ scope, string/*!*/ self, [NotNull]RubyRegex/*!*/ regex, [DefaultProtocol]int occurrance) {
+            if (regex.IsEmpty) {
+                return String.Empty;
+            }
+
+            MatchData match = RegexpOps.Match(scope, regex, MutableString.Create(self, RubyEncoding.UTF8));
+            if (match == null || !RegexpOps.NormalizeGroupIndex(ref occurrance, match.GroupCount)) {
+                return null;
+            }
+
+            MutableString result = match.GetGroupValue(occurrance);
+            return result != null ? result.ToString() : null;
+        }
 
         #endregion
 
@@ -187,6 +259,8 @@ namespace IronRuby.Builtins {
         #endregion
 
         #region TODO: index, rindex
+
+
         #endregion
 
         #region TODO: delete
@@ -195,11 +269,21 @@ namespace IronRuby.Builtins {
         #region TODO: count
         #endregion
 
-        #region TODO: include?
+        #region include?
+
+        [RubyMethod(&quot;include?&quot;)]
+        public static bool Include(string/*!*/ str, [DefaultProtocol, NotNull]string/*!*/ subString) {
+            return str.IndexOf(subString) != -1;
+        }
 
         #endregion
 
-        #region TODO: insert
+        #region insert
+
+        [RubyMethod(&quot;insert&quot;)]
+        public static string Insert(string/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol, NotNull]string/*!*/ value) {
+            return self.Insert(MutableStringOps.NormalizeInsertIndex(start, self.Length), value);
+        }
 
         #endregion
 
@@ -230,7 +314,29 @@ namespace IronRuby.Builtins {
         #region TODO: succ
         #endregion
 
-        #region TODO: split
+        #region split
+
+        // TODO: return an array of CLR strings, not mutable strings
+
+        [RubyMethod(&quot;split&quot;)]
+        public static RubyArray/*!*/ Split(ConversionStorage&lt;MutableString&gt;/*!*/ stringCast, RubyScope/*!*/ scope, string/*!*/ self) {
+            return MutableStringOps.Split(stringCast, scope, MutableString.Create(self, RubyEncoding.UTF8), (MutableString)null, 0);
+        }
+
+        [RubyMethod(&quot;split&quot;)]
+        public static RubyArray/*!*/ Split(ConversionStorage&lt;MutableString&gt;/*!*/ stringCast, RubyScope/*!*/ scope, string/*!*/ self,
+            [DefaultProtocol]string separator, [DefaultProtocol, Optional]int limit) {
+
+            return MutableStringOps.Split(stringCast, scope, MutableString.Create(self, RubyEncoding.UTF8), MutableString.Create(separator, RubyEncoding.UTF8), limit);
+        }
+
+        [RubyMethod(&quot;split&quot;)]
+        public static RubyArray/*!*/ Split(ConversionStorage&lt;MutableString&gt;/*!*/ stringCast, RubyScope/*!*/ scope, string/*!*/ self, 
+            [NotNull]RubyRegex/*!*/ regexp, [DefaultProtocol, Optional]int limit) {
+
+            return MutableStringOps.Split(stringCast, scope, MutableString.Create(self, RubyEncoding.UTF8), regexp, limit);
+        }
+
         #endregion
 
         #region TODO: strip, lstrip, rstrip
@@ -301,7 +407,22 @@ namespace IronRuby.Builtins {
         #region TODO: upto
         #endregion
 
-        #region TODO: replace, reverse
+        #region replace, reverse
+
+        // Ruby replace is a mutating operation, we fallback to System.String::Replace.
+
+        [RubyMethod(&quot;reverse&quot;)]
+        public static string/*!*/ GetReversed(string/*!*/ self) {
+            // TODO: surrogates
+            StringBuilder result = new StringBuilder(self.Length);
+            result.Length = self.Length;
+            for (int i = 0; i &lt; self.Length; i++) {
+                result[i] = self[self.Length - 1 - i];
+            }
+
+            return result.ToString();
+        }
+
         #endregion
 
         #region TODO: tr, tr_s</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Extensions/ClrStringOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -67,7 +67,7 @@ namespace IronRuby.Builtins {
             // Skipped primitive: Kernel
             DefineGlobalModule(&quot;Marshal&quot;, typeof(IronRuby.Builtins.RubyMarshal), 0x00000107, null, LoadMarshal_Class, LoadMarshal_Constants, IronRuby.Builtins.RubyModule.EmptyArray);
             DefineGlobalModule(&quot;Math&quot;, typeof(IronRuby.Builtins.RubyMath), 0x00000107, LoadMath_Instance, LoadMath_Class, LoadMath_Constants, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendClass(typeof(Microsoft.Scripting.Actions.TypeTracker), null, LoadMicrosoft__Scripting__Actions__TypeTracker_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendClass(typeof(Microsoft.Scripting.Actions.TypeTracker), 0x00000000, null, LoadMicrosoft__Scripting__Actions__TypeTracker_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
             DefineGlobalModule(&quot;ObjectSpace&quot;, typeof(IronRuby.Builtins.ObjectSpace), 0x00000107, null, LoadObjectSpace_Class, null, IronRuby.Builtins.RubyModule.EmptyArray);
             IronRuby.Builtins.RubyModule def42 = DefineGlobalModule(&quot;Precision&quot;, typeof(IronRuby.Builtins.Precision), 0x00000107, LoadPrecision_Instance, LoadPrecision_Class, null, IronRuby.Builtins.RubyModule.EmptyArray);
             #if !SILVERLIGHT
@@ -76,25 +76,25 @@ namespace IronRuby.Builtins {
             #if !SILVERLIGHT
             DefineGlobalModule(&quot;Signal&quot;, typeof(IronRuby.Builtins.Signal), 0x00000107, null, LoadSignal_Class, null, IronRuby.Builtins.RubyModule.EmptyArray);
             #endif
-            ExtendClass(typeof(System.Type), null, LoadSystem__Type_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendClass(typeof(System.Type), 0x00000000, null, LoadSystem__Type_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
             // Skipped primitive: __ClassSingletonSingleton
             #if !SILVERLIGHT
             object def1 = DefineSingleton(Load__Singleton_ArgFilesSingletonOps_Instance, null, null, def36);
             #endif
             object def9 = DefineSingleton(Load__Singleton_EnvironmentSingletonOps_Instance, null, null, def36);
-            ExtendClass(typeof(Microsoft.Scripting.Actions.TypeGroup), null, LoadMicrosoft__Scripting__Actions__TypeGroup_Instance, null, null, new IronRuby.Builtins.RubyModule[] {def36});
+            ExtendClass(typeof(Microsoft.Scripting.Actions.TypeGroup), 0x00000000, null, LoadMicrosoft__Scripting__Actions__TypeGroup_Instance, null, null, new IronRuby.Builtins.RubyModule[] {def36});
             // Skipped primitive: Object
-            ExtendClass(typeof(System.Char), null, null, null, null, new IronRuby.Builtins.RubyModule[] {def8, def36, def45}, 
+            ExtendClass(typeof(System.Char), 0x00000000, null, LoadSystem__Char_Instance, null, null, new IronRuby.Builtins.RubyModule[] {def8, def36, def45}, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Char, System.Char&gt;(IronRuby.Builtins.CharOps.Create), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Char[], System.Char&gt;(IronRuby.Builtins.CharOps.Create), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.String, System.Char&gt;(IronRuby.Builtins.CharOps.Create), 
                 new Func&lt;IronRuby.Builtins.RubyClass, IronRuby.Builtins.MutableString, System.Char&gt;(IronRuby.Builtins.CharOps.Create)
             );
-            ExtendModule(typeof(System.Collections.Generic.IDictionary&lt;System.Object, System.Object&gt;), LoadSystem__Collections__Generic__IDictionary_Instance, null, null, def36);
-            ExtendModule(typeof(System.Collections.IEnumerable), LoadSystem__Collections__IEnumerable_Instance, null, null, def36);
-            ExtendModule(typeof(System.Collections.IList), LoadSystem__Collections__IList_Instance, null, null, def36);
-            ExtendModule(typeof(System.IComparable), LoadSystem__IComparable_Instance, null, null, def45);
-            ExtendClass(typeof(System.String), null, null, null, null, new IronRuby.Builtins.RubyModule[] {def8, def36, def45}, 
+            ExtendModule(typeof(System.Collections.Generic.IDictionary&lt;System.Object, System.Object&gt;), 0x00000000, LoadSystem__Collections__Generic__IDictionary_Instance, null, null, def36);
+            ExtendModule(typeof(System.Collections.IEnumerable), 0x00000000, LoadSystem__Collections__IEnumerable_Instance, null, null, def36);
+            ExtendModule(typeof(System.Collections.IList), 0x00000000, LoadSystem__Collections__IList_Instance, null, null, def36);
+            ExtendModule(typeof(System.IComparable), 0x00000000, LoadSystem__IComparable_Instance, null, null, def45);
+            ExtendClass(typeof(System.String), 0x00000000, null, LoadSystem__String_Instance, null, null, new IronRuby.Builtins.RubyModule[] {def8, def36, def45}, 
                 new Func&lt;IronRuby.Builtins.RubyClass, IronRuby.Builtins.MutableString, System.String&gt;(IronRuby.Builtins.ClrStringOps.Create), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Char, System.Int32, System.String&gt;(IronRuby.Builtins.ClrStringOps.Create), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Char[], System.String&gt;(IronRuby.Builtins.ClrStringOps.Create), 
@@ -186,7 +186,7 @@ namespace IronRuby.Builtins {
             new Func&lt;IronRuby.Builtins.RubyClass, System.Object, System.Exception&gt;(BuiltinsLibraryInitializer.ExceptionFactory__SignalException));
             IronRuby.Builtins.RubyClass def38 = Context.StandardErrorClass = DefineGlobalClass(&quot;StandardError&quot;, typeof(System.SystemException), 0x00000007, def46, null, null, null, IronRuby.Builtins.RubyModule.EmptyArray, 
             new Func&lt;IronRuby.Builtins.RubyClass, System.Object, System.Exception&gt;(BuiltinsLibraryInitializer.ExceptionFactory__StandardError));
-            ExtendClass(typeof(System.Single), def41, LoadSystem__Single_Instance, LoadSystem__Single_Class, null, new IronRuby.Builtins.RubyModule[] {def42}, 
+            ExtendClass(typeof(System.Single), 0x00000000, def41, LoadSystem__Single_Instance, LoadSystem__Single_Class, null, new IronRuby.Builtins.RubyModule[] {def42}, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.Single&gt;(IronRuby.Builtins.SingleOps.Create)
             );
             DefineGlobalClass(&quot;SystemExit&quot;, typeof(IronRuby.Builtins.SystemExit), 0x00000007, def46, LoadSystemExit_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray, 
@@ -223,42 +223,42 @@ namespace IronRuby.Builtins {
             new Func&lt;IronRuby.Builtins.RubyClass, System.Object, System.Exception&gt;(BuiltinsLibraryInitializer.ExceptionFactory__SecurityError));
             DefineGlobalClass(&quot;SyntaxError&quot;, typeof(IronRuby.Builtins.SyntaxError), 0x00000007, def44, null, null, null, IronRuby.Builtins.RubyModule.EmptyArray, 
             new Func&lt;IronRuby.Builtins.RubyClass, System.Object, System.Exception&gt;(BuiltinsLibraryInitializer.ExceptionFactory__SyntaxError));
-            ExtendClass(typeof(System.Byte), def48, LoadSystem__Byte_Instance, LoadSystem__Byte_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.Byte), 0x00000000, def48, LoadSystem__Byte_Instance, LoadSystem__Byte_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.Byte&gt;(IronRuby.Builtins.ByteOps.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.Byte&gt;(IronRuby.Builtins.ByteOps.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.Byte&gt;(IronRuby.Builtins.ByteOps.InducedFrom)
             );
-            ExtendClass(typeof(System.Decimal), def48, LoadSystem__Decimal_Instance, LoadSystem__Decimal_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.Decimal), 0x00000000, def48, LoadSystem__Decimal_Instance, LoadSystem__Decimal_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.Decimal&gt;(IronRuby.Builtins.DecimalOps.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.Decimal&gt;(IronRuby.Builtins.DecimalOps.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.Decimal&gt;(IronRuby.Builtins.DecimalOps.InducedFrom)
             );
-            ExtendClass(typeof(System.Int16), def48, LoadSystem__Int16_Instance, LoadSystem__Int16_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.Int16), 0x00000000, def48, LoadSystem__Int16_Instance, LoadSystem__Int16_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.Int16&gt;(IronRuby.Builtins.Int16Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.Int16&gt;(IronRuby.Builtins.Int16Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.Int16&gt;(IronRuby.Builtins.Int16Ops.InducedFrom)
             );
-            ExtendClass(typeof(System.Int64), def48, LoadSystem__Int64_Instance, LoadSystem__Int64_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.Int64), 0x00000000, def48, LoadSystem__Int64_Instance, LoadSystem__Int64_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.Int64&gt;(IronRuby.Builtins.Int64Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.Int64&gt;(IronRuby.Builtins.Int64Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.Int64&gt;(IronRuby.Builtins.Int64Ops.InducedFrom)
             );
-            ExtendClass(typeof(System.SByte), def48, LoadSystem__SByte_Instance, LoadSystem__SByte_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.SByte), 0x00000000, def48, LoadSystem__SByte_Instance, LoadSystem__SByte_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.SByte&gt;(IronRuby.Builtins.SByteOps.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.SByte&gt;(IronRuby.Builtins.SByteOps.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.SByte&gt;(IronRuby.Builtins.SByteOps.InducedFrom)
             );
-            ExtendClass(typeof(System.UInt16), def48, LoadSystem__UInt16_Instance, LoadSystem__UInt16_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.UInt16), 0x00000000, def48, LoadSystem__UInt16_Instance, LoadSystem__UInt16_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.UInt16&gt;(IronRuby.Builtins.UInt16Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.UInt16&gt;(IronRuby.Builtins.UInt16Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.UInt16&gt;(IronRuby.Builtins.UInt16Ops.InducedFrom)
             );
-            ExtendClass(typeof(System.UInt32), def48, LoadSystem__UInt32_Instance, LoadSystem__UInt32_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.UInt32), 0x00000000, def48, LoadSystem__UInt32_Instance, LoadSystem__UInt32_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.UInt32&gt;(IronRuby.Builtins.UInt32Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.UInt32&gt;(IronRuby.Builtins.UInt32Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.UInt32&gt;(IronRuby.Builtins.UInt32Ops.InducedFrom)
             );
-            ExtendClass(typeof(System.UInt64), def48, LoadSystem__UInt64_Instance, LoadSystem__UInt64_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
+            ExtendClass(typeof(System.UInt64), 0x00000000, def48, LoadSystem__UInt64_Instance, LoadSystem__UInt64_Class, null, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Int32, System.UInt64&gt;(IronRuby.Builtins.UInt64Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, Microsoft.Scripting.Math.BigInteger, System.UInt64&gt;(IronRuby.Builtins.UInt64Ops.InducedFrom), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Double, System.UInt64&gt;(IronRuby.Builtins.UInt64Ops.InducedFrom)
@@ -2526,6 +2526,15 @@ namespace IronRuby.Builtins {
                 new Func&lt;System.String, System.Int32, System.String&gt;(IronRuby.Builtins.ClrString.Repeat)
             );
             
+            module.DefineLibraryMethod(&quot;[]&quot;, 0x51, 
+                new Func&lt;System.String, System.Int32, System.Object&gt;(IronRuby.Builtins.ClrString.GetChar), 
+                new Func&lt;System.String, System.Int32, System.Int32, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, System.String, IronRuby.Builtins.Range, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;System.String, System.String, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;IronRuby.Runtime.RubyScope, System.String, IronRuby.Builtins.RubyRegex, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;IronRuby.Runtime.RubyScope, System.String, IronRuby.Builtins.RubyRegex, System.Int32, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring)
+            );
+            
             module.DefineLibraryMethod(&quot;+&quot;, 0x51, 
                 new Func&lt;System.String, IronRuby.Builtins.MutableString, System.String&gt;(IronRuby.Builtins.ClrString.Concatenate)
             );
@@ -2570,6 +2579,14 @@ namespace IronRuby.Builtins {
                 new Func&lt;System.String, System.Object&gt;(IronRuby.Builtins.ClrString.ToIntegerHex)
             );
             
+            module.DefineLibraryMethod(&quot;include?&quot;, 0x51, 
+                new Func&lt;System.String, System.String, System.Boolean&gt;(IronRuby.Builtins.ClrString.Include)
+            );
+            
+            module.DefineLibraryMethod(&quot;insert&quot;, 0x51, 
+                new Func&lt;System.String, System.Int32, System.String, System.String&gt;(IronRuby.Builtins.ClrString.Insert)
+            );
+            
             module.DefineLibraryMethod(&quot;inspect&quot;, 0x51, 
                 new Func&lt;System.String, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.ClrString.Inspect)
             );
@@ -2586,10 +2603,29 @@ namespace IronRuby.Builtins {
                 new Func&lt;System.String, System.Object&gt;(IronRuby.Builtins.ClrString.ToIntegerOctal)
             );
             
+            module.DefineLibraryMethod(&quot;reverse&quot;, 0x51, 
+                new Func&lt;System.String, System.String&gt;(IronRuby.Builtins.ClrString.GetReversed)
+            );
+            
             module.DefineLibraryMethod(&quot;size&quot;, 0x51, 
                 new Func&lt;System.String, System.Int32&gt;(IronRuby.Builtins.ClrString.GetLength)
             );
             
+            module.DefineLibraryMethod(&quot;slice&quot;, 0x51, 
+                new Func&lt;System.String, System.Int32, System.Object&gt;(IronRuby.Builtins.ClrString.GetChar), 
+                new Func&lt;System.String, System.Int32, System.Int32, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, System.String, IronRuby.Builtins.Range, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;System.String, System.String, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;IronRuby.Runtime.RubyScope, System.String, IronRuby.Builtins.RubyRegex, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring), 
+                new Func&lt;IronRuby.Runtime.RubyScope, System.String, IronRuby.Builtins.RubyRegex, System.Int32, System.String&gt;(IronRuby.Builtins.ClrString.GetSubstring)
+            );
+            
+            module.DefineLibraryMethod(&quot;split&quot;, 0x51, 
+                new Func&lt;IronRuby.Runtime.ConversionStorage&lt;IronRuby.Builtins.MutableString&gt;, IronRuby.Runtime.RubyScope, System.String, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.ClrString.Split), 
+                new Func&lt;IronRuby.Runtime.ConversionStorage&lt;IronRuby.Builtins.MutableString&gt;, IronRuby.Runtime.RubyScope, System.String, System.String, System.Int32, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.ClrString.Split), 
+                new Func&lt;IronRuby.Runtime.ConversionStorage&lt;IronRuby.Builtins.MutableString&gt;, IronRuby.Runtime.RubyScope, System.String, IronRuby.Builtins.RubyRegex, System.Int32, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.ClrString.Split)
+            );
+            
             module.DefineLibraryMethod(&quot;to_clr_string&quot;, 0x51, 
                 new Func&lt;System.String, System.String&gt;(IronRuby.Builtins.ClrString.ToClrString)
             );
@@ -2729,7 +2765,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;clr_member&quot;, 0x51, 
-                new Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.String, IronRuby.Builtins.RubyMethod&gt;(IronRuby.Builtins.KernelOps.GetClrMember)
+                new Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.Object, System.String, IronRuby.Builtins.RubyMethod&gt;(IronRuby.Builtins.KernelOps.GetClrMember)
             );
             
             module.DefineLibraryMethod(&quot;display&quot;, 0x51, 
@@ -3371,8 +3407,8 @@ namespace IronRuby.Builtins {
         
         private static void LoadMatchData_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
             module.DefineLibraryMethod(&quot;[]&quot;, 0x51, 
-                new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.MatchData, System.Int32, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MatchDataOps.GetGroup), 
-                new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.MatchData, System.Int32, System.Int32, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.MatchDataOps.GetGroup), 
+                new Func&lt;IronRuby.Builtins.MatchData, System.Int32, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MatchDataOps.GetGroup), 
+                new Func&lt;IronRuby.Builtins.MatchData, System.Int32, System.Int32, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.MatchDataOps.GetGroup), 
                 new Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, IronRuby.Builtins.MatchData, IronRuby.Builtins.Range, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.MatchDataOps.GetGroup)
             );
             
@@ -3381,7 +3417,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;captures&quot;, 0x51, 
-                new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.MatchData, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.MatchDataOps.Captures)
+                new Func&lt;IronRuby.Builtins.MatchData, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.MatchDataOps.Captures)
             );
             
             module.DefineLibraryMethod(&quot;end&quot;, 0x51, 
@@ -3413,7 +3449,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;select&quot;, 0x51, 
-                new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, IronRuby.Builtins.MatchData, System.Object&gt;(IronRuby.Builtins.MatchDataOps.Select)
+                new Func&lt;IronRuby.Runtime.BlockParam, IronRuby.Builtins.MatchData, System.Object&gt;(IronRuby.Builtins.MatchDataOps.Select)
             );
             
             module.DefineLibraryMethod(&quot;size&quot;, 0x51, 
@@ -3425,11 +3461,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;to_a&quot;, 0x51, 
-                new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.MatchData, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.MatchDataOps.ToArray)
+                new Func&lt;IronRuby.Builtins.MatchData, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.MatchDataOps.ToArray)
             );
             
             module.DefineLibraryMethod(&quot;to_s&quot;, 0x51, 
-                new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.MatchData, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MatchDataOps.ToS)
+                new Func&lt;IronRuby.Builtins.MatchData, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MatchDataOps.ToS)
             );
             
             module.DefineLibraryMethod(&quot;values_at&quot;, 0x51, 
@@ -4494,6 +4530,10 @@ namespace IronRuby.Builtins {
                 new Func&lt;IronRuby.Builtins.RubyRegex, System.Boolean&gt;(IronRuby.Builtins.RegexpOps.IsCaseInsensitive)
             );
             
+            module.DefineLibraryMethod(&quot;encoding&quot;, 0x51, 
+                new Func&lt;IronRuby.Builtins.RubyRegex, IronRuby.Builtins.RubyEncoding&gt;(IronRuby.Builtins.RegexpOps.GetEncoding)
+            );
+            
             module.DefineLibraryMethod(&quot;eql?&quot;, 0x51, 
                 new Func&lt;IronRuby.Builtins.RubyRegex, System.Object, System.Boolean&gt;(IronRuby.Builtins.RegexpOps.Equals), 
                 new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.RubyRegex, IronRuby.Builtins.RubyRegex, System.Boolean&gt;(IronRuby.Builtins.RegexpOps.Equals)
@@ -4516,7 +4556,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;kcode&quot;, 0x51, 
-                new Func&lt;IronRuby.Builtins.RubyRegex, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.RegexpOps.GetEncoding)
+                new Func&lt;IronRuby.Builtins.RubyRegex, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.RegexpOps.GetKCode)
             );
             
             module.DefineLibraryMethod(&quot;match&quot;, 0x51, 
@@ -4597,7 +4637,7 @@ namespace IronRuby.Builtins {
                 new Func&lt;IronRuby.Builtins.MutableString, System.Int32, System.Int32, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.ReplaceSubstring), 
                 new Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, IronRuby.Builtins.MutableString, IronRuby.Builtins.Range, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.ReplaceSubstring), 
                 new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.ReplaceSubstring), 
-                new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.RubyRegex, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.ReplaceSubstring)
+                new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.MutableString, IronRuby.Builtins.RubyRegex, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.ReplaceSubstring)
             );
             
             module.DefineLibraryMethod(&quot;+&quot;, 0x51, 
@@ -4814,11 +4854,9 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;rindex&quot;, 0x51, 
-                new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString, System.Object&gt;(IronRuby.Builtins.MutableStringOps.ReverseIndex), 
-                new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString, System.Int32, System.Object&gt;(IronRuby.Builtins.MutableStringOps.ReverseIndex), 
-                new Func&lt;IronRuby.Builtins.MutableString, System.Int32, System.Int32, System.Object&gt;(IronRuby.Builtins.MutableStringOps.ReverseIndex), 
-                new Func&lt;IronRuby.Runtime.RubyScope, IronRuby.Builtins.MutableString, IronRuby.Builtins.RubyRegex, System.Object&gt;(IronRuby.Builtins.MutableStringOps.ReverseIndex), 
-                new Func&lt;IronRuby.Runtime.RubyScope, IronRuby.Builtins.MutableString, IronRuby.Builtins.RubyRegex, System.Int32, System.Object&gt;(IronRuby.Builtins.MutableStringOps.ReverseIndex)
+                new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString, System.Int32, System.Object&gt;(IronRuby.Builtins.MutableStringOps.LastIndexOf), 
+                new Func&lt;IronRuby.Builtins.MutableString, System.Int32, System.Int32, System.Object&gt;(IronRuby.Builtins.MutableStringOps.LastIndexOf), 
+                new Func&lt;IronRuby.Runtime.RubyScope, IronRuby.Builtins.MutableString, IronRuby.Builtins.RubyRegex, System.Int32, System.Object&gt;(IronRuby.Builtins.MutableStringOps.LastIndexOf)
             );
             
             module.DefineLibraryMethod(&quot;rjust&quot;, 0x51, 
@@ -5129,6 +5167,13 @@ namespace IronRuby.Builtins {
             
         }
         
+        private static void LoadSystem__Char_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
+            module.DefineLibraryMethod(&quot;inspect&quot;, 0x51, 
+                new Func&lt;System.Char, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.CharOps.Inspect)
+            );
+            
+        }
+        
         private static void LoadSystem__Collections__Generic__IDictionary_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
             module.DefineLibraryMethod(&quot;[]&quot;, 0x51, 
                 new Func&lt;IronRuby.Runtime.RubyContext, System.Collections.Generic.IDictionary&lt;System.Object, System.Object&gt;, System.Object, System.Object&gt;(IronRuby.Builtins.IDictionaryOps.GetElement)
@@ -5705,6 +5750,14 @@ namespace IronRuby.Builtins {
             LoadIronRuby__Clr__Float_Class(module);
         }
         
+        private static void LoadSystem__String_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
+            module.HideMethod(&quot;[]&quot;);
+            module.HideMethod(&quot;==&quot;);
+            module.HideMethod(&quot;clone&quot;);
+            module.HideMethod(&quot;insert&quot;);
+            module.HideMethod(&quot;split&quot;);
+        }
+        
         private static void LoadSystem__Type_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
             module.DefineLibraryMethod(&quot;to_class&quot;, 0x51, 
                 new Func&lt;IronRuby.Runtime.RubyContext, System.Type, IronRuby.Builtins.RubyClass&gt;(IronRuby.Builtins.TypeOps.ToClass)
@@ -8113,7 +8166,7 @@ namespace IronRuby.StandardLibrary.Enumerator {
             
             
             IronRuby.Builtins.RubyModule def1 = DefineGlobalModule(&quot;Enumerable&quot;, typeof(IronRuby.Builtins.Enumerable), 0x00000000, LoadEnumerable_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
-            ExtendModule(typeof(IronRuby.Builtins.Kernel), LoadIronRuby__Builtins__Kernel_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.Kernel), 0x00000000, LoadIronRuby__Builtins__Kernel_Instance, null, null, IronRuby.Builtins.RubyModule.EmptyArray);
             IronRuby.Builtins.RubyClass def2 = DefineClass(&quot;Enumerable::Enumerator&quot;, typeof(IronRuby.StandardLibrary.Enumerator.Enumerable.Enumerator), 0x00000100, classRef0, LoadEnumerable__Enumerator_Instance, null, null, new IronRuby.Builtins.RubyModule[] {def1}, 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Object, IronRuby.StandardLibrary.Enumerator.Enumerable.Enumerator&gt;(IronRuby.StandardLibrary.Enumerator.Enumerable.Enumerator.Create), 
                 new Func&lt;IronRuby.Builtins.RubyClass, System.Object, System.String, System.Object[], IronRuby.StandardLibrary.Enumerator.Enumerable.Enumerator&gt;(IronRuby.StandardLibrary.Enumerator.Enumerable.Enumerator.Create)
@@ -8223,7 +8276,7 @@ namespace IronRuby.StandardLibrary.BigDecimal {
             DefineGlobalClass(&quot;BigDecimal&quot;, typeof(IronRuby.StandardLibrary.BigDecimal.BigDecimal), 0x00000000, classRef0, LoadBigDecimal_Instance, LoadBigDecimal_Class, LoadBigDecimal_Constants, IronRuby.Builtins.RubyModule.EmptyArray, 
                 new Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Builtins.RubyClass, IronRuby.Builtins.MutableString, System.Int32, IronRuby.StandardLibrary.BigDecimal.BigDecimal&gt;(IronRuby.StandardLibrary.BigDecimal.BigDecimalOps.CreateBigDecimal)
             );
-            ExtendModule(typeof(IronRuby.Builtins.Kernel), LoadIronRuby__Builtins__Kernel_Instance, LoadIronRuby__Builtins__Kernel_Class, null, IronRuby.Builtins.RubyModule.EmptyArray);
+            ExtendModule(typeof(IronRuby.Builtins.Kernel), 0x00000000, LoadIronRuby__Builtins__Kernel_Instance, LoadIronRuby__Builtins__Kernel_Class, null, IronRuby.Builtins.RubyModule.EmptyArray);
         }
         
         private static void LoadBigDecimal_Constants(IronRuby.Builtins.RubyModule/*!*/ module) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -368,9 +368,9 @@ namespace IronRuby.StandardLibrary.ParseTree {
                 public override bool Enter(RegularExpression/*!*/ node) {
                     StringLiteral lit;
                     if (node.Pattern.Count == 0) {
-                        _result = MakeNode(NodeKind.lit, new RubyRegex(String.Empty, node.Options));
+                        _result = MakeNode(NodeKind.lit, new RubyRegex(MutableString.CreateEmpty(), node.Options));
                     } else if (node.Pattern.Count == 1 &amp;&amp; (lit = node.Pattern[0] as StringLiteral) != null) {
-                        _result = MakeNode(NodeKind.lit, lit.GetMutableString(_encoding).ToRegularExpression(node.Options));
+                        _result = MakeNode(NodeKind.lit, new RubyRegex(lit.GetMutableString(_encoding), node.Options));
                     } else {
                         var regex = VisitStringConstructor(node.Pattern, NodeKind.dregx);
                         if (node.Options != RubyRegexOptions.NONE) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/ParseTree/IronRubyParseTreeOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ namespace IronRuby.StandardLibrary.StringScanner {
         private int _currentPosition;
         private int _foundPosition;
         private MutableString _lastMatch;
-        private GroupCollection _lastMatchingGroups;
+        private MatchData _lastMatchingGroups;
 
         #region Construction
 
@@ -118,12 +118,12 @@ namespace IronRuby.StandardLibrary.StringScanner {
                 return null;
             }
             if (subgroup &lt; 0) {
-                subgroup = self.LastMatchingGroups.Count - subgroup;
+                subgroup = self.LastMatchingGroups.GroupCount - subgroup;
             }
-            if (subgroup &gt;= self.LastMatchingGroups.Count) {
+            if (subgroup &gt;= self.LastMatchingGroups.GroupCount) {
                 return null;
             }
-            return MutableString.Create(self.LastMatchingGroups[subgroup].ToString(), self._scanString.Encoding);
+            return self.LastMatchingGroups.GetGroupValue(subgroup);
         }
 
         [RubyMethod(&quot;beginning_of_line?&quot;)]
@@ -391,11 +391,12 @@ namespace IronRuby.StandardLibrary.StringScanner {
         #region Helpers
 
         private bool Match(RubyRegex/*!*/ pattern, bool currentPositionOnly, bool advancePosition) {
-            Match match = pattern.Match(_scanString, _currentPosition);
+            // TODO: KCODE?
+            MatchData match = pattern.Match(null, _scanString, _currentPosition);
             _lastMatch = null;
             _lastMatchingGroups = null;
             _foundPosition = 0;
-            if (!match.Success) {
+            if (match == null) {
                 return false;
             }
             if (currentPositionOnly &amp;&amp; match.Index != _currentPosition) {
@@ -405,7 +406,7 @@ namespace IronRuby.StandardLibrary.StringScanner {
             _foundPosition = match.Index;
             _previousPosition = _currentPosition;
             _lastMatch = _scanString.GetSlice(_foundPosition, match.Length);
-            _lastMatchingGroups = match.Groups;
+            _lastMatchingGroups = match;
             if (advancePosition) {
                 _currentPosition += length;
             }
@@ -444,7 +445,7 @@ namespace IronRuby.StandardLibrary.StringScanner {
             get { return _lastMatch; }
         }
 
-        private GroupCollection LastMatchingGroups {
+        private MatchData LastMatchingGroups {
             get { return _lastMatchingGroups; }
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/StringScanner/StringScanner.cs</filename>
    </modified>
    <modified>
      <diff>@@ -60,7 +60,7 @@ class WIN32OLE
     # we create a wrapper object which does the cast
     load_assembly &quot;Microsoft.Dynamic&quot;
     strongly_typed_enumerable = Microsoft::Scripting::Utils::EnumerableWrapper.new(@com_object)
-    result = strongly_typed_enumerable.each &amp;b
+    result = strongly_typed_enumerable.each(&amp;b)
     (result == strongly_typed_enumerable) ? self : result
   end
   </diff>
      <filename>Merlin/Main/Languages/Ruby/Libs/win32ole.rb</filename>
    </modified>
    <modified>
      <diff>@@ -70,11 +70,11 @@ namespace IronRuby.Builtins {
             return _context.DefineLibraryClass(name, type, instanceTrait, classTrait, constantsInitializer, super, mixins, factories, (RubyModuleAttributes)attributes, _builtin);
         }
 
-        protected RubyClass/*!*/ ExtendClass(Type/*!*/ type, RubyClass super, 
+        protected RubyClass/*!*/ ExtendClass(Type/*!*/ type, int attributes, RubyClass super, 
             Action&lt;RubyModule&gt; instanceTrait, Action&lt;RubyModule&gt; classTrait, Action&lt;RubyModule&gt; constantsInitializer,
             RubyModule/*!*/[]/*!*/ mixins, params Delegate[] factories) {
 
-            return _context.DefineLibraryClass(null, type, instanceTrait, classTrait, constantsInitializer, super, mixins, factories, RubyModuleAttributes.None, _builtin);
+            return _context.DefineLibraryClass(null, type, instanceTrait, classTrait, constantsInitializer, super, mixins, factories, (RubyModuleAttributes)attributes, _builtin);
         }
 
         protected RubyModule/*!*/ DefineGlobalModule(string/*!*/ name, Type/*!*/ type, int attributes,
@@ -101,10 +101,10 @@ namespace IronRuby.Builtins {
             return _context.DefineLibraryModule(name, type, instanceTrait, classTrait, constantsInitializer, mixins, (RubyModuleAttributes)attributes, _builtin);
         }
 
-        protected RubyModule/*!*/ ExtendModule(Type/*!*/ type,
+        protected RubyModule/*!*/ ExtendModule(Type/*!*/ type, int attributes, 
             Action&lt;RubyModule&gt; instanceTrait, Action&lt;RubyModule&gt; classTrait, Action&lt;RubyModule&gt; constantsInitializer,
             params RubyModule/*!*/[]/*!*/ mixins) {
-            return _context.DefineLibraryModule(null, type, instanceTrait, classTrait, constantsInitializer, mixins, RubyModuleAttributes.None, _builtin);
+            return _context.DefineLibraryModule(null, type, instanceTrait, classTrait, constantsInitializer, mixins, (RubyModuleAttributes)attributes, _builtin);
         }
 
         protected object/*!*/ DefineSingleton(Action&lt;RubyModule&gt; instanceTrait, Action&lt;RubyModule&gt; classTrait, Action&lt;RubyModule&gt; constantsInitializer,</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/LibraryInitializer.cs</filename>
    </modified>
    <modified>
      <diff>@@ -17,29 +17,51 @@ using Microsoft.Scripting.Utils;
 using System.Text.RegularExpressions;
 using IronRuby.Runtime;
 using System;
+using System.Diagnostics;
+using System.Text;
 
 namespace IronRuby.Builtins {
-    // TODO: taint from OriginalString, copy original string?
-    public partial class MatchData : IDuplicable {
+    public partial class MatchData : IDuplicable, IRubyObjectState {
+        private const int FrozenFlag = 1;
+        private const int TaintedFlag = 2;
+
+        private int _flags;
         private Match/*!*/ _match;
+        private int[] _kIndices;
         private MutableString/*!*/ _originalString;
 
-        public Match/*!*/ Match { get { return _match; } }
         public MutableString/*!*/ OriginalString { get { return _originalString; } }
+
+        /// &lt;summary&gt;
+        /// The encoding of the match data is always the same as encoding of the input string 
+        /// (even if the regex has a different compatible encoding).
+        /// &lt;/summary&gt;
         public RubyEncoding/*!*/ Encoding { get { return _originalString.Encoding; } }
-        public bool Success { get { return _match.Success; } }
-        public GroupCollection Groups { get { return _match.Groups; } }
-        public int Index { get { return _match.Index; } }
-        public int Length { get { return _match.Length; } }
-        public string Value { get { return _match.Value; } }
+
+        public int GroupCount { 
+            get { return _match.Groups.Count; } 
+        }
+
+        public int Index {
+            get { return GetGroupStart(0); } 
+        }
+
+        public int Length {
+            get { return GetGroupLength(0); } 
+        }
 
         #region Construction
 
-        public MatchData(Match/*!*/ match, MutableString/*!*/ originalString) {
-            ContractUtils.RequiresNotNull(match, &quot;regex&quot;);
-            ContractUtils.RequiresNotNull(originalString, &quot;originalString&quot;);
+        private MatchData(Match/*!*/ match, MutableString/*!*/ originalString, int[] kIndices) {
+            Debug.Assert(match.Success);
+            
             _match = match;
-            _originalString = originalString;
+
+            // TODO (opt): create groups instead?
+            _originalString = originalString.Clone().Freeze();
+
+            _kIndices = kIndices;
+            IsTainted = originalString.IsTainted;
         }
 
         public MatchData() {
@@ -48,7 +70,7 @@ namespace IronRuby.Builtins {
         }
 
         protected MatchData(MatchData/*!*/ data)
-            : this(data._match, data._originalString) {
+            : this(data._match, data._originalString, data._kIndices) {
         }
 
         object IDuplicable.Duplicate(RubyContext/*!*/ context, bool copySingletonMembers) {
@@ -63,21 +85,93 @@ namespace IronRuby.Builtins {
         
         public void InitializeFrom(MatchData/*!*/ other) {
             _match = other._match;
+            _kIndices = other._kIndices;
             _originalString = other._originalString;
         }
 
+        internal static MatchData Create(Match/*!*/ match, MutableString/*!*/ input, string/*!*/ encodedInput, RubyEncoding kcoding, int kStart) {
+            if (!match.Success) {
+                return null;
+            }
+            
+            int[] kIndices;
+            if (kcoding != null) {
+                // TODO (opt): minimize GetByteCount calls, remove ToCharArray:
+                char[] kCodedChars = encodedInput.ToCharArray();
+                Encoding encoding = kcoding.StrictEncoding;
+                kIndices = new int[match.Groups.Count * 2];
+                for (int i = 0; i &lt; match.Groups.Count; i++) {
+                    var group = match.Groups[i];
+                    if (group.Success) {
+                        kIndices[i * 2] = encoding.GetByteCount(kCodedChars, 0, group.Index) + kStart;
+                        kIndices[i * 2 + 1] = encoding.GetByteCount(kCodedChars, group.Index, group.Length) + kStart;
+                    } else {
+                        kIndices[i * 2] = -1;
+                    }
+                }
+            } else {
+                kIndices = null;
+            }
+
+            return new MatchData(match, input, kIndices);
+        }
+        
+        #endregion
+
+        #region IRubyObjectState Members
+
+        public bool IsFrozen {
+            get { return (_flags &amp; FrozenFlag) != 0; }
+        }
+
+        public bool IsTainted {
+            get { return (_flags &amp; TaintedFlag) != 0; }
+            set { _flags = (_flags &amp; ~TaintedFlag) | (value ? TaintedFlag : 0); }
+        }
+
+        public void Freeze() {
+            _flags |= FrozenFlag;
+        }
+
         #endregion
 
-        public MutableString GetGroupValue(RubyContext/*!*/ context, int index) {
-            var group = Groups[index];
-            return group.Success ? MutableString.Create(group.Value, Encoding).TaintBy(this, context) : null;
+        public bool GroupSuccess(int index) {
+            return _match.Groups[index].Success;
+        }
+
+        public MutableString GetValue() {
+            return _match.Success ? _originalString.GetSlice(Index, Length).TaintBy(this) : null;
+        }
+
+        public MutableString GetGroupValue(int index) {
+            // we don't need to check index range, Groups indexer returns an unsuccessful group if out of range:
+            return GroupSuccess(index) ? _originalString.GetSlice(GetGroupStart(index), GetGroupLength(index)).TaintBy(this) : null;
+        }
+
+        public MutableString AppendGroupValue(int index, MutableString/*!*/ result) {
+            // we don't need to check index range, Groups indexer returns an unsuccessful group if out of range:
+            return GroupSuccess(index) ? result.Append(_originalString, GetGroupStart(index), GetGroupLength(index)).TaintBy(this) : null;
+        }
+
+        public int GetGroupStart(int groupIndex) {
+            ContractUtils.Requires(groupIndex &gt;= 0);
+            return _kIndices != null ? _kIndices[groupIndex * 2] : _match.Groups[groupIndex].Index;
+        }
+
+        public int GetGroupLength(int groupIndex) {
+            ContractUtils.Requires(groupIndex &gt;= 0);
+            return _kIndices != null ? _kIndices[groupIndex * 2 + 1] : _match.Groups[groupIndex].Length;
+        }
+        
+        public int GetGroupEnd(int groupIndex) {
+            ContractUtils.Requires(groupIndex &gt;= 0);
+            return GetGroupStart(groupIndex) + GetGroupLength(groupIndex);
         }
 
-        public Group/*!*/ GetExistingGroup(int index) {
-            if (index &gt;= Groups.Count || index &lt; 0) {
+        public void RequireExistingGroup(int index) {
+            if (index &gt;= _match.Groups.Count || index &lt; 0) {
                 throw RubyExceptions.CreateIndexError(String.Format(&quot;index {0} out of matches&quot;, index));
             }
-            return Groups[index];
         }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/MatchData.cs</filename>
    </modified>
    <modified>
      <diff>@@ -169,13 +169,13 @@ namespace IronRuby.Builtins {
                 // nop
             }
 
-            public override GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) {
-                // TODO: Fix BinaryRegex and use instead
-                return new StringRegex(ToString(), options);
-            }
-
             public override Content/*!*/ EscapeRegularExpression() {
-                return new BinaryContent(BinaryRegex.Escape(ToByteArray()), _owner);
+                // TODO:
+                var a = ToByteArray();
+                return new BinaryContent(
+                    BinaryEncoding.Obsolete.GetBytes(RubyRegex.Escape(BinaryEncoding.Obsolete.GetString(a, 0, a.Length))),
+                    _owner
+                );
             }
 
             public override void CheckEncoding() {
@@ -248,7 +248,7 @@ namespace IronRuby.Builtins {
             }
 
             public override int IndexOf(byte[]/*!*/ bytes, int start, int count) {
-                return Utils.IndexOf(_data, bytes, start, count);
+                return Utils.IndexOf(_data, _count, bytes, start, count);
             }
 
             public override int IndexIn(Content/*!*/ str, int start, int count) {
@@ -272,7 +272,7 @@ namespace IronRuby.Builtins {
             }
 
             public override int LastIndexOf(byte[]/*!*/ bytes, int start, int count) {
-                return Utils.LastIndexOf(_data, bytes, start, count);
+                return Utils.LastIndexOf(_data, _count, bytes, start, count);
             }
 
             public override int LastIndexIn(Content/*!*/ str, int start, int count) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.BinaryContent.cs</filename>
    </modified>
    <modified>
      <diff>@@ -173,13 +173,9 @@ namespace IronRuby.Builtins {
                 return SwitchToBinary().GetByteArray();
             }
 
-            public override GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) {
-                return new StringRegex(ToString(), options);
-            }
-
             public override Content/*!*/ EscapeRegularExpression() {
                 // TODO:
-                StringBuilder sb = StringRegex.EscapeToStringBuilder(ToString());
+                StringBuilder sb = RubyRegex.EscapeToStringBuilder(ToString());
                 return (sb != null) ? new CharArrayContent(sb.ToString().ToCharArray(), _owner) : this;
             }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.CharArrayContent.cs</filename>
    </modified>
    <modified>
      <diff>@@ -62,7 +62,6 @@ namespace IronRuby.Builtins {
 
             public abstract byte[]/*!*/ ToByteArray();
             internal abstract byte[]/*!*/ GetByteArray();
-            public abstract GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options);
 
             // returns self if there are no characters to be escaped:
             public abstract Content/*!*/ EscapeRegularExpression();</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.Content.cs</filename>
    </modified>
    <modified>
      <diff>@@ -145,12 +145,8 @@ namespace IronRuby.Builtins {
                 SwitchToMutable();
             }
 
-            public override GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) {
-                return new StringRegex(_data, options);
-            }
-
             public override Content/*!*/ EscapeRegularExpression() {
-                StringBuilder sb = StringRegex.EscapeToStringBuilder(_data);
+                StringBuilder sb = RubyRegex.EscapeToStringBuilder(_data);
                 return (sb != null) ? new StringContent(sb.ToString(), _owner) : this;
             }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.StringContent.cs</filename>
    </modified>
    <modified>
      <diff>@@ -565,6 +565,23 @@ namespace IronRuby.Builtins {
         }
 
         /// &lt;summary&gt;
+        /// Switches the content to a byte array using the current encoding and decodes the binary into a string using the given encoding.
+        /// &lt;/summary&gt;
+        /// &lt;exception cref=&quot;DecoderFallbackException&quot;&gt;Invalid characters present.&lt;/exception&gt;
+        public string/*!*/ ToString(Encoding/*!*/ encoding) {
+            byte[] bytes = _content.GetByteArray();
+            return encoding.GetString(bytes, 0, bytes.Length);
+        }
+
+        /// &lt;summary&gt;
+        /// Switches the content to a byte array using the current encoding and decodes the binary into a string using the given encoding.
+        /// &lt;/summary&gt;
+        /// &lt;exception cref=&quot;DecoderFallbackException&quot;&gt;Invalid characters present.&lt;/exception&gt;
+        public string/*!*/ ToString(Encoding/*!*/ encoding, int start, int count) {
+            return encoding.GetString(_content.GetByteArray(), start, count);
+        }
+
+        /// &lt;summary&gt;
         /// This property can be viewed using a string visualizer in a debugger, making it easy to inspect large or multi-line strings.
         /// &lt;/summary&gt;
         internal string/*!*/ Dump {
@@ -579,10 +596,6 @@ namespace IronRuby.Builtins {
             return _content.ToByteArray();
         }
 
-        public GenericRegex/*!*/ ToRegularExpression(RubyRegexOptions options) {
-            return _content.ToRegularExpression(options);
-        }
-
         /// &lt;summary&gt;
         /// Switches internal representation to textual.
         /// &lt;/summary&gt;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs</filename>
    </modified>
    <modified>
      <diff>@@ -26,7 +26,7 @@ namespace IronRuby.Builtins {
     /// &lt;summary&gt;
     /// Converts a Ruby regexp pattern to a CLR pattern
     /// &lt;/summary&gt;
-    internal class RegexpTransformer {
+    internal sealed class RegexpTransformer {
         [Flags]
         enum PatternState {
             Normal,
@@ -34,18 +34,22 @@ namespace IronRuby.Builtins {
             InCharacterClass
         }
 
-        string/*!*/ _rubyPattern;
-        PatternState _state = PatternState.Normal;
-        int _index;
-        StringBuilder/*!*/ _sb;
+        private string/*!*/ _rubyPattern;
+        private PatternState _state = PatternState.Normal;
+        private int _index;
+        private StringBuilder/*!*/ _sb;
+        private bool _hasGAnchor;
 
-        internal static string Transform(string/*!*/ rubyPattern, RubyRegexOptions options) {
+        internal static string Transform(string/*!*/ rubyPattern, RubyRegexOptions options, out bool hasGAnchor) {
             if (rubyPattern == &quot;\\Af(?=[[:xdigit:]]{2}+\\z)&quot;) {
                 // pp.rb uses this pattern. The real fix requires cracking the entire regexp and so is left for later
+                hasGAnchor = false;
                 return &quot;\\Af(?=(?:[[:xdigit:]]{2})+\\z)&quot;;
             }
             RegexpTransformer transformer = new RegexpTransformer(rubyPattern);
-            return transformer.Transform();
+            var result = transformer.Transform();
+            hasGAnchor = transformer._hasGAnchor;
+            return result;
         }
 
         private RegexpTransformer(string/*!*/ rubyPattern) {
@@ -226,8 +230,7 @@ namespace IronRuby.Builtins {
                 case 'A': // beginning of string
                 case 'Z': // end of string, or before newline at the end
                 case 'z': // end of string
-                case 'G':
-
+                
                 case 'd':
                 case 'D':
                 case 's':
@@ -297,6 +300,11 @@ namespace IronRuby.Builtins {
                     LeaveEscapeSequence();
                     break;
 
+                case 'G':
+                    _hasGAnchor = true;
+                    AppendEscapedChar(c);
+                    return;
+
                 default:
                     if (IsMetaCharacterWithDirectMapping(c)) {
                         AppendEscapedChar(c);</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RegexpTransformer.cs</filename>
    </modified>
    <modified>
      <diff>@@ -107,23 +107,25 @@ namespace IronRuby.Builtins {
         }
 
         public int WriteBytes(byte[]/*!*/ buffer, int offset, int count, bool preserveEndOfLines) {
+            ContractUtils.RequiresArrayRange(buffer.Length, offset, count, &quot;offset&quot;, &quot;count&quot;);
             FlushRead();
 
             if (preserveEndOfLines) {
                 _stream.Write(buffer, offset, count);
-                return buffer.Length;
+                return count;
             } else {
                 int bytesWritten = 0;
                 int i = offset;
-                while (i &lt; count) {
+                int end = offset + count;
+                while (i &lt; end) {
                     int j = i;
-                    while (j &lt; buffer.Length &amp;&amp; buffer[j] != LF) {
+                    while (j &lt; end &amp;&amp; buffer[j] != LF) {
                         j++;
                     }
                     _stream.Write(buffer, i, j - i);
                     bytesWritten += j - i;
 
-                    if (j &lt; buffer.Length) {
+                    if (j &lt; end) {
                         _stream.WriteByte(CR);
                         _stream.WriteByte(LF);
                         bytesWritten += 2;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyBufferedStream.cs</filename>
    </modified>
    <modified>
      <diff>@@ -682,6 +682,13 @@ namespace IronRuby.Builtins {
 
         // thread safe: doesn't need any lock since it only accesses immutable state
         public bool TryGetClrMember(string/*!*/ name, out RubyMemberInfo method) {
+            return TryGetClrMember(name, null, out method);
+        }
+
+        // thread safe: doesn't need any lock since it only accesses immutable state
+        public bool TryGetClrMember(string/*!*/ name, Type asType, out RubyMemberInfo method) {
+            Debug.Assert(!_isSingletonClass);
+
             // Get the first class in hierarchy that represents CLR type - worse case we end up with Object.
             // Ruby classes don't represent a CLR type and hence expose no CLR members.
             RubyClass cls = this;
@@ -689,11 +696,18 @@ namespace IronRuby.Builtins {
                 cls = cls.SuperClass;
             }
 
-            Debug.Assert(!cls.TypeTracker.Type.IsInterface);
+            Type type = cls.TypeTracker.Type;
+            Debug.Assert(!type.IsInterface);
 
-            // Note: We don't cache failures as this API is not used so frequently (e.g. for regular method dispatch) that we would need caching.
+            // Note: We don't cache results as this API is not used so frequently (e.g. for regular method dispatch).
+            
+            if (asType != null &amp;&amp; !asType.IsAssignableFrom(type)) {
+                throw RubyExceptions.CreateNameError(String.Format(&quot;`{0}' does not inherit from `{0}'&quot;, cls.Name, Context.GetTypeName(asType, true)));
+            }
+
+            // TODO: should declaring module of the resulting method rather be the base class?
             method = null;
-            return cls.TryGetClrMember(cls.TypeTracker.Type, name, true, 0, out method);
+            return cls.TryGetClrMember(asType ?? type, name, true, 0, out method);
         }
 
         // thread safe: doesn't need any lock since it only accesses immutable state
@@ -725,6 +739,10 @@ namespace IronRuby.Builtins {
             return false;
         }
 
+        /// &lt;summary&gt;
+        /// Returns a fresh instance of RubyMemberInfo each time it is called. The caller needs to cache it if appropriate.
+        /// May add or use method groups to/from super-clases if BindingFlags.DeclaredOnly is used.
+        /// &lt;/summary&gt;
         private bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool tryUnmangle, BindingFlags basicBindingFlags, out RubyMemberInfo method) {
             basicBindingFlags |= BindingFlags.Public | BindingFlags.NonPublic;
 
@@ -760,7 +778,7 @@ namespace IronRuby.Builtins {
                 }
             } else if (name.LastCharacter() == '=') {
                 string propertyName = name.Substring(0, name.Length - 1);
-                string altName = tryUnmangle ? RubyUtils.TryUnmangleName(propertyName) : null;
+                string altName = tryUnmangle ? RubyUtils.TryUnmangleMethodName(propertyName) : null;
                 
                 // property setter:
                 if (TryGetClrProperty(type, bindingFlags, true, name, propertyName, altName, out method)) return true;
@@ -768,7 +786,7 @@ namespace IronRuby.Builtins {
                 // writeable field:
                 if (TryGetClrField(type, bindingFlags, true, propertyName, altName, out method)) return true;
             } else {
-                string altName = tryUnmangle ? RubyUtils.TryUnmangleName(name) : null;
+                string altName = tryUnmangle ? RubyUtils.TryUnmangleMethodName(name) : null;
 
                 // method:
                 if (TryGetClrMethod(type, bindingFlags, false, name, null, name, altName, out method)) return true;
@@ -869,6 +887,12 @@ namespace IronRuby.Builtins {
         ///        2) C.HidesInheritedOverloads == false
         ///           All overloads of the method we look for are in [type..C) and in the RubyMemberInfo.
         /// &lt;/summary&gt;
+        /// &lt;remarks&gt;
+        /// Doesn't include explicitly implemented interface methods. Including them would allow to call them directly (obj.foo) 
+        /// if the overload resolution succeeds. However, the interface methods are probably implemented explicitly for a reason:
+        /// 1) There is a conflict in signatures -&gt; the overload resolution would probably fail.
+        /// 2) The class was designed with an intention to not expose the implementations directly.
+        /// &lt;/remarks&gt;
         private bool TryGetClrMethod(Type/*!*/ type, BindingFlags bindingFlags, bool specialNameOnly, 
             string/*!*/ name, string clrNamePrefix, string/*!*/ clrName, string altClrName, out RubyMemberInfo method) {
 
@@ -1216,15 +1240,16 @@ namespace IronRuby.Builtins {
 
                 initializer = ResolveMethodForSiteNoLock(Symbols.Initialize, VisibilityContext.AllVisible).Info;
 
-                // Initializer resolves to Object#initializer unless overridden in a derived class.
-                // We ensure that this method cannot be removed.
+                // Initializer resolves to Object#initialize unless overridden in a derived class.
+                // We ensure that initializer cannot be removed/undefined so that we don't ever fall back to method_missing.
                 Debug.Assert(initializer != null);
             }
 
-            bool hasRubyInitializer = initializer is RubyMethodInfo;
-            bool hasLibraryInitializer = !hasRubyInitializer &amp;&amp; !initializer.DeclaringModule.IsObjectClass &amp;&amp; initializer is RubyLibraryMethodInfo;
+            bool isLibraryMethod = initializer is RubyLibraryMethodInfo;
+            bool isRubyInitializer = initializer.IsRubyMember &amp;&amp; !isLibraryMethod;
+            bool isLibraryInitializer = isLibraryMethod &amp;&amp; !initializer.DeclaringModule.IsObjectClass;
 
-            if (hasRubyInitializer || hasLibraryInitializer &amp;&amp; _isRubyClass) {
+            if (isRubyInitializer || isLibraryInitializer &amp;&amp; _isRubyClass) {
                 // allocate and initialize:
                 bool allocatorFound = BuildAllocatorCall(metaBuilder, args, () =&gt; AstUtils.Constant(Name));
                 if (metaBuilder.Error) {
@@ -1299,11 +1324,11 @@ namespace IronRuby.Builtins {
             var instanceVariable = metaBuilder.GetTemporary(instanceExpr.Type, &quot;#instance&quot;);
 
             // We know an exact type of the new instance and that there is no singleton for that instance.
-            // We also have the exact method we need to call (&quot;initialize&quot; is a RubyMethodInfo).
+            // We also have the exact method we need to call (&quot;initialize&quot; is a RubyMethodInfo/RubyLambdaMethodInfo).
             // =&gt; no tests are necessary:
             args.SetTarget(instanceVariable, null);
 
-            if (initializer is RubyMethodInfo) {
+            if (initializer is RubyMethodInfo || initializer is RubyLambdaMethodInfo) {
                 initializer.BuildCallNoFlow(metaBuilder, args, Symbols.Initialize);
             } else {
                 // TODO: we need more refactoring of RubyMethodGroupInfo.BuildCall to be able to inline this:</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs</filename>
    </modified>
    <modified>
      <diff>@@ -212,6 +212,37 @@ namespace IronRuby.Builtins {
         public static RubyEncoding/*!*/ GetRubyEncoding(string/*!*/ name) {
             return GetRubyEncoding(GetEncodingByRubyName(name));
         }
+
+        public static RubyRegexOptions ToRegexOption(RubyEncoding encoding) {
+#if SILVERLIGHT
+            return RubyRegexOptions.NONE;
+#else
+            if (encoding == null || !encoding._isKCoding) {
+                return RubyRegexOptions.NONE;
+            }
+
+            switch (encoding._encoding.CodePage) {
+                case RubyEncoding.CodePageUTF8: return RubyRegexOptions.UTF8;
+                case RubyEncoding.CodePageSJIS: return RubyRegexOptions.SJIS;
+                case RubyEncoding.CodePageEUC: return RubyRegexOptions.EUC;
+            }
+
+            throw Assert.Unreachable;
+#endif
+        }
+
+        public static RubyEncoding GetKCoding(RubyRegexOptions options) {
+#if SILVERLIGHT
+            return null;
+#else
+            switch (options &amp; RubyRegexOptions.EncodingMask) {
+                case RubyRegexOptions.EUC: return RubyEncoding.KCodeEUC;
+                case RubyRegexOptions.SJIS: return RubyEncoding.KCodeSJIS;
+                case RubyRegexOptions.UTF8: return RubyEncoding.KCodeUTF8;
+                default: return null;
+            }
+#endif
+        }
         
 #if !SILVERLIGHT
         private static Dictionary&lt;int, RubyEncoding&gt; _Encodings;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyEncoding.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,11 +25,11 @@ using System.Runtime.CompilerServices;
 using IronRuby.Runtime;
 using IronRuby.Runtime.Calls;
 using Microsoft.Scripting.Utils;
+using Microsoft.Scripting.Generation;
 using AstUtils = Microsoft.Scripting.Ast.Utils;
 
 namespace IronRuby.Builtins {
     using Ast = Expression;
-
     using BlockCallTargetUnsplatN = Func&lt;BlockParam, object, object[], RubyArray, object&gt;;
 
     public partial class RubyMethod {
@@ -105,7 +105,7 @@ namespace IronRuby.Builtins {
             metaBuilder.AddRestriction(Ast.Equal(args.TargetExpression, AstUtils.Constant(this)));
 
             // set the target (becomes self in the called method):
-            args.SetTarget(AstUtils.Constant(_target), _target);
+            args.SetTarget(AstUtils.Constant(_target, CompilerHelpers.GetVisibleType(_target)), _target);
 
             _info.BuildCall(metaBuilder, args, _name);
         }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyMethod.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1249,6 +1249,10 @@ namespace IronRuby.Builtins {
                     IsClass ? &quot;class&quot; : &quot;module&quot;, _name, _context.RuntimeId));
             }
 
+            if (method.IsUndefined &amp;&amp; name == Symbols.Initialize) {
+                throw RubyExceptions.CreateTypeError(&quot;Cannot undefine `initialize' method&quot;);
+            }
+
             PrepareMethodUpdate(name, method);
 
             InitializeMethodsNoLock();</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs</filename>
    </modified>
    <modified>
      <diff>@@ -21,41 +21,56 @@ using System.Text;
 using System.Text.RegularExpressions;
 using IronRuby.Compiler;
 using IronRuby.Runtime;
+using System.Collections.Generic;
 
 namespace IronRuby.Builtins {
     public partial class RubyRegex : IEquatable&lt;RubyRegex&gt;, IDuplicable {
-        private GenericRegex/*!*/ _regex;
+        // 1.9: correctly encoded, switched to characters 
+        // 1.8: k-coded binary data, if _options specify encoding, or raw binary data otherwise.
+        private MutableString/*!*/ _pattern;
+        private RubyRegexOptions _options;
+        private bool _hasGAnchor;
+
+        private Regex _cachedRegex;
+
+        // Ruby 1.8: match operations use KCODE encoding so we need to remember the one for which we have cached CLR Regex.
+        private RubyRegexOptions _cachedKCode;
 
         #region Construction
 
         public RubyRegex() {
-            _regex = StringRegex.Empty;
+            _pattern = MutableString.CreateEmpty();
+            _options = RubyRegexOptions.NONE;
+        }
+
+        public RubyRegex(MutableString/*!*/ pattern) 
+            : this(pattern, RubyRegexOptions.NONE) {
         }
 
         public RubyRegex(MutableString/*!*/ pattern, RubyRegexOptions options) {
-            ContractUtils.RequiresNotNull(pattern, &quot;pattern&quot;);
-            _regex = pattern.ToRegularExpression(GetPersistedOptions(options));
+            Set(pattern, options);
         }
 
-        public RubyRegex(string/*!*/ pattern, RubyRegexOptions options) {
-            ContractUtils.RequiresNotNull(pattern, &quot;pattern&quot;);
-            _regex = new StringRegex(pattern, GetPersistedOptions(options));
+        public RubyRegex(RubyRegex/*!*/ regex) {
+            ContractUtils.RequiresNotNull(regex, &quot;regex&quot;);
+            Set(regex.Pattern, regex.Options);
         }
 
-        public RubyRegex(byte[]/*!*/ pattern, RubyRegexOptions options) {
+        public void Set(MutableString/*!*/ pattern, RubyRegexOptions options) {
             ContractUtils.RequiresNotNull(pattern, &quot;pattern&quot;);
-            // TODO: _regex = new BinaryRegex(pattern, RubyRegex.GetPersistedOptions(options));
-            _regex = new StringRegex(BinaryEncoding.Obsolete.GetString(pattern, 0, pattern.Length), GetPersistedOptions(options));
-        }
 
-        public RubyRegex(Regex/*!*/ regex) {
-            ContractUtils.RequiresNotNull(regex, &quot;regex&quot;);
-            _regex = new StringRegex(regex);
-        }
+            // RubyRegexOptions.Once is only used to determine how the Regexp object should be created and cached. 
+            // It is not a property of the final object. /foo/ should compare equal with /foo/o.
+            _options = options &amp; ~RubyRegexOptions.Once;
 
-        public RubyRegex(RubyRegex/*!*/ regex) {
-            ContractUtils.RequiresNotNull(regex, &quot;regex&quot;);
-            _regex = regex._regex;
+            RubyEncoding kcoding = RubyEncoding.GetKCoding(options);
+            if (kcoding != null || pattern.Encoding.IsKCoding) {
+                _pattern = MutableString.CreateBinary(pattern.ToByteArray(), kcoding ?? RubyEncoding.Binary).Freeze();
+            } else {
+                _pattern = pattern.SwitchToCharacters().Clone().Freeze();
+            }
+            
+            TransformPattern(kcoding, options &amp; RubyRegexOptions.EncodingMask);
         }
 
         /// &lt;summary&gt;
@@ -75,124 +90,112 @@ namespace IronRuby.Builtins {
 
         #endregion
 
-        public bool IsEmpty {
-            get { return _regex.IsEmpty; }
-        }
+        #region Transformation to CLR Regex
 
-        public RubyRegexOptions Options {
-            get { return _regex.Options; }
-        }
+        private Regex/*!*/ Transform(ref RubyEncoding kcoding, MutableString/*!*/ input, int start, out string strInput) {
+            ContractUtils.RequiresNotNull(input, &quot;input&quot;);
 
-        public RubyEncoding/*!*/ Encoding {
-            // TODO:
-            get { return _regex.GetPattern().Encoding; }
-        }
+            // K-coding of the current operation (the current KCODE gets preference over the KCODE regex option):
+            RubyRegexOptions kc = _options &amp; RubyRegexOptions.EncodingMask;
+            if (kc != 0) {
+                kcoding = _pattern.Encoding;
+            } else {
+                kc = RubyEncoding.ToRegexOption(kcoding);
+            }
 
-        public MutableString/*!*/ GetPattern() {
-            return _regex.GetPattern();
-        }
+            // Convert input to a string. Force k-coding if necessary.
+            if (kc != 0) {
+                try {
+                    strInput = ForceEncoding(input, kcoding.StrictEncoding, start);
+                } catch (DecoderFallbackException) {
+                    throw RubyExceptions.CreateArgumentError(String.Format(&quot;invalid {0} character&quot;, kcoding.RealEncoding));
+                }
+            } else if (input.Encoding.IsKCoding) {
+                strInput = input.ToString(BinaryEncoding.Instance);
+            } else {
+                _pattern.RequireCompatibleEncoding(input);
+                input.SwitchToCharacters();
+                strInput = input.ToString();
+            }
 
-#if DEBUG
-        public string/*!*/ GetTransformedPattern() {
-            return _regex.GetTransformedPattern();
-        }
-#endif
-        public bool Equals(RubyRegex other) {
-            return ReferenceEquals(this, other) || other != null &amp;&amp; _regex.Equals(other._regex);
+            return TransformPattern(kcoding, kc);
         }
 
-        public override bool Equals(object other) {
-            return _regex.Equals(other as RubyRegex);
-        }
+        private Regex/*!*/ TransformPattern(RubyEncoding kcoding, RubyRegexOptions kc) {
+            // We can reuse cached CLR regex if it was created for the same k-coding:
+            if (_cachedRegex != null &amp;&amp; kc == _cachedKCode) {
+                return _cachedRegex;
+            }
 
-        public override int GetHashCode() {
-            return _regex.GetHashCode();
-        }
+            string pattern;
+            if (kc != 0) {
+                try {
+                    pattern = _pattern.ToString(kcoding.StrictEncoding);
+                } catch (DecoderFallbackException) {
+                    throw RubyExceptions.CreateArgumentError(String.Format(&quot;invalid multi-byte sequence in {0} regex pattern&quot;, kcoding));
+                }
+            } else {
+                pattern = _pattern.ConvertToString();
+            }
 
-        #region Match, ReverseMatch, Matches, Split
+            Regex result;
+            try {
+                result = new Regex(RegexpTransformer.Transform(pattern, _options, out _hasGAnchor), ToClrOptions(_options));
+            } catch (Exception e) {
+                throw new RegexpError(e.Message);
+            }
 
-        public Match/*!*/ Match(MutableString/*!*/ input) {
-            return Match(input, 0);
+            _cachedKCode = kc;
+            _cachedRegex = result;
+            return result;
         }
 
-        public Match/*!*/ Match(MutableString/*!*/ input, int start) {
-            ContractUtils.RequiresNotNull(input, &quot;input&quot;);
-            return Match(input, start, input.GetCharCount() - start);
-        }
+        private static string/*!*/ ForceEncoding(MutableString/*!*/ input, Encoding/*!*/ encoding, int start) {
+            int byteCount = input.GetByteCount();
 
-        public Match/*!*/ Match(MutableString/*!*/ input, int start, int count) {
-            ContractUtils.RequiresNotNull(input, &quot;input&quot;);
-            return _regex.Match(input, start, count);
-        }
+            if (start &lt; 0) {
+                start += byteCount;
+            }
+            if (start &lt; 0) {
+                return null;
+            }
 
-        public Match/*!*/ ReverseMatch(MutableString/*!*/ str, int start) {
-            ContractUtils.RequiresNotNull(str, &quot;str&quot;);
-            return _regex.ReverseMatch(str, start);
-        }
-        
-        public Match/*!*/ ReverseMatch(MutableString/*!*/ str, int start, int count) {
-            ContractUtils.RequiresNotNull(str, &quot;str&quot;);
-            return _regex.ReverseMatch(str, start, count);            
+            return (start &lt;= byteCount) ? input.ToString(encoding, start, byteCount - start) : null;
         }
 
-        public MatchCollection/*!*/ Matches(MutableString/*!*/ input) {
-            return Matches(input, 0);
-        }
+        #endregion
 
-        public MatchCollection/*!*/ Matches(MutableString/*!*/ input, int start) {
-            ContractUtils.RequiresNotNull(input, &quot;input&quot;);
-            return _regex.Matches(input, start);
+        public bool IsEmpty {
+            get { return _pattern.IsEmpty; }
         }
 
-        public MutableString[]/*!*/ Split(MutableString/*!*/ input) {
-            return _regex.Split(input, 0, 0);
+        public RubyRegexOptions Options {
+            get { return _options; }
         }
 
-        public MutableString[]/*!*/ Split(MutableString/*!*/ input, int count) {
-            return _regex.Split(input, count, 0);
-        }
-        
-        public MutableString[]/*!*/ Split(MutableString/*!*/ input, int count, int start) {
-            return _regex.Split(input, count, start);
+        public RubyEncoding/*!*/ Encoding {
+            get { return _pattern.Encoding; }
         }
 
-        public static MatchData SetCurrentMatchData(RubyScope/*!*/ scope, RubyRegex/*!*/ regex, MutableString/*!*/ str) {
-            var targetScope = scope.GetInnerMostClosureScope();
-            
-            if (str == null) {
-                return targetScope.CurrentMatch = null;
-            }
-
-            Match match = regex.Match(str, 0);
-            if (match.Success) {
-                return targetScope.CurrentMatch = scope.RubyContext.TaintObjectBy(new MatchData(match, str), str);
-            } else {
-                return targetScope.CurrentMatch = null;
-            }
+        public MutableString/*!*/ Pattern {
+            get { return _pattern; }
         }
 
-        #endregion
-
-        /// &lt;summary&gt;
-        /// Returns a new instance of MutableString that contains escaped content of the given string.
-        /// &lt;/summary&gt;
-        public static MutableString/*!*/ Escape(MutableString/*!*/ str) {
-            // TODO:
-            return str.EscapeRegularExpression();
+        public bool Equals(RubyRegex other) {
+            return ReferenceEquals(this, other) 
+                || other != null &amp;&amp; _options.Equals(other._options) &amp;&amp; _pattern.Equals(other._pattern);
         }
 
-        public void Set(MutableString/*!*/ pattern, RubyRegexOptions options) {
-            _regex = pattern.ToRegularExpression(options);
+        public override bool Equals(object other) {
+            return Equals(other as RubyRegex);
         }
 
-        internal static RubyRegexOptions GetPersistedOptions(RubyRegexOptions options) {
-            // RubyRegexOptions.Once is only used to determine how the Regexp object should be created and cached. 
-            // It is not a property of the final object. /foo/ should compare equal with /foo/o.
-            return options &amp; ~RubyRegexOptions.Once;
+        public override int GetHashCode() {
+            return _pattern.GetHashCode() ^ _options.GetHashCode();
         }
 
         public static RegexOptions ToClrOptions(RubyRegexOptions options) {
-            RegexOptions result = RegexOptions.Multiline;
+            RegexOptions result = RegexOptions.Multiline | RegexOptions.CultureInvariant;
 
 #if DEBUG
             if (RubyOptions.CompileRegexps) {
@@ -214,10 +217,142 @@ namespace IronRuby.Builtins {
             if ((options &amp; RubyRegexOptions.Multiline) != 0) {
                 result |= RegexOptions.Singleline;
             }
-            
+
             return result;
         }
 
+        #region Match, LastMatch, Matches, Split
+
+        public MatchData Match(RubyEncoding kcode, MutableString/*!*/ input) {
+            string str;
+            return MatchData.Create(Transform(ref kcode, input, 0, out str).Match(str), input, str, kcode, 0);
+        }
+
+        /// &lt;summary&gt;
+        /// Start is a number of bytes if kcode is given, otherwise it's a number of characters.
+        /// &lt;/summary&gt;
+        public MatchData Match(RubyEncoding kcode, MutableString/*!*/ input, int start) {
+            string str;
+            Regex regex = Transform(ref kcode, input, start, out str);
+
+            Match match;
+            if (kcode != null) {
+                if (str == null) {
+                    return null;
+                }
+                match = regex.Match(str, 0);
+            } else {
+                if (start &lt; 0) {
+                    start += str.Length;
+                }
+                if (start &lt; 0 || start &gt; str.Length) {
+                    return null;
+                }
+                match = regex.Match(str, start);
+            }
+
+            return MatchData.Create(match, input, str, kcode, start);
+        }
+
+        public MatchData LastMatch(RubyEncoding kcode, MutableString/*!*/ input) {
+            return LastMatch(kcode, input, Int32.MaxValue);
+        }
+
+        /// &lt;summary&gt;
+        /// Finds the last match whose index is less than or equal to &quot;start&quot;.
+        /// Captures are ordered in the same way as with forward match. This is different from .NET reverse matching.
+        /// Start is a number of bytes if kcode is given, otherwise it's a number of characters.
+        /// &lt;/summary&gt;
+        public MatchData LastMatch(RubyEncoding kcode, MutableString/*!*/ input, int start) {
+            string str;
+            Regex regex = Transform(ref kcode, input, 0, out str);
+            Debug.Assert(str != null);
+
+            if (kcode != null) {
+                byte[] bytes = input.GetByteArray();
+
+                if (start &lt; 0) {
+                    start += bytes.Length;
+                }
+
+                // GetCharCount returns the number of whole characters:
+                start = (start &gt;= bytes.Length) ? str.Length : kcode.Encoding.GetCharCount(bytes, 0, start + 1) - 1;
+            } else {
+                if (start &lt; 0) {
+                    start += str.Length;
+                }
+
+                if (start &gt; str.Length) {
+                    start = str.Length;
+                }
+            }
+
+            Match match;
+            if (_hasGAnchor) {
+                // This only makes some \G anchors work. It seems that CLR doesn't support \G if preceeded by some characters.
+                // For example, this works in MRI but doesn't in CLR: &quot;abcabczzz&quot;.rindex(/.+\G.+/, 3)
+                match = regex.Match(str, start);
+            } else {
+                match = LastMatch(regex, str, start);
+                if (match == null) {
+                    return null;
+                }
+            }
+            return MatchData.Create(match, input, str, kcode, 0);
+        }
+
+        /// &lt;summary&gt;
+        /// Binary searches &quot;str&quot; for the last match whose index is within the range [0, start].
+        /// &lt;/summary&gt;
+        private static Match LastMatch(Regex/*!*/ regex, string/*!*/ input, int start) {
+            Match result = null;
+            int s = 0;
+            int e = start;
+
+            while (s &lt;= e) {
+                int m = (s + e) / 2;
+                Match match = regex.Match(input, m);
+                if (match.Success &amp;&amp; match.Index &lt;= e) {
+                    result = match;
+                    s = match.Index + 1;
+                } else {
+                    e = m - 1;
+                }
+            }
+
+            return result;
+        }
+
+        /// &lt;summary&gt;
+        /// Returns a collection of fresh MatchData objects.
+        /// &lt;/summary&gt;
+        public IList&lt;MatchData&gt;/*!*/ Matches(RubyEncoding kcode, MutableString/*!*/ input) {
+            string str;
+            MatchCollection matches = Transform(ref kcode, input, 0, out str).Matches(str);
+
+            var result = new MatchData[matches.Count];
+            for (int i = 0; i &lt; result.Length; i++) {
+                result[i] = MatchData.Create(matches[i], input, str, kcode, 0);
+            }
+            return result;
+        }
+
+        public MutableString[]/*!*/ Split(RubyEncoding kcode, MutableString/*!*/ input) {
+            string str;
+            return MutableString.MakeArray(Transform(ref kcode, input, 0, out str).Split(str), kcode ?? input.Encoding);
+        }
+        
+        public MutableString[]/*!*/ Split(RubyEncoding kcode, MutableString/*!*/ input, int count) {
+            string str;
+            return MutableString.MakeArray(Transform(ref kcode, input, 0, out str).Split(str, count), kcode ?? input.Encoding);
+        }
+
+        public static MatchData SetCurrentMatchData(RubyScope/*!*/ scope, RubyRegex/*!*/ regex, MutableString str) {
+            return scope.GetInnerMostClosureScope().CurrentMatch = (str != null) ? regex.Match(scope.RubyContext.KCode, str) : null;
+        }
+
+        #endregion               
+
         #region ToString, Inspect
 
         public override string/*!*/ ToString() {
@@ -231,7 +366,7 @@ namespace IronRuby.Builtins {
         public MutableString/*!*/ Inspect() {
             MutableString result = MutableString.CreateMutable(RubyEncoding.Binary);
             result.Append('/');
-            AppendEscapeForwardSlash(result, GetPattern());
+            AppendEscapeForwardSlash(result, _pattern);
             result.Append('/');
             AppendOptionString(result, true, true);
             return result;
@@ -246,7 +381,7 @@ namespace IronRuby.Builtins {
             }
             AppendOptionString(result, false, false);
             result.Append(':');
-            AppendEscapeForwardSlash(result, GetPattern());
+            AppendEscapeForwardSlash(result, _pattern);
             result.Append(')');
             return result;
         }
@@ -317,5 +452,101 @@ namespace IronRuby.Builtins {
         }
 
         #endregion
+
+        #region Escape
+
+        private const int EndOfPattern = -1;
+
+        /// &lt;summary&gt;
+        /// Returns a new instance of MutableString that contains escaped content of the given string.
+        /// &lt;/summary&gt;
+        public static MutableString/*!*/ Escape(MutableString/*!*/ str) {
+            return str.EscapeRegularExpression();
+        }
+
+        private static int SkipNonSpecial(string/*!*/ pattern, int i, out char escaped) {
+            while (i &lt; pattern.Length) {
+                char c = pattern[i];
+                switch (c) {
+                    case '$':
+                    case '^':
+                    case '|':
+                    case '[':
+                    case ']':
+                    case '(':
+                    case ')':
+                    case '\\':
+                    case '.':
+                    case '#':
+                    case '-':
+
+                    case '{':
+                    case '}':
+                    case '*':
+                    case '+':
+                    case '?':
+                    case ' ':
+                        escaped = c;
+                        return i;
+
+                    case '\t':
+                        escaped = 't';
+                        return i;
+
+                    case '\n':
+                        escaped = 'n';
+                        return i;
+
+                    case '\r':
+                        escaped = 'r';
+                        return i;
+
+                    case '\f':
+                        escaped = 'f';
+                        return i;
+                }
+                i++;
+            }
+
+            escaped = '\0';
+            return EndOfPattern;
+        }
+
+        internal static string/*!*/ Escape(string/*!*/ pattern) {
+            StringBuilder sb = EscapeToStringBuilder(pattern);
+            return (sb != null) ? sb.ToString() : pattern;
+        }
+
+        internal static StringBuilder EscapeToStringBuilder(string/*!*/ pattern) {
+            int first = 0;
+            char escaped;
+            int i = SkipNonSpecial(pattern, 0, out escaped);
+
+            if (i == EndOfPattern) {
+                return null;
+            }
+
+            StringBuilder result = new StringBuilder(pattern.Length + 1);
+
+            do {
+                Debug.Assert(i &lt; pattern.Length);
+                // pattern[i] needs escape
+
+                result.Append(pattern, first, i - first);
+                result.Append('\\');
+                result.Append(escaped);
+                i++;
+
+                Debug.Assert(i &lt;= pattern.Length);
+
+                first = i;
+                i = SkipNonSpecial(pattern, i, out escaped);
+            } while (i &gt;= 0);
+
+            result.Append(pattern, first, pattern.Length - first);
+            return result;
+        }
+
+        #endregion
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegex.cs</filename>
    </modified>
    <modified>
      <diff>@@ -24,12 +24,14 @@ namespace IronRuby.Builtins {
         Multiline = 4,
         Once = 8,
 
-        // encoding:
+        // encoding (only set in 1.8 mode)
         FIXED = 16,
         EUC = 32,
-        SJIS = 48,
-        UTF8 = 64,
+        SJIS = 64,
+        UTF8 = 128,
 
-        EncodingMask = FIXED | EUC | SJIS | UTF8
+        EncodingMask = EUC | SJIS | UTF8,
+
+        CompleteEncodingMask = EncodingMask | FIXED
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegexOptions.cs</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,7 @@ using System.Diagnostics;
 
 namespace IronRuby.Builtins {
 #if GENERATOR
-    Stateless = ['MatchData', 'Proc', 'Range', 'RubyRegex']
+    Stateless = ['Proc', 'Range', 'RubyRegex']
 
     def generate
       Stateless.each do |cls| 
@@ -115,19 +115,6 @@ namespace IronRuby.Builtins {
                 return _instanceData;
             }
 
-            public bool IsFrozen {
-                get { return _instanceData != null &amp;&amp; _instanceData.Frozen; }
-            }
-
-            public bool IsTainted {
-                get { return _instanceData != null &amp;&amp; _instanceData.Tainted; }
-                set { GetInstanceData().Tainted = value; }
-            }
-
-            public void Freeze() {
-                GetInstanceData().Freeze();
-            }
-
             public int BaseGetHashCode() {
                 return base.GetHashCode();
             }
@@ -303,7 +290,7 @@ namespace IronRuby.Builtins {
 #endregion
 
 #if GENERATOR
-    Stateful = ['RubyArray']
+    Stateful = ['RubyArray', 'MatchData']
 
     def generate
       Stateful.each do |cls| </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/Subclasses.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,7 @@ using Microsoft.Scripting;
 using Microsoft.Scripting.Actions;
 using Microsoft.Scripting.Utils;
 using IronRuby.Builtins;
+using IronRuby.Runtime.Calls;
 using IronRuby.Runtime;
 using AstUtils = Microsoft.Scripting.Ast.Utils;
 
@@ -178,16 +179,15 @@ namespace IronRuby.Compiler.Ast {
         }
 
         internal override MSA.Expression TransformDefinedCondition(AstGenerator/*!*/ gen) {
-            if (_target != null) {
-                return gen.TryCatchAny(
-                    Methods.IsDefinedMethod.OpCall(
-                        AstFactory.Box(_target.TransformRead(gen)), gen.CurrentScopeVariable, AstUtils.Constant(_methodName)
-                    ),
-                    AstFactory.False
-                );
-            } else {
-                return Methods.IsDefinedMethod.OpCall(gen.CurrentSelfVariable, gen.CurrentScopeVariable, AstUtils.Constant(_methodName));
-            }
+            // MRI doesn't evaluate the arguments 
+            MSA.Expression result = Ast.Dynamic(
+                RubyCallAction.Make(gen.Context, _methodName, RubyCallSignature.IsDefined(_target == null)), 
+                typeof(bool),
+                gen.CurrentScopeVariable,
+                (_target != null) ? AstFactory.Box(_target.TransformRead(gen)) : gen.CurrentSelfVariable
+            );
+
+            return (_target != null) ? gen.TryCatchAny(result, AstFactory.False) : result;
         }
 
         internal override string/*!*/ GetNodeName(AstGenerator/*!*/ gen) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/MethodCall.cs</filename>
    </modified>
    <modified>
      <diff>@@ -24,10 +24,11 @@ using Microsoft.Scripting;
 using Microsoft.Scripting.Actions;
 using Microsoft.Scripting.Utils;
 using IronRuby.Builtins;
+using IronRuby.Runtime.Calls;
 using AstUtils = Microsoft.Scripting.Ast.Utils;
 
 namespace IronRuby.Compiler.Ast {
-    using Ast = Expression;
+    using Ast = MSA.Expression;
 
     /// &lt;summary&gt;
     /// super(args)
@@ -86,9 +87,13 @@ namespace IronRuby.Compiler.Ast {
         }
 
         internal override MSA.Expression/*!*/ TransformDefinedCondition(AstGenerator/*!*/ gen) {
-            // TODO:
-            //throw new NotImplementedError();
-            return AstUtils.Constant(false);
+            // MRI doesn't evaluate the arguments 
+            return Ast.Dynamic(
+                SuperCallAction.Make(gen.Context, RubyCallSignature.IsDefined(true), gen.CurrentFrame.UniqueId),
+                typeof(bool),
+                gen.CurrentScopeVariable,
+                gen.CurrentSelfVariable
+            );
         }
 
         internal override string/*!*/ GetNodeName(AstGenerator/*!*/ gen) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/SuperCall.cs</filename>
    </modified>
    <modified>
      <diff>@@ -2020,7 +2020,12 @@ namespace IronRuby.Compiler {
                 }
             }
 
-            return options | encoding;
+            // encoding is ignored in 1.9:
+            if (_compatibility == RubyCompatibility.Ruby18) {
+                return options | encoding;
+            } else {
+                return options;
+            }
         }
 
         #endregion</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Tokenizer.cs</filename>
    </modified>
    <modified>
      <diff>@@ -48,6 +48,8 @@ namespace IronRuby.Compiler {
         private static MethodInfo _ConvertBignumToFixnum;
         public static MethodInfo/*!*/ ConvertBignumToFloat { get { return _ConvertBignumToFloat ?? (_ConvertBignumToFloat = GetMethod(typeof(RubyOps), &quot;ConvertBignumToFloat&quot;)); } }
         private static MethodInfo _ConvertBignumToFloat;
+        public static MethodInfo/*!*/ ConvertCharToFloat { get { return _ConvertCharToFloat ?? (_ConvertCharToFloat = GetMethod(typeof(RubyOps), &quot;ConvertCharToFloat&quot;)); } }
+        private static MethodInfo _ConvertCharToFloat;
         public static MethodInfo/*!*/ ConvertDoubleToFixnum { get { return _ConvertDoubleToFixnum ?? (_ConvertDoubleToFixnum = GetMethod(typeof(RubyOps), &quot;ConvertDoubleToFixnum&quot;)); } }
         private static MethodInfo _ConvertDoubleToFixnum;
         public static MethodInfo/*!*/ ConvertFixnumToSymbol { get { return _ConvertFixnumToSymbol ?? (_ConvertFixnumToSymbol = GetMethod(typeof(RubyOps), &quot;ConvertFixnumToSymbol&quot;)); } }
@@ -310,8 +312,6 @@ namespace IronRuby.Compiler {
         private static MethodInfo _IsDefinedGlobalVariable;
         public static MethodInfo/*!*/ IsDefinedInstanceVariable { get { return _IsDefinedInstanceVariable ?? (_IsDefinedInstanceVariable = GetMethod(typeof(RubyOps), &quot;IsDefinedInstanceVariable&quot;)); } }
         private static MethodInfo _IsDefinedInstanceVariable;
-        public static MethodInfo/*!*/ IsDefinedMethod { get { return _IsDefinedMethod ?? (_IsDefinedMethod = GetMethod(typeof(RubyOps), &quot;IsDefinedMethod&quot;)); } }
-        private static MethodInfo _IsDefinedMethod;
         public static MethodInfo/*!*/ IsDefinedQualifiedConstant { get { return _IsDefinedQualifiedConstant ?? (_IsDefinedQualifiedConstant = GetMethod(typeof(RubyOps), &quot;IsDefinedQualifiedConstant&quot;)); } }
         private static MethodInfo _IsDefinedQualifiedConstant;
         public static MethodInfo/*!*/ IsDefinedUnqualifiedConstant { get { return _IsDefinedUnqualifiedConstant ?? (_IsDefinedUnqualifiedConstant = GetMethod(typeof(RubyOps), &quot;IsDefinedUnqualifiedConstant&quot;)); } }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/ReflectionCache.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,8 @@ using IronRuby.Runtime;
 [assembly: InternalsVisibleTo(&quot;ClassInitGenerator&quot;)]
 #endif
 
+
 [assembly: SecurityTransparent]
 #if !CLR2 &amp;&amp; !SILVERLIGHT
 [assembly: SecurityRules(SecurityRuleSet.Level1)]
-#endif
\ No newline at end of file
+#endif</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Properties/AssemblyInfo.cs</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Ruby.Build.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,6 @@
     &lt;BaseAddress&gt;887095296&lt;/BaseAddress&gt;
     &lt;Silverlight3Path&gt;..\..\..\Utilities\Silverlight\x86ret&lt;/Silverlight3Path&gt;
     &lt;Silverlight4Path&gt;..\..\..\Utilities\Silverlight\v4-x86fre&lt;/Silverlight4Path&gt;
-    
     &lt;!-- The following two lines prevent csc.rsp and Microsoft.NETFramework.props from adding additional assembly references --&gt;
     &lt;NoConfig&gt;true&lt;/NoConfig&gt;
     &lt;AddAdditionalExplicitAssemblyReferences&gt;false&lt;/AddAdditionalExplicitAssemblyReferences&gt;
@@ -147,15 +146,15 @@
     &lt;Reference Include=&quot;System.Core&quot; Condition=&quot; '$(TargetFrameworkVersion)' == 'v4.0' &quot; /&gt;
   &lt;/ItemGroup&gt;
   &lt;ItemGroup Condition=&quot; '$(SilverlightBuild)' == 'true' &quot;&gt;
-    &lt;Reference Include=&quot;mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&quot; &gt;
+    &lt;Reference Include=&quot;mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&quot;&gt;
       &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;
       &lt;HintPath&gt;$(SilverlightPath)\mscorlib.dll&lt;/HintPath&gt;
     &lt;/Reference&gt;
-    &lt;Reference Include=&quot;System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&quot; &gt;
+    &lt;Reference Include=&quot;System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&quot;&gt;
       &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;
       &lt;HintPath&gt;$(SilverlightPath)\System.Net.dll&lt;/HintPath&gt;
     &lt;/Reference&gt;
-    &lt;Reference Include=&quot;System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&quot; &gt;
+    &lt;Reference Include=&quot;System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&quot;&gt;
       &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;
       &lt;HintPath&gt;$(SilverlightPath)\System.dll&lt;/HintPath&gt;
     &lt;/Reference&gt;
@@ -200,7 +199,6 @@
     &lt;Compile Include=&quot;Builtins\RubyBufferedStream.cs&quot; /&gt;
     &lt;Compile Include=&quot;Builtins\RubyEvent.Meta.cs&quot; /&gt;
     &lt;Compile Include=&quot;Builtins\DuplexStream.cs&quot; /&gt;
-    &lt;Compile Include=&quot;Builtins\GenericRegex.cs&quot; /&gt;
     &lt;Compile Include=&quot;Builtins\Hash.Subclass.cs&quot; /&gt;
     &lt;Compile Include=&quot;Builtins\RegexpTransformer.cs&quot; /&gt;
     &lt;Compile Include=&quot;Builtins\RubyArray.Subclass.cs&quot; /&gt;
@@ -463,4 +461,4 @@
   &lt;/Target&gt;
   &lt;Target Name=&quot;AfterBuild&quot;&gt;
   &lt;/Target&gt;
-&lt;/Project&gt;
+&lt;/Project&gt;
\ No newline at end of file</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -83,7 +83,7 @@ namespace IronRuby.Runtime {
             ContractUtils.RequiresArrayRange(chars, charIndex, byteCount, &quot;charIndex&quot;, &quot;byteCount&quot;);
 
             for (int i = 0; i &lt; byteCount; i++) {
-                chars[byteIndex + i] = (char)bytes[charIndex + i];
+                chars[charIndex + i] = (char)bytes[byteIndex + i];
             }
 
             return byteCount;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/BinaryEncoding.cs</filename>
    </modified>
    <modified>
      <diff>@@ -289,7 +289,7 @@ namespace IronRuby.Runtime.Calls {
                 new DynamicMetaObject(AstUtils.Constant(context), BindingRestrictions.Empty, context),
                 target,
                 args,
-                RubyCallSignature.Simple(callInfo.ArgumentCount)
+                RubyCallSignature.Interop(callInfo.ArgumentCount)
             ) {
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/CallArguments.cs</filename>
    </modified>
    <modified>
      <diff>@@ -32,6 +32,7 @@ using Microsoft.Scripting.Utils;
 using AstUtils = Microsoft.Scripting.Ast.Utils;
 
 namespace IronRuby.Runtime.Calls {
+    using AstFactory = IronRuby.Compiler.Ast.AstFactory;
     using Ast = Expression;
 
     public class RubyCallAction : RubyMetaBinder {
@@ -47,7 +48,7 @@ namespace IronRuby.Runtime.Calls {
         }
 
         public override Type/*!*/ ReturnType {
-            get { return typeof(object); }
+            get { return _signature.ResolveOnly ? typeof(bool) : typeof(object); }
         }
 
         internal protected RubyCallAction(RubyContext context, string/*!*/ methodName, RubyCallSignature signature) 
@@ -97,7 +98,9 @@ namespace IronRuby.Runtime.Calls {
         #region Precompiled Rules
 
         public override T BindDelegate&lt;T&gt;(CallSite&lt;T&gt;/*!*/ site, object[]/*!*/ args) {
-            if (Context == null || (Signature.Flags &amp; ~(RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasScope | RubyCallFlags.HasBlock)) != 0) {
+            if (Context == null || 
+                Signature.ResolveOnly ||
+                (Signature.Flags &amp; ~(RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasScope | RubyCallFlags.HasBlock)) != 0) {
                 return base.BindDelegate&lt;T&gt;(site, args);
             }
 
@@ -152,6 +155,11 @@ namespace IronRuby.Runtime.Calls {
                     return false;
                 }
 
+                if (args.Signature.ResolveOnly) {
+                    metaBuilder.Result = AstFactory.True;
+                    return true;    
+                }
+                
                 if (args.Signature.IsVirtualCall &amp;&amp; !method.Info.IsRubyMember) {
                     metaBuilder.Result = Ast.Field(null, Fields.ForwardToBase);
                     return true;
@@ -159,6 +167,9 @@ namespace IronRuby.Runtime.Calls {
 
                 method.Info.BuildCall(metaBuilder, args, methodName);
                 return true;
+            } else if (args.Signature.ResolveOnly) {
+                metaBuilder.Result = AstFactory.False;
+                return true;
             } else {
                 return BuildMethodMissingCall(metaBuilder, args, methodName, methodMissing, method.IncompatibleVisibility, false, defaultFallback);
             }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyCallAction.cs</filename>
    </modified>
    <modified>
      <diff>@@ -54,21 +54,26 @@ namespace IronRuby.Runtime.Calls {
     /// &lt;/summary&gt;
     public struct RubyCallSignature : IEquatable&lt;RubyCallSignature&gt; {
         private const int FlagsCount = 7;
-        private const int MaxArgumentCount = (int)(UInt32.MaxValue &gt;&gt; FlagsCount);
-        private const RubyCallFlags FlagsMask = (RubyCallFlags)(1 &lt;&lt; FlagsCount) - 1;
+
+        private const int ResolveOnlyArgumentCount = (int)(UInt32.MaxValue &gt;&gt; FlagsCount);
+        private const int MaxArgumentCount = ResolveOnlyArgumentCount - 1;
+        private const uint FlagsMask = (1 &lt;&lt; FlagsCount) - 1;
 
         private readonly uint _countAndFlags;
 
-        public bool HasImplicitSelf { get { return ((RubyCallFlags)_countAndFlags &amp; RubyCallFlags.HasImplicitSelf) != 0; } }
-        public bool HasScope { get { return ((RubyCallFlags)_countAndFlags &amp; RubyCallFlags.HasScope) != 0; } }
-        public bool HasBlock { get { return ((RubyCallFlags)_countAndFlags &amp; RubyCallFlags.HasBlock) != 0; } }
-        public bool HasSplattedArgument { get { return ((RubyCallFlags)_countAndFlags &amp; RubyCallFlags.HasSplattedArgument) != 0; } }
-        public bool HasRhsArgument { get { return ((RubyCallFlags)_countAndFlags &amp; RubyCallFlags.HasRhsArgument) != 0; } }
-        public bool IsInteropCall { get { return ((RubyCallFlags)_countAndFlags &amp; RubyCallFlags.IsInteropCall) != 0; } }
-        public bool IsVirtualCall { get { return ((RubyCallFlags)_countAndFlags &amp; RubyCallFlags.IsVirtualCall) != 0; } }
+        public bool HasImplicitSelf { get { return (_countAndFlags &amp; (uint)RubyCallFlags.HasImplicitSelf) != 0; } }
+        public bool HasScope { get { return (_countAndFlags &amp; (uint)RubyCallFlags.HasScope) != 0; } }
+        public bool HasBlock { get { return (_countAndFlags &amp; (uint)RubyCallFlags.HasBlock) != 0; } }
+        public bool HasSplattedArgument { get { return (_countAndFlags &amp; (uint)RubyCallFlags.HasSplattedArgument) != 0; } }
+        public bool HasRhsArgument { get { return (_countAndFlags &amp; (uint)RubyCallFlags.HasRhsArgument) != 0; } }
+        public bool IsInteropCall { get { return (_countAndFlags &amp; (uint)RubyCallFlags.IsInteropCall) != 0; } }
+        public bool IsVirtualCall { get { return (_countAndFlags &amp; (uint)RubyCallFlags.IsVirtualCall) != 0; } }
+
+        // defined? ignores arguments hence we can use one argument number (max) to represent resolve only sites:
+        public bool ResolveOnly { get { return ArgumentCount == ResolveOnlyArgumentCount; } }
 
-        public int ArgumentCount { get { return (int)_countAndFlags &gt;&gt; FlagsCount; } }
-        internal RubyCallFlags Flags { get { return (RubyCallFlags)_countAndFlags &amp; FlagsMask; } }
+        public int ArgumentCount { get { return (int)(_countAndFlags &gt;&gt; FlagsCount); } }
+        internal RubyCallFlags Flags { get { return (RubyCallFlags)(_countAndFlags &amp; FlagsMask); } }
         
         // total call-site arguments w/o RubyContext/RubyScope
         public int TotalArgumentCount {
@@ -81,15 +86,23 @@ namespace IronRuby.Runtime.Calls {
             }
         }
 
+        /// &lt;summary&gt;
+        /// Used by defined? operator applied on methods.
+        /// &lt;/summary&gt;
+        private RubyCallSignature(RubyCallFlags flags) {
+            Debug.Assert(((int)flags &gt;&gt; FlagsCount) == 0);
+            _countAndFlags = ((uint)ResolveOnlyArgumentCount &lt;&lt; FlagsCount) | (uint)flags;
+        }
+
         public RubyCallSignature(int argumentCount, RubyCallFlags flags) {
-            Debug.Assert(argumentCount &gt;= 0 &amp;&amp; argumentCount &lt; MaxArgumentCount);
+            Debug.Assert(argumentCount &gt;= 0 &amp;&amp; argumentCount &lt;= MaxArgumentCount);
             Debug.Assert(((int)flags &gt;&gt; FlagsCount) == 0);
 
             _countAndFlags = ((uint)argumentCount &lt;&lt; FlagsCount) | (uint)flags;
         }
 
         public RubyCallSignature(bool hasScope, bool hasImplicitSelf, int argumentCount, bool hasSplattedArgument, bool hasBlock, bool hasRhsArgument) {
-            Debug.Assert(argumentCount &gt;= 0 &amp;&amp; argumentCount &lt; MaxArgumentCount);
+            Debug.Assert(argumentCount &gt;= 0 &amp;&amp; argumentCount &lt;= MaxArgumentCount);
 
             var flags = RubyCallFlags.None;
             if (hasImplicitSelf) flags |= RubyCallFlags.HasImplicitSelf;
@@ -151,6 +164,10 @@ namespace IronRuby.Runtime.Calls {
             return new RubyCallSignature(argumentCount, RubyCallFlags.HasScope | RubyCallFlags.HasBlock | RubyCallFlags.HasSplattedArgument);
         }
 
+        public static RubyCallSignature IsDefined(bool hasImplicitSelf) {
+            return new RubyCallSignature(RubyCallFlags.HasScope | (hasImplicitSelf ? RubyCallFlags.HasImplicitSelf : RubyCallFlags.None));
+        }
+
         internal Expression/*!*/ CreateExpression() {
             return Ast.New(Methods.RubyCallSignatureCtor, AstUtils.Constant(_countAndFlags));
         }
@@ -163,8 +180,8 @@ namespace IronRuby.Runtime.Calls {
             return &quot;(&quot; +
                 (HasImplicitSelf ? &quot;.&quot; : &quot;&quot;) +
                 (IsVirtualCall ? &quot;V&quot; : &quot;&quot;) +
-                (HasScope ? &quot;S,&quot; : &quot;C,&quot;) +
-                ArgumentCount.ToString() + 
+                (HasScope ? &quot;S&quot; : &quot;C&quot;) +
+                (ResolveOnly ? &quot;?&quot; : &quot;,&quot; + ArgumentCount.ToString()) + 
                 (HasSplattedArgument ? &quot;*&quot; : &quot;&quot;) + 
                 (HasBlock ? &quot;&amp;&quot; : &quot;&quot;) + 
                 (HasRhsArgument ? &quot;=&quot; : &quot;&quot;) + </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyCallSignature.cs</filename>
    </modified>
    <modified>
      <diff>@@ -68,16 +68,15 @@ namespace IronRuby.Runtime.Calls {
         }
 
         internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
-            Expression expr = null;
             Expression instance = _fieldInfo.IsStatic ? null : Ast.Convert(args.TargetExpression, _fieldInfo.DeclaringType);
 
             if (_isSetter) {
-                // parameters should be: instance/type, value
-                if (args.SimpleArgumentCount == 0 &amp;&amp; args.Signature.HasRhsArgument) {
-                    expr = Ast.Assign(
+                var actualArgs = RubyOverloadResolver.NormalizeArguments(metaBuilder, args, 1, 1);
+                if (!metaBuilder.Error) {
+                    metaBuilder.Result = Ast.Assign(
                         Ast.Field(instance, _fieldInfo),
                         Converter.ConvertExpression(
-                            args.GetRhsArgumentExpression(), 
+                            actualArgs[0].Expression, 
                             _fieldInfo.FieldType,
                             args.RubyContext, 
                             args.MetaContext.Expression,
@@ -86,26 +85,18 @@ namespace IronRuby.Runtime.Calls {
                     );
                 }
             } else {
-                // parameter should be: instance/type
-                if (args.SimpleArgumentCount == 0) {
+                RubyOverloadResolver.NormalizeArguments(metaBuilder, args, 0, 0);
+                if (!metaBuilder.Error) {
                     if (_fieldInfo.IsLiteral) {
                         // TODO: seems like Compiler should correctly handle the literal field case
                         // (if you emit a read to a literal field, you get a NotSupportedExpception from
                         // FieldHandle when we try to emit)
-                        expr = AstUtils.Constant(_fieldInfo.GetValue(null));
+                        metaBuilder.Result = AstUtils.Constant(_fieldInfo.GetValue(null));
                     } else {
-                        expr = Ast.Field(instance, _fieldInfo);
+                        metaBuilder.Result = Ast.Field(instance, _fieldInfo);
                     }
                 }
             }
-
-            if (expr != null) {
-                metaBuilder.Result = expr;
-            } else {
-                metaBuilder.SetError(
-                    Methods.MakeInvalidArgumentTypesError.OpCall(AstUtils.Constant(_isSetter ? name + &quot;=&quot; : name))
-                );
-            }
         }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyFieldInfo.cs</filename>
    </modified>
    <modified>
      <diff>@@ -145,6 +145,7 @@ namespace IronRuby.Runtime.Calls {
         /// Method definition that replaces/overrides this method will cause version update of all dependent subclasses/modules, which
         /// triggers invalidation of sites that are bound to those classes.
         /// &lt;/summary&gt;
+        [DebuggerDisplay(&quot;{_invalidateSitesOnOverride}&quot;)]
         internal bool InvalidateSitesOnOverride {
             get {
                 Context.RequiresClassHierarchyLock();</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs</filename>
    </modified>
    <modified>
      <diff>@@ -437,8 +437,8 @@ namespace IronRuby.Runtime.Calls {
             Type typeTwo = candidateTwo.Type;
             Type actualType = arg.GetLimitType();
 
-            // if nil is passed as a block argument prefer BlockParam over missing block:
             if (actualType == typeof(DynamicNull)) {
+                // if nil is passed as a block argument prefers BlockParam over a missing block:
                 if (typeOne == typeof(BlockParam) &amp;&amp; typeTwo == typeof(MissingBlockParam)) {
                     Debug.Assert(!candidateOne.ProhibitNull);
                     return Candidate.One;
@@ -448,31 +448,34 @@ namespace IronRuby.Runtime.Calls {
                     Debug.Assert(!candidateTwo.ProhibitNull);
                     return Candidate.Two;
                 }
-            } else if (actualType == typeof(MissingBlockParam)) {
-                if (typeOne == typeof(BlockParam) &amp;&amp; typeTwo == typeof(MissingBlockParam)) {
+            } else {
+                if (typeOne == actualType) {
+                    if (typeTwo == actualType) {
+                        // prefer non-nullable reference type over nullable:
+                        if (!actualType.IsValueType) {
+                            if (candidateOne.ProhibitNull) {
+                                return Candidate.One;
+                            } else if (candidateTwo.ProhibitNull) {
+                                return Candidate.Two;
+                            }
+                        }
+                    } else {
+                        return Candidate.One;
+                    }
+                } else if (typeTwo == actualType) {
                     return Candidate.Two;
                 }
+            }
 
-                if (typeOne == typeof(MissingBlockParam) &amp;&amp; typeTwo == typeof(BlockParam)) {
-                    return Candidate.One;
-                }
-            } else if (actualType == typeof(BlockParam)) {
-                if (typeOne == typeof(BlockParam) &amp;&amp; typeTwo == typeof(MissingBlockParam)) {
-                    return Candidate.One;
-                }
-
-                if (typeOne == typeof(MissingBlockParam) &amp;&amp; typeTwo == typeof(BlockParam)) {
-                    return Candidate.Two;
-                }
+            // prefer integer type over enum:
+            if (typeOne.IsEnum &amp;&amp; Enum.GetUnderlyingType(typeOne) == typeTwo) {
+                return Candidate.Two;
+            }
 
-                if (typeOne == typeof(BlockParam) &amp;&amp; typeTwo == typeof(BlockParam)) {
-                    if (candidateOne.ProhibitNull) {
-                        return Candidate.One;
-                    } else if (candidateTwo.ProhibitNull) {
-                        return Candidate.Two;
-                    }
-                }
+            if (typeTwo.IsEnum &amp;&amp; Enum.GetUnderlyingType(typeTwo) == typeOne) {
+                return Candidate.One;
             }
+
             return base.SelectBestConversionFor(arg, candidateOne, candidateTwo, level);
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyOverloadResolver.cs</filename>
    </modified>
    <modified>
      <diff>@@ -63,7 +63,7 @@ namespace IronRuby.Runtime.Calls {
         }
 
         public override Type/*!*/ ReturnType {
-            get { return typeof(object); }
+            get { return _signature.ResolveOnly ? typeof(bool) : typeof(object); }
         }
 
         #region Rule Generation
@@ -109,6 +109,12 @@ namespace IronRuby.Runtime.Calls {
                 metaBuilder.TreatRestrictionsAsConditions = false;
 
                 method = targetClass.ResolveSuperMethodNoLock(currentMethodName, currentDeclaringModule).InvalidateSitesOnOverride().Info;
+
+                if (_signature.ResolveOnly) {
+                    metaBuilder.Result = AstUtils.Constant(method != null);
+                    return true;
+                }
+
                 if (method == null) {
                     // MRI: method_missing is called for the targetClass, not for the super:
                     methodMissing = targetClass.ResolveMethodMissingForSite(currentMethodName, RubyMethodVisibility.None);</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/SuperCallAction.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,7 @@ namespace IronRuby.Runtime.Conversions {
         Byte = 2,
         Int16 = 3,
         UInt16 = 4,
+        // System::Char is treated like a single-character string and not a numeric type
         Int32 = 5,
         UInt32 = 6,
         Int64 = 7,
@@ -115,7 +116,7 @@ namespace IronRuby.Runtime.Conversions {
         append_generated result
     end
 #endif
-            #region Generated by C:/M2/Merlin/Main/Languages/Ruby/Ruby/Runtime/Converter.Generator.rb
+#region Generated by Converter.Generator.rb
             result[(int)NumericTypeCode.SByte] = (1 &lt;&lt; ((int)NumericTypeCode.Byte)) | (1 &lt;&lt; ((int)NumericTypeCode.UInt16)) | (1 &lt;&lt; ((int)NumericTypeCode.UInt32)) | (1 &lt;&lt; ((int)NumericTypeCode.UInt64));
             result[(int)NumericTypeCode.Byte] = (1 &lt;&lt; ((int)NumericTypeCode.SByte));
             result[(int)NumericTypeCode.Int16] = (1 &lt;&lt; ((int)NumericTypeCode.SByte)) | (1 &lt;&lt; ((int)NumericTypeCode.Byte)) | (1 &lt;&lt; ((int)NumericTypeCode.UInt16)) | (1 &lt;&lt; ((int)NumericTypeCode.UInt32)) | (1 &lt;&lt; ((int)NumericTypeCode.UInt64));</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/Converter.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
-&#65279;require '../../Scripts/CodeGenerator.rb'
+&#65279;require '../../../Scripts/CodeGenerator.rb'
 
 expand_templates(__FILE__)
\ No newline at end of file</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/Converter.Generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -282,6 +282,12 @@ namespace IronRuby.Runtime.Conversions {
                         return Candidate.Two;
                     }
                     return Candidate.Equivalent;
+
+                case TypeCode.Char:
+                    if (t2 == typeof(string)) {
+                        return Candidate.Two;
+                    }
+                    return Candidate.Equivalent;
             }
             return Candidate.Equivalent;
         }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/Converter.cs</filename>
    </modified>
    <modified>
      <diff>@@ -32,6 +32,7 @@ using IronRuby.Runtime.Calls;
 
 namespace IronRuby.Runtime.Conversions {
     using Ast = Expression;
+    using Microsoft.Scripting.Generation;
 
     public sealed class GenericConversionAction : RubyConversionAction {
         private readonly Type/*!*/ _type;
@@ -92,7 +93,7 @@ namespace IronRuby.Runtime.Conversions {
                 metaBuilder.SetError(Methods.MakeTypeConversionError.OpCall(
                     contextExpression,
                     AstUtils.Convert(target.Expression, typeof(object)),
-                    Ast.Constant(toType)
+                    Ast.Constant(toType, typeof(Type))
                 ));
                 return true;
             }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/GenericConversionAction.cs</filename>
    </modified>
    <modified>
      <diff>@@ -88,6 +88,11 @@ namespace IronRuby.Runtime.Conversions {
             // TODO: 
             // nullable int (see Array#fill, Sockets:ConvertToSocketFlag, Kernel#open(perm=nil), File.chown, IO#read)
 
+            // TODO: do we want to use a default protocol for enums?
+            if (parameterType.IsEnum) {
+                return null;
+            }
+
             switch (Type.GetTypeCode(parameterType)) {
                 case TypeCode.SByte: return (factory) =&gt; factory.Conversion&lt;ConvertToSByteAction&gt;();
                 case TypeCode.Byte: return (factory) =&gt; factory.Conversion&lt;ConvertToByteAction&gt;();</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/ProtocolConversionAction.cs</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ namespace IronRuby.Runtime {
             _encoding = encoding;
         }
 
-        public static int GetCodePage(int firstChar) {
+        internal static int GetCodePage(int firstChar) {
             switch (firstChar) {
                 case 'E':
                 case 'e': return RubyEncoding.CodePageEUC;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/KCoding.cs</filename>
    </modified>
    <modified>
      <diff>@@ -577,13 +577,6 @@ namespace IronRuby.Runtime {
             owner.UndefineMethod(name);
         }
 
-        [Emitted] // MethodCall:
-        public static bool IsDefinedMethod(object self, RubyScope/*!*/ scope, string/*!*/ name) {
-            // MRI: this is different from UndefineMethod, it behaves like Kernel#method (i.e. doesn't use lexical scope):
-            // TODO: visibility
-            return scope.RubyContext.ResolveMethod(self, name, VisibilityContext.AllVisible).Found;
-        }
-
         #endregion
 
         #region Modules
@@ -1229,7 +1222,8 @@ namespace IronRuby.Runtime {
 
             var result = new TElement[list.Count];
             for (int i = 0; i &lt; result.Length; i++) {
-                result[i] = site.Target(site, list[i]);
+                object item = list[i];
+                result[i] = (item is TElement) ? (TElement)item : site.Target(site, item);
             }
 
             return result;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -635,24 +635,18 @@ namespace IronRuby.Runtime {
         internal MutableString GetCurrentMatchGroup(int index) {
             Debug.Assert(index &gt;= 0);
 
-            // we don't need to check index range, Groups indexer returns an unsuccessful group if out of range:
             var match = _currentMatch;
-            Group group;
-            if (match != null &amp;&amp; (group = match.Groups[index]).Success) {
-                return MutableString.Create(group.Value, match.Encoding).TaintBy(match.OriginalString);
-            }
-
-            return null;
+            return (match != null) ? match.GetGroupValue(index) : null;
         }
 
         internal MutableString GetCurrentMatchLastGroup() {
             var match = _currentMatch;
             if (match != null) {
                 // TODO: cache the last successful group index?
-                for (int i = match.Groups.Count - 1; i &gt;= 0; i--) {
-                    Group group = match.Groups[i];
-                    if (group.Success) {
-                        return MutableString.Create(group.Value, match.Encoding).TaintBy(match.OriginalString);
+                for (int i = match.GroupCount - 1; i &gt;= 0; i--) {
+                    MutableString result = match.GetGroupValue(i);
+                    if (result != null) {
+                        return result;
                     }
                 }
             }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs</filename>
    </modified>
    <modified>
      <diff>@@ -192,6 +192,15 @@ namespace IronRuby.Runtime {
             return context.GetInstanceData(obj).ObjectId;
         }
 
+        private const int CachedCharCount = 256;
+        private static object[] _charCache = new object[CachedCharCount];
+
+        public static object/*!*/ CharToObject(char ch) {
+            return (ch &lt; CachedCharCount) ? (_charCache[(int)ch] ?? (_charCache[(int)ch] = (object)ch)) : (object)ch;
+        }
+
+        
+
         #endregion
 
         #region Names</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -194,9 +194,14 @@ namespace IronRuby.Runtime {
             return copy;
         }
 
-        internal static int IndexOf(byte[]/*!*/ array, byte[]/*!*/ bytes, int start, int count) {
-            // TODO:
-            for (int i = start; i &lt; start + count - bytes.Length + 1; i++) {
+        /// &lt;summary&gt;
+        /// Implements the same behavior as String.IndexOf on ASCII strings.
+        /// &lt;/summary&gt;
+        internal static int IndexOf(byte[]/*!*/ array, int arrayLength, byte[]/*!*/ bytes, int start, int count) {
+            ContractUtils.RequiresArrayRange(arrayLength, start, count, &quot;start&quot;, &quot;count&quot;);
+
+            int finish = start + count - bytes.Length;
+            for (int i = start; i &lt;= finish; i++) {
                 bool match = true;
                 for (int j = 0; j &lt; bytes.Length; j++) {
                     if (bytes[j] != array[i + j]) {
@@ -212,14 +217,21 @@ namespace IronRuby.Runtime {
             return -1;
         }
 
-        internal static int LastIndexOf(byte[]/*!*/ array, byte[]/*!*/ bytes, int start, int count) {
-            // TODO:
-            int finish = start - count &lt; 0 ? bytes.Length - 1 : start - count + bytes.Length;
-            //for (int i = start; i &lt; start + count - bytes.Length + 1; i++) {
-            for (int i = start; i &gt;= finish; --i) {
+        /// &lt;summary&gt;
+        /// Implements the same behavior as String.LastIndexOf on ASCII strings.
+        /// &lt;/summary&gt;
+        internal static int LastIndexOf(byte[]/*!*/ array, int arrayLength, byte[]/*!*/ value, int start, int count) {
+            int finish = start - count + 1;
+            ContractUtils.RequiresArrayRange(arrayLength, finish, count, &quot;start&quot;, &quot;count&quot;);
+
+            if (value.Length == 0) {
+                return start;
+            }
+
+            for (int i = start - value.Length + 1; i &gt;= finish; i--) {
                 bool match = true;
-                for (int j = 0; j &lt; bytes.Length; j++) {
-                    if (bytes[j] != array[i + j]) {
+                for (int j = 0; j &lt; value.Length; j++) {
+                    if (value[j] != array[i + j]) {
                         match = false;
                         break;
                     }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,9 @@ class IRTest
        
     mspec_base = &quot;#{@root}\\..\\External.LCA_RESTRICTED\\Languages\\IronRuby\\mspec\\mspec\\bin\\mspec.bat ci -fd&quot;
     ir = &quot;\&quot;#{@bin}\\ir.exe\&quot; -v&quot;
+    if options[:parallel]
+      ir = &quot;cmd /K #{ir}&quot;
+    end
     @suites = {
       :Smoke =&gt; &quot;#{@root}\\Languages\\Ruby\\Tests\\Scripts\\irtest.bat&quot;,
       :Legacy =&gt; &quot;#{@root}\\Languages\\Ruby\\Tests\\run.bat&quot;,
@@ -138,7 +141,7 @@ class IRTest
     test = @suites[suite]
     cmd = nil
     if options[:parallel]
-      cmd = &quot;start \&quot;#{title}\&quot; #{test}&quot;
+      cmd = &quot;start /BELOWNORMAL \&quot;#{title}\&quot; #{test}&quot;
     else
       puts title
       cmd = test</diff>
      <filename>Merlin/Main/Languages/Ruby/Scripts/irtests.rb</filename>
    </modified>
    <modified>
      <diff>@@ -434,7 +434,10 @@ no_csc do
         it &quot;passes the correct input (#{input}) into method (#{meth}) (ClassWithMethods)&quot; do
           value = @values[input]
           meth_call = (input == &quot;NoArg&quot; ? lambda { @target.send(meth)} : lambda {@target.send(meth, value)})
+          
+          # calls the C# method
           res, ref = meth_call.call
+          
           if input != &quot;NoArg&quot;
             result = Helper.result(meth,value)
             @target.tracker.should == [*result]
@@ -568,10 +571,23 @@ no_csc do
         [System::Byte, System::SByte, System::Int16, System::UInt16, System::UInt32, System::Int64, System::UInt64].each do |val|
           define_method(&quot;test_#{val.name.gsub(&quot;System::&quot;,&quot;&quot;)}Arg&quot;) {|v| val.induced_from(v.to_int) if test_value(v)}
         end
-
-        def method_missing(meth, *args, &amp;blk)
+        
+        def test_StringArg(arg)
+          case arg
+          when NilClass
+            nil
+          when Symbol
+            arg.to_s
+          when Fixnum
+            arg.to_sym.to_s
+          else
+            arg.to_str
+          end
+        end
+        
+        def method_missing(meth, arg)
           if meth =~ /test_.*?Arg/
-            value
+            arg
           end
         end
         </diff>
      <filename>Merlin/Main/Languages/Ruby/Tests/Interop/net/method/fixtures/classes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -281,15 +281,6 @@ class LegacyRouteSetTests
 
 end
 
-class LinkToUnlessCurrentWithControllerTest
-  # NoMethodError: protected method `default_url_options' called for #&lt;LinkToUnlessCurrentWithControllerTest::TasksController:0x0043838 @before_filter_chain_aborted=false, @performed_redirect=false, @performed_render=false, @_request=#&lt;ActionController::TestRequest:0x00437ac @env={&quot;rack.version&quot;=&gt;[0, 1], &quot;rack.input&quot;=&gt;IronRuby.StandardLibrary.StringIO.StringIO, &quot;rack.errors&quot;=&gt;IronRuby.StandardLibrary.S
-  def test_link_to_unless_current_shows_link() end
-
-  # NoMethodError: protected method `default_url_options' called for #&lt;LinkToUnlessCurrentWithControllerTest::TasksController:0x00438ee @before_filter_chain_aborted=false, @performed_redirect=false, @performed_render=false, @_request=#&lt;ActionController::TestRequest:0x0043862 @env={&quot;rack.version&quot;=&gt;[0, 1], &quot;rack.input&quot;=&gt;IronRuby.StandardLibrary.StringIO.StringIO, &quot;rack.errors&quot;=&gt;IronRuby.StandardLibrary.S
-  def test_link_to_unless_current_to_current() end
-
-end
-
 class MultipartParamsParsingTest
   # NoMethodError: undefined method `stat' for #&lt;File:c:/github/ironruby/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/RailsTests-2.3.3/actionpack/test/controller/request/../../fixtures/multipart/none&gt;
   def test_does_not_create_tempfile_if_no_file_has_been_selected() end
@@ -334,15 +325,6 @@ class PageCachingTest
 
 end
 
-class PolymorphicControllerTest
-  # NoMethodError: protected method `default_url_options' called for #&lt;PolymorphicControllerTest::SessionsController:0x0046aec @before_filter_chain_aborted=false, @performed_redirect=false, @performed_render=false, @_request=#&lt;ActionController::TestRequest:0x00469ac @env={&quot;rack.version&quot;=&gt;[0, 1], &quot;rack.input&quot;=&gt;IronRuby.StandardLibrary.StringIO.StringIO, &quot;rack.errors&quot;=&gt;IronRuby.StandardLibrary.StringIO.S
-  def test_new_nested_resource() end
-
-  # NoMethodError: protected method `default_url_options' called for #&lt;PolymorphicControllerTest::WorkshopsController:0x0046c52 @before_filter_chain_aborted=false, @performed_redirect=false, @performed_render=false, @_request=#&lt;ActionController::TestRequest:0x0046b12 @env={&quot;rack.version&quot;=&gt;[0, 1], &quot;rack.input&quot;=&gt;IronRuby.StandardLibrary.StringIO.StringIO, &quot;rack.errors&quot;=&gt;IronRuby.StandardLibrary.StringIO.
-  def test_new_resource() end
-
-end
-
 class ReloadableRenderTest
   # &lt;&quot;undefined method `doesnt_exist' for #&lt;ActionView::Base:0x004d78c @_rendered={:template=&gt;#&lt;ActionView::ReloadableTemplate:0x004d816 @template_path=\&quot;test/_raise.html.erb\&quot;, @load_path=\&quot;c:/github/ironruby/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/RailsTests-2.3.3/actionpack/test/fixtures\&quot;, @base_path=\&quot;test\&quot;, @name=\&quot;_raise\&quot;, @locale=nil, @format=\&quot;html\&quot;, @extension=\&quot;erb\&quot;, @_memoized
   def test_render_partial_with_errors() end
@@ -383,15 +365,6 @@ class TestTest
   def test_fixture_file_upload() end
 end
 
-class UrlHelperWithControllerTest
-  # NoMethodError: protected method `default_url_options' called for #&lt;UrlHelperWithControllerTest::UrlHelperController:0x006195a @before_filter_chain_aborted=false, @performed_redirect=false, @performed_render=false, @_request=#&lt;ActionController::TestRequest:0x0061928 @env={&quot;rack.version&quot;=&gt;[0, 1], &quot;rack.input&quot;=&gt;IronRuby.StandardLibrary.StringIO.StringIO, &quot;rack.errors&quot;=&gt;IronRuby.StandardLibrary.StringI
-  def test_named_route_path_shows_only_path() end
-
-  # NoMethodError: protected method `default_url_options' called for #&lt;UrlHelperWithControllerTest::UrlHelperController:0x0061a04 @before_filter_chain_aborted=false, @performed_redirect=false, @performed_render=false, @_request=#&lt;ActionController::TestRequest:0x00619d4 @env={&quot;rack.version&quot;=&gt;[0, 1], &quot;rack.input&quot;=&gt;IronRuby.StandardLibrary.StringIO.StringIO, &quot;rack.errors&quot;=&gt;IronRuby.StandardLibrary.StringI
-  def test_named_route_url_shows_host_and_path() end
-
-end
-
 class UrlWriterTests
   # &lt;&quot;http://www.basecamphq.com/&quot;&gt; expected but was
   # &lt;&quot;http://www.basecamphq.com/posts&quot;&gt;.</diff>
      <filename>Merlin/Main/Languages/Ruby/Tests/Scripts/ActionPackTests.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,7 @@ using System.Security;
 using System.Security.Permissions;
 using Microsoft.Scripting.Utils;
 using ComTypes = System.Runtime.InteropServices.ComTypes;
+using Microsoft.Scripting.Generation;
 
 namespace Microsoft.Scripting.ComInterop {
 
@@ -258,127 +259,93 @@ namespace Microsoft.Scripting.ComInterop {
 
             #region public members
 
+        private static readonly MethodInfo _ConvertByrefToPtr = Create_ConvertByrefToPtr();
+
+        public delegate IntPtr ConvertByrefToPtrDelegate&lt;T&gt;(ref T value);
+
+        private static readonly ConvertByrefToPtrDelegate&lt;Variant&gt; _ConvertVariantByrefToPtr = (ConvertByrefToPtrDelegate&lt;Variant&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Variant&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Variant)));
+
+        private static MethodInfo Create_ConvertByrefToPtr() {
+            // We dont use AssemblyGen.DefineMethod since that can create a anonymously-hosted DynamicMethod which cannot contain unverifiable code.
+            TypeBuilder type = Snippets.Shared.DefineType(&quot;Type$ConvertByrefToPtr&quot;, typeof(object), false, false).TypeBuilder;
+
+            Type[] paramTypes = new Type[] { typeof(Variant).MakeByRefType() };
+            MethodBuilder mb = type.DefineMethod(&quot;ConvertByrefToPtr&quot;, MethodAttributes.Public | MethodAttributes.Static, typeof(IntPtr), paramTypes);
+            GenericTypeParameterBuilder[] typeParams = mb.DefineGenericParameters(&quot;T&quot;);
+            typeParams[0].SetGenericParameterAttributes(GenericParameterAttributes.NotNullableValueTypeConstraint);
+            mb.SetSignature(typeof(IntPtr), null, null, new Type[] { typeParams[0].MakeByRefType() }, null, null);
+
+            ILGenerator method = mb.GetILGenerator();
+
+            method.Emit(OpCodes.Ldarg_0);
+            method.Emit(OpCodes.Conv_I);
+            method.Emit(OpCodes.Ret);
+
+            return type.CreateType().GetMethod(&quot;ConvertByrefToPtr&quot;);
+        }
+
+
+        #region Generated Convert ByRef Delegates
+
+        // *** BEGIN GENERATED CODE ***
+        // generated by function: gen_ConvertByrefToPtrDelegates from: generate_comdispatch.py
+
+        private static readonly ConvertByrefToPtrDelegate&lt;SByte&gt; _ConvertSByteByrefToPtr = (ConvertByrefToPtrDelegate&lt;SByte&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;SByte&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(SByte)));
+        private static readonly ConvertByrefToPtrDelegate&lt;Int16&gt; _ConvertInt16ByrefToPtr = (ConvertByrefToPtrDelegate&lt;Int16&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Int16&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Int16)));
+        private static readonly ConvertByrefToPtrDelegate&lt;Int32&gt; _ConvertInt32ByrefToPtr = (ConvertByrefToPtrDelegate&lt;Int32&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Int32&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Int32)));
+        private static readonly ConvertByrefToPtrDelegate&lt;Int64&gt; _ConvertInt64ByrefToPtr = (ConvertByrefToPtrDelegate&lt;Int64&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Int64&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Int64)));
+        private static readonly ConvertByrefToPtrDelegate&lt;Byte&gt; _ConvertByteByrefToPtr = (ConvertByrefToPtrDelegate&lt;Byte&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Byte&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Byte)));
+        private static readonly ConvertByrefToPtrDelegate&lt;UInt16&gt; _ConvertUInt16ByrefToPtr = (ConvertByrefToPtrDelegate&lt;UInt16&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;UInt16&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(UInt16)));
+        private static readonly ConvertByrefToPtrDelegate&lt;UInt32&gt; _ConvertUInt32ByrefToPtr = (ConvertByrefToPtrDelegate&lt;UInt32&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;UInt32&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(UInt32)));
+        private static readonly ConvertByrefToPtrDelegate&lt;UInt64&gt; _ConvertUInt64ByrefToPtr = (ConvertByrefToPtrDelegate&lt;UInt64&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;UInt64&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(UInt64)));
+        private static readonly ConvertByrefToPtrDelegate&lt;IntPtr&gt; _ConvertIntPtrByrefToPtr = (ConvertByrefToPtrDelegate&lt;IntPtr&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;IntPtr&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(IntPtr)));
+        private static readonly ConvertByrefToPtrDelegate&lt;UIntPtr&gt; _ConvertUIntPtrByrefToPtr = (ConvertByrefToPtrDelegate&lt;UIntPtr&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;UIntPtr&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(UIntPtr)));
+        private static readonly ConvertByrefToPtrDelegate&lt;Single&gt; _ConvertSingleByrefToPtr = (ConvertByrefToPtrDelegate&lt;Single&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Single&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Single)));
+        private static readonly ConvertByrefToPtrDelegate&lt;Double&gt; _ConvertDoubleByrefToPtr = (ConvertByrefToPtrDelegate&lt;Double&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Double&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Double)));
+        private static readonly ConvertByrefToPtrDelegate&lt;Decimal&gt; _ConvertDecimalByrefToPtr = (ConvertByrefToPtrDelegate&lt;Decimal&gt;)Delegate.CreateDelegate(typeof(ConvertByrefToPtrDelegate&lt;Decimal&gt;), _ConvertByrefToPtr.MakeGenericMethod(typeof(Decimal)));
+
+        // *** END GENERATED CODE ***
+
+        #endregion
+
         #region Generated Outer ConvertByrefToPtr
 
         // *** BEGIN GENERATED CODE ***
         // generated by function: gen_ConvertByrefToPtr from: generate_comdispatch.py
 
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertSByteByrefToPtr(ref SByte value) {
-            fixed (SByte *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertSByteByrefToPtr(ref SByte value) { return _ConvertSByteByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertInt16ByrefToPtr(ref Int16 value) {
-            fixed (Int16 *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertInt16ByrefToPtr(ref Int16 value) { return _ConvertInt16ByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        public static unsafe IntPtr ConvertInt32ByrefToPtr(ref Int32 value) {
-            fixed (Int32 *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertInt32ByrefToPtr(ref Int32 value) { return _ConvertInt32ByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertInt64ByrefToPtr(ref Int64 value) {
-            fixed (Int64 *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertInt64ByrefToPtr(ref Int64 value) { return _ConvertInt64ByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertByteByrefToPtr(ref Byte value) {
-            fixed (Byte *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertByteByrefToPtr(ref Byte value) { return _ConvertByteByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertUInt16ByrefToPtr(ref UInt16 value) {
-            fixed (UInt16 *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertUInt16ByrefToPtr(ref UInt16 value) { return _ConvertUInt16ByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertUInt32ByrefToPtr(ref UInt32 value) {
-            fixed (UInt32 *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertUInt32ByrefToPtr(ref UInt32 value) { return _ConvertUInt32ByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertUInt64ByrefToPtr(ref UInt64 value) {
-            fixed (UInt64 *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertUInt64ByrefToPtr(ref UInt64 value) { return _ConvertUInt64ByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertIntPtrByrefToPtr(ref IntPtr value) {
-            fixed (IntPtr *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertIntPtrByrefToPtr(ref IntPtr value) { return _ConvertIntPtrByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertUIntPtrByrefToPtr(ref UIntPtr value) {
-            fixed (UIntPtr *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertUIntPtrByrefToPtr(ref UIntPtr value) { return _ConvertUIntPtrByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertSingleByrefToPtr(ref Single value) {
-            fixed (Single *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertSingleByrefToPtr(ref Single value) { return _ConvertSingleByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertDoubleByrefToPtr(ref Double value) {
-            fixed (Double *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertDoubleByrefToPtr(ref Double value) { return _ConvertDoubleByrefToPtr(ref value); }
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        internal static unsafe IntPtr ConvertDecimalByrefToPtr(ref Decimal value) {
-            fixed (Decimal *x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
-
+        public static IntPtr ConvertDecimalByrefToPtr(ref Decimal value) { return _ConvertDecimalByrefToPtr(ref value); }
 
         // *** END GENERATED CODE ***
 
         #endregion
 
         [SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1045:DoNotPassTypesByReference&quot;)]
-        public static unsafe IntPtr ConvertVariantByrefToPtr(ref Variant value) {
-            fixed (Variant* x = &amp;value) {
-                AssertByrefPointsToStack(new IntPtr(x));
-                return new IntPtr(x);
-            }
-        }
+        public static IntPtr ConvertVariantByrefToPtr(ref Variant value) { return _ConvertVariantByrefToPtr(ref value); }
 
         internal static Variant GetVariantForObject(object obj) {
             Variant variant = default(Variant);
@@ -401,7 +368,7 @@ namespace Microsoft.Scripting.ComInterop {
                 return;
             }
 
-            System.Runtime.InteropServices.Marshal.GetNativeVariantForObject(obj, UnsafeMethods.ConvertVariantByrefToPtr(ref variant));
+            System.Runtime.InteropServices.Marshal.GetNativeVariantForObject(obj, ConvertVariantByrefToPtr(ref variant));
         }
 
         [Obsolete(&quot;do not use this method&quot;, true)]
@@ -521,7 +488,7 @@ namespace Microsoft.Scripting.ComInterop {
         /// allowed &quot;value&quot;  to be a pinned object.
         /// &lt;/summary&gt;
         [Conditional(&quot;DEBUG&quot;)]
-        private static void AssertByrefPointsToStack(IntPtr ptr) {
+        public static void AssertByrefPointsToStack(IntPtr ptr) {
             if (Marshal.ReadInt32(ptr) == _dummyMarker) {
                 // Prevent recursion
                 return;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/ComInterop/ComRuntimeHelpers.cs</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,9 @@ using System.Runtime.InteropServices;
 using System.Security;
 using System.Security.Permissions;
 using Microsoft.Scripting.Utils;
+using System.Reflection;
+using Microsoft.Scripting.Generation;
+using System.Reflection.Emit;
 
 namespace Microsoft.Scripting.ComInterop {
 </diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/ComInterop/Variant.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1030,9 +1030,9 @@ namespace Microsoft.Scripting.Interpreter {
         public override int ProducedStack { get { return 0; } }
 
         public override int Run(InterpretedFrame frame) {
+            T value = (T)frame.Pop();
             int index = (int)frame.Pop();
             T[] array = (T[])frame.Pop();
-            T value = (T)frame.Pop();
             array[index] = value;
             return +1;
         }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Interpreter/Instruction.cs</filename>
    </modified>
    <modified>
      <diff>@@ -73,13 +73,13 @@ namespace Microsoft.Scripting.Interpreter {
             }
         }
 
-        public object Run(InterpretedFrame frame) {
+        public void Run(InterpretedFrame frame) {
             if (_onlyFaultHandlers) {
                 bool fault = true;
                 try {
                     RunInstructions(frame);
                     fault = false;
-                    return frame.Pop();
+                    return;
                 } finally {
                     if (fault) {
                         frame.FaultingInstruction = frame.InstructionIndex;
@@ -90,7 +90,7 @@ namespace Microsoft.Scripting.Interpreter {
                 while (true) {
                     try {
                         RunInstructions(frame);
-                        return frame.Pop();
+                        return;
                     } catch (Exception exc) {
                         frame.FaultingInstruction = frame.InstructionIndex;
                         ExceptionHandler handler = HandleCatch(frame, exc);
@@ -104,7 +104,8 @@ namespace Microsoft.Scripting.Interpreter {
                         if (abort != null) {
                             _anyAbortException = abort;
                             frame.CurrentAbortHandler = handler;
-                            return Run(frame);
+                            Run(frame);
+                            return;
                         } 
                     }
                 }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs</filename>
    </modified>
    <modified>
      <diff>@@ -557,30 +557,55 @@ namespace Microsoft.Scripting.Interpreter {
             }
         }
 
-        private void CompileIndexAssignment(BinaryExpression node, bool asVoid) {
-            var index = (IndexExpression)node.Left;
+        private void CompileIndexExpression(Expression expr) {
+            var index = (IndexExpression)expr;
 
-            if (index.Indexer != null) {
-                throw new NotImplementedException();
+            // instance:
+            if (index.Object != null) {
+                Compile(index.Object);
             }
 
-            if (index.Arguments.Count &gt; 1) {
-                throw new NotImplementedException();
+            // indexes, byref args not allowed.
+            foreach (var arg in index.Arguments) {
+                Compile(arg);
             }
 
+            if (index.Indexer != null) {
+                AddInstruction(new CallInstruction(index.Indexer.GetGetMethod(true)));
+            } else if (index.Arguments.Count != 1) {
+                AddInstruction(new CallInstruction(index.Object.Type.GetMethod(&quot;Get&quot;, BindingFlags.Public | BindingFlags.Instance)));
+            } else {
+                AddInstruction(CreateGetArrayItemInstruction(index.Object.Type));
+            }
+        }
+
+        private void CompileIndexAssignment(BinaryExpression node, bool asVoid) {
+            var index = (IndexExpression)node.Left;
+
             if (!asVoid) {
                 throw new NotImplementedException();
             }
 
-            // TODO:
-            //Compile(node.Right);
-            //Compile(index.Object);
+            // instance:
+            if (index.Object != null) {
+                Compile(index.Object);
+            }
+
+            // indexes, byref args not allowed.
+            foreach (var arg in index.Arguments) {
+                Compile(arg);
+            }
 
-            //for (int i = 0; i &lt; index.Arguments.Count - 1; i++) {
-            //    Compile(index.Arguments[i]);
-            //}
+            // value:
+            Compile(node.Right);
 
-            CompileSetArrayItem(index.Object, index.Arguments[0], node.Right);            
+            if (index.Indexer != null) {
+                AddInstruction(new CallInstruction(index.Indexer.GetSetMethod(true)));
+            } else if (index.Arguments.Count != 1) {
+                AddInstruction(new CallInstruction(index.Object.Type.GetMethod(&quot;Set&quot;, BindingFlags.Public | BindingFlags.Instance)));
+            } else {
+                AddInstruction(CreateSetArrayItemInstruction(index.Object.Type));
+            }
         }
 
         private void CompileMemberAssignment(BinaryExpression node, bool asVoid) {
@@ -673,7 +698,10 @@ namespace Microsoft.Scripting.Interpreter {
             } else {
                 switch (node.NodeType) {
                     case ExpressionType.ArrayIndex:
-                        CompileArrayIndex(node.Left, node.Right);
+                        Debug.Assert(node.Right.Type == typeof(int));
+                        Compile(node.Left);
+                        Compile(node.Right);
+                        AddInstruction(CreateGetArrayItemInstruction(node.Left.Type));
                         return;
 
                     case ExpressionType.Equal:
@@ -748,51 +776,28 @@ namespace Microsoft.Scripting.Interpreter {
             throw new NotImplementedException();
         }
 
-        private void CompileArrayIndex(Expression array, Expression index) {
-            if (index.Type == typeof(int)) {
-                Type elemType = array.Type.GetElementType();
-                Compile(array);
-                Compile(index);
-                if (elemType.IsClass || elemType.IsInterface) {
-                    AddInstruction(GetArrayItemInstruction&lt;object&gt;.Instance);
-                } else if (elemType == typeof(bool)) {
-                    AddInstruction(GetArrayItemInstruction&lt;bool&gt;.Instance);
-                } else if (elemType == typeof(SymbolId)) {
-                    AddInstruction(GetArrayItemInstruction&lt;SymbolId&gt;.Instance);
-                } else {
-                    AddInstruction((Instruction)typeof(GetArrayItemInstruction&lt;&gt;).MakeGenericType(elemType).GetField(&quot;Instance&quot;).GetValue(null));
-                }
+        public Instruction CreateGetArrayItemInstruction(Type arrayType) {
+            Type elementType = arrayType.GetElementType();
+            if (elementType.IsClass || elementType.IsInterface) {
+                return GetArrayItemInstruction&lt;object&gt;.Instance;
+            } else if (elementType == typeof(bool)) {
+                return GetArrayItemInstruction&lt;bool&gt;.Instance;
+            } else if (elementType == typeof(SymbolId)) {
+                return GetArrayItemInstruction&lt;SymbolId&gt;.Instance;
             } else {
-                throw new NotImplementedException(&quot;ArrayIndex index type &quot; + index.Type);
+                return (Instruction)typeof(GetArrayItemInstruction&lt;&gt;).MakeGenericType(elementType).GetField(&quot;Instance&quot;).GetValue(null);
             }
         }
 
-        private void CompileSetArrayItem(Expression array, Expression index, Expression value) {
-            Type elemType = array.Type.GetElementType();
-            if ((elemType.IsClass || elemType.IsInterface) &amp;&amp; index.Type == typeof(int)) {
-                Compile(value);
-                Compile(array);
-                Compile(index);
-                AddInstruction(SetArrayItemInstruction&lt;object&gt;.Instance);
+        public Instruction CreateSetArrayItemInstruction(Type arrayType) {
+            Type elementType = arrayType.GetElementType();
+            if (elementType.IsClass || elementType.IsInterface) {
+                return SetArrayItemInstruction&lt;object&gt;.Instance;
             } else {
-                // TODO: this code doesn't work, we just need to visit the expressions and force compilation
-                _forceCompile = true;
+                return (Instruction)typeof(SetArrayItemInstruction&lt;&gt;).MakeGenericType(elementType).GetField(&quot;Instance&quot;).GetValue(null);
             }
         }
 
-
-        private void CompileIndexExpression(Expression expr) {
-            var node = (IndexExpression)expr;
-
-            if (node.Object.Type.IsArray &amp;&amp; node.Arguments.Count == 1) {
-                CompileArrayIndex(node.Object, node.Arguments[0]);
-                return;
-            }
-
-            throw new System.NotImplementedException();
-        }
-
-
         private void CompileConvertUnaryExpression(Expression expr) {
             var node = (UnaryExpression)expr;
             if (node.Method != null) {</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs</filename>
    </modified>
    <modified>
      <diff>@@ -33,7 +33,8 @@ namespace Microsoft.Scripting.Interpreter {
             }
 
             var frame = MakeFrame();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid0() {
@@ -60,7 +61,8 @@ namespace Microsoft.Scripting.Interpreter {
             var frame = MakeFrame();
             frame.Data[0] = arg0;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid1&lt;T0&gt;(T0 arg0) {
@@ -90,7 +92,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[0] = arg0;
             frame.Data[1] = arg1;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid2&lt;T0,T1&gt;(T0 arg0,T1 arg1) {
@@ -122,7 +125,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[1] = arg1;
             frame.Data[2] = arg2;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid3&lt;T0,T1,T2&gt;(T0 arg0,T1 arg1,T2 arg2) {
@@ -156,7 +160,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[2] = arg2;
             frame.Data[3] = arg3;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid4&lt;T0,T1,T2,T3&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3) {
@@ -192,7 +197,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[3] = arg3;
             frame.Data[4] = arg4;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid5&lt;T0,T1,T2,T3,T4&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4) {
@@ -230,7 +236,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[4] = arg4;
             frame.Data[5] = arg5;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid6&lt;T0,T1,T2,T3,T4,T5&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5) {
@@ -270,7 +277,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[5] = arg5;
             frame.Data[6] = arg6;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid7&lt;T0,T1,T2,T3,T4,T5,T6&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6) {
@@ -312,7 +320,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[6] = arg6;
             frame.Data[7] = arg7;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid8&lt;T0,T1,T2,T3,T4,T5,T6,T7&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7) {
@@ -356,7 +365,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[7] = arg7;
             frame.Data[8] = arg8;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid9&lt;T0,T1,T2,T3,T4,T5,T6,T7,T8&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8) {
@@ -402,7 +412,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[8] = arg8;
             frame.Data[9] = arg9;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid10&lt;T0,T1,T2,T3,T4,T5,T6,T7,T8,T9&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9) {
@@ -450,7 +461,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[9] = arg9;
             frame.Data[10] = arg10;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid11&lt;T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10) {
@@ -500,7 +512,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[10] = arg10;
             frame.Data[11] = arg11;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid12&lt;T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11) {
@@ -552,7 +565,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[11] = arg11;
             frame.Data[12] = arg12;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid13&lt;T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12) {
@@ -606,7 +620,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[12] = arg12;
             frame.Data[13] = arg13;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid14&lt;T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12,T13 arg13) {
@@ -662,7 +677,8 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[13] = arg13;
             frame.Data[14] = arg14;
             frame.BoxLocals();
-            return (TRet)_interpreter.Run(frame);
+            _interpreter.Run(frame);
+            return (TRet)frame.Pop();
         }
 
         internal void RunVoid15&lt;T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14&gt;(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12,T13 arg13,T14 arg14) {</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -181,7 +181,7 @@ namespace Microsoft.Scripting.Interpreter {
             frame.Data[0] = arg0;
             frame.Data[1] = arg1;
             frame.BoxLocals();
-            var ret = _interpreter.Run(frame);
+            _interpreter.Run(frame);
             arg0 = (T0)frame.Data[0];
             arg1 = (T1)frame.Data[1];
         }
@@ -197,8 +197,8 @@ namespace Microsoft.Scripting.Interpreter {
                 frame.Data[i] = arguments[i];
             }
             frame.BoxLocals();
-            object ret = _interpreter.Run(frame);
-            return ret;
+            _interpreter.Run(frame);
+            return frame.Pop();
         }
     }
 }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs</filename>
    </modified>
    <modified>
      <diff>@@ -231,11 +231,34 @@ namespace Microsoft.Scripting.Math {
             return Create(i);
         }
 
-        public static explicit operator double(BigInteger i) {
-            if (object.ReferenceEquals(i, null)) {
-                throw new ArgumentNullException(&quot;i&quot;);
+        public static explicit operator BigInteger(double self) {
+            return Create(self);
+        }
+
+        public static explicit operator BigInteger(float self) {
+            return Create((double)self);
+        }
+
+        public static explicit operator double(BigInteger self) {
+            if (object.ReferenceEquals(self, null)) {
+                throw new ArgumentNullException(&quot;self&quot;);
+            }
+            return self.ToFloat64();
+        }
+
+        public static explicit operator float(BigInteger self) {
+            if (object.ReferenceEquals(self, null)) {
+                throw new ArgumentNullException(&quot;self&quot;);
+            }
+            return checked((float)self.ToFloat64());
+        }
+
+        public static explicit operator decimal(BigInteger self) {
+            decimal res;
+            if (self.AsDecimal(out res)) {
+                return res;
             }
-            return i.ToFloat64();
+            throw new OverflowException();
         }
 
         public static explicit operator byte(BigInteger self) {
@@ -306,25 +329,6 @@ namespace Microsoft.Scripting.Math {
             throw new OverflowException();
         }
 
-        public static explicit operator float(BigInteger self) {
-            if (object.ReferenceEquals(self, null)) {
-                throw new ArgumentNullException(&quot;self&quot;);
-            }
-            return checked((float)self.ToFloat64());
-        }
-
-        public static explicit operator decimal(BigInteger self) {
-            decimal res;
-            if (self.AsDecimal(out res)) {
-                return res;
-            }
-            throw new OverflowException();
-        }
-
-        public static explicit operator BigInteger(double self) {
-            return Create(self);
-        }
-
         public BigInteger(BigInteger copy) {
             if (object.ReferenceEquals(copy, null)) {
                 throw new ArgumentNullException(&quot;copy&quot;);</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Math/BigIntegerV2.cs</filename>
    </modified>
    <modified>
      <diff>@@ -115,10 +115,19 @@ namespace Microsoft.Scripting.Math {
             return new BigInteger((BigInt)self);
         }
 
+        public static explicit operator BigInteger(float self) {
+            return new BigInteger((BigInt)self);
+        }
+
         public static explicit operator double(BigInteger self) {
             return (double)self._value;
         }
 
+
+        public static explicit operator float(BigInteger self) {
+            return (float)self._value;
+        }
+
         public static explicit operator byte(BigInteger self) {
             return (byte)self._value;
         }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Math/BigIntegerV4.cs</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,6 @@
     &lt;AssemblyOriginatorKeyFile&gt;..\..\Support\MSSharedLibKey.snk&lt;/AssemblyOriginatorKeyFile&gt;
     &lt;SignAssembly Condition=&quot;'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')&quot;&gt;true&lt;/SignAssembly&gt;
     &lt;SignedSym Condition=&quot;'$(SignAssembly)' == 'true'&quot;&gt;SIGNED&lt;/SignedSym&gt;
-    &lt;AllowUnsafeBlocks&gt;true&lt;/AllowUnsafeBlocks&gt;
     &lt;DelaySign&gt;true&lt;/DelaySign&gt;
     &lt;DefineConstants&gt;CLR4;$(SignedSym)&lt;/DefineConstants&gt;
     &lt;BaseAddress&gt;857735168&lt;/BaseAddress&gt;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.Build.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,6 @@
     &lt;SccProvider&gt;SAK&lt;/SccProvider&gt;
     &lt;WarningsNotAsErrors&gt;1685,618&lt;/WarningsNotAsErrors&gt;
     &lt;NoWarn&gt;1591&lt;/NoWarn&gt;
-    &lt;AllowUnsafeBlocks&gt;true&lt;/AllowUnsafeBlocks&gt;
     &lt;AssemblyOriginatorKeyFile&gt;..\..\Support\MSSharedLibKey.snk&lt;/AssemblyOriginatorKeyFile&gt;
     &lt;SignAssembly Condition=&quot;'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')&quot;&gt;true&lt;/SignAssembly&gt;
     &lt;SignedSym Condition=&quot;'$(SignAssembly)' == 'true'&quot;&gt;SIGNED&lt;/SignedSym&gt;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -18,6 +18,7 @@ using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Security;
+using System.Security.Permissions;
 
 // General Information about an assembly is controlled through the following 
 // set of attributes. Change these attribute values to modify the information</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs</filename>
    </modified>
    <modified>
      <diff>@@ -28,10 +28,15 @@ namespace Microsoft.Scripting.Utils {
         /// Creates a new ReflectedCaller which can be used to quickly invoke the provided MethodInfo.
         /// &lt;/summary&gt;
         public static ReflectedCaller Create(MethodInfo info) {
-            if ((!info.IsStatic &amp;&amp; info.DeclaringType.IsValueType) || 
-                info is System.Reflection.Emit.DynamicMethod) {
+            // A workaround for CLR bug #796414 (Unable to create delegates for Array.Get/Set):
+            // T[]::Address - not supported by ETs due to T&amp; return value
+            if (info.DeclaringType != null &amp;&amp; info.DeclaringType.IsArray &amp;&amp; (info.Name == &quot;Get&quot; || info.Name == &quot;Set&quot;)) {
+                return GetArrayAccessor(info);
+            }
+
+            if (info is DynamicMethod || !info.IsStatic &amp;&amp; info.DeclaringType.IsValueType) {
                 return new SlowReflectedCaller(info);
-            }            
+            }
 
             ParameterInfo[] pis = info.GetParameters();
             int argCnt = pis.Length;
@@ -88,6 +93,45 @@ namespace Microsoft.Scripting.Utils {
             return res;            
         }
 
+        private static ReflectedCaller GetArrayAccessor(MethodInfo info) {
+            Type arrayType = info.DeclaringType;
+            bool isGetter = info.Name == &quot;Get&quot;;
+            switch (arrayType.GetArrayRank()) {
+                case 1:
+                    return Create(isGetter ?
+                        arrayType.GetMethod(&quot;GetValue&quot;, new[] { typeof(int)}) :
+                        new Action&lt;Array, int, object&gt;(ArrayItemSetter1).Method
+                    );
+               
+                case 2: 
+                    return Create(isGetter ? 
+                        arrayType.GetMethod(&quot;GetValue&quot;, new[] { typeof(int), typeof(int) }) :
+                        new Action&lt;Array, int, int, object&gt;(ArrayItemSetter2).Method
+                    );
+
+                case 3: 
+                    return Create(isGetter ?
+                        arrayType.GetMethod(&quot;GetValue&quot;, new[] { typeof(int), typeof(int), typeof(int) }) :
+                        new Action&lt;Array, int, int, int, object&gt;(ArrayItemSetter3).Method
+                    );
+
+                default: 
+                    return new SlowReflectedCaller(info);
+            }
+        }
+
+        public static void ArrayItemSetter1(Array array, int index0, object value) {
+            array.SetValue(value, index0);
+        }
+
+        public static void ArrayItemSetter2(Array array, int index0, int index1, object value) {
+            array.SetValue(value, index0, index1);
+        }
+
+        public static void ArrayItemSetter3(Array array, int index0, int index1, int index2, object value) {
+            array.SetValue(value, index0, index1, index2);
+        }
+
         private static bool ShouldCache(MethodInfo info) {            
             return !(info is DynamicMethod);
         }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Utils/ReflectedCaller.cs</filename>
    </modified>
    <modified>
      <diff>@@ -761,7 +761,8 @@ namespace Microsoft.Scripting.Hosting {
 
         /// &lt;summary&gt;
         /// Converts the remote object into the specified type returning a handle to
-        /// the new remote object.
+        /// the new remote object. The conversion will be explicit or implicit depending on 
+        /// what the langauge prefers.
         /// &lt;/summary&gt;
         public ObjectHandle ConvertTo&lt;T&gt;([NotNull]ObjectHandle obj) {
             return new ObjectHandle(ConvertTo&lt;T&gt;(GetLocalObject(obj)));
@@ -769,7 +770,8 @@ namespace Microsoft.Scripting.Hosting {
 
         /// &lt;summary&gt;
         /// Converts the remote object into the specified type returning a handle to
-        /// the new remote object.
+        /// the new remote object. The conversion will be explicit or implicit depending on 
+        /// what the langauge prefers.
         /// &lt;/summary&gt;
         public ObjectHandle ConvertTo([NotNull]ObjectHandle obj, Type type) {
             return new ObjectHandle(ConvertTo(GetLocalObject(obj), type));
@@ -778,7 +780,8 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;summary&gt;
         /// Converts the remote object into the specified type returning a handle to
         /// the new remote object. Returns true if the value can be converted,
-        /// false if it cannot.
+        /// false if it cannot. The conversion will be explicit or implicit depending on 
+        /// what the langauge prefers.
         /// &lt;/summary&gt;
         public bool TryConvertTo&lt;T&gt;([NotNull]ObjectHandle obj, out ObjectHandle result) {
             T resultObj;
@@ -793,7 +796,8 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;summary&gt;
         /// Converts the remote object into the specified type returning a handle to
         /// the new remote object. Returns true if the value can be converted,
-        /// false if it cannot.
+        /// false if it cannot. The conversion will be explicit or implicit depending on 
+        /// what the langauge prefers.
         /// &lt;/summary&gt;
         public bool TryConvertTo([NotNull]ObjectHandle obj, Type type, out ObjectHandle result) {
             object resultObj;
@@ -854,6 +858,54 @@ namespace Microsoft.Scripting.Hosting {
         }
 
         /// &lt;summary&gt;
+        /// Converts the object obj to the type T including implicit conversions.
+        /// &lt;/summary&gt;
+        public ObjectHandle ImplicitConvertTo&lt;T&gt;([NotNull]ObjectHandle obj) {
+            return new ObjectHandle(_ops.ImplicitConvertTo&lt;T&gt;(GetLocalObject(obj)));
+        }
+
+        /// &lt;summary&gt;
+        /// Converts the object obj to the type type including implicit conversions.
+        /// &lt;/summary&gt;
+        public ObjectHandle ImplicitConvertTo([NotNull]ObjectHandle obj, Type type) {
+            ContractUtils.RequiresNotNull(type, &quot;type&quot;);
+
+            return new ObjectHandle(_ops.ImplicitConvertTo(GetLocalObject(obj), type));
+        }
+
+        /// &lt;summary&gt;
+        /// Converts the object obj to the type T including implicit conversions.
+        /// 
+        /// Returns true if the value can be converted, false if it cannot.
+        /// &lt;/summary&gt;
+        public bool TryImplicitConvertTo&lt;T&gt;([NotNull]ObjectHandle obj, out ObjectHandle result) {
+            T outp;
+            bool res = _ops.TryImplicitConvertTo&lt;T&gt;(GetLocalObject(obj), out outp);
+            if (res) {
+                result = new ObjectHandle(obj);
+            } else {
+                result = null;
+            }
+            return res;
+        }
+
+        /// &lt;summary&gt;
+        /// Converts the object obj to the type type including implicit conversions.  
+        /// 
+        /// Returns true if the value can be converted, false if it cannot.
+        /// &lt;/summary&gt;
+        public bool TryImplicitConvertTo([NotNull]ObjectHandle obj, Type type, out ObjectHandle result) {
+            object outp;
+            bool res = _ops.TryImplicitConvertTo(GetLocalObject(obj), type, out outp);
+            if (res) {
+                result = new ObjectHandle(obj);
+            } else {
+                result = null;
+            }
+            return res;
+        }
+
+        /// &lt;summary&gt;
         /// Unwraps the remote object and converts it into the specified type before
         /// returning it.
         /// &lt;/summary&gt;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Hosting/ObjectOperations.cs</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,6 @@
     &lt;DocumentationFile&gt;..\..\Bin\Release\Microsoft.Dynamic.xml&lt;/DocumentationFile&gt;
     &lt;WarningsNotAsErrors&gt;1685&lt;/WarningsNotAsErrors&gt;
     &lt;NoWarn&gt;1591&lt;/NoWarn&gt;
-    &lt;AllowUnsafeBlocks&gt;true&lt;/AllowUnsafeBlocks&gt;
     &lt;AssemblyOriginatorKeyFile&gt;..\..\Support\MSSharedLibKey.snk&lt;/AssemblyOriginatorKeyFile&gt;
     &lt;SignAssembly Condition=&quot;'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')&quot;&gt;true&lt;/SignAssembly&gt;
     &lt;SignedSym Condition=&quot;'$(SignAssembly)' == 'true'&quot;&gt;SIGNED&lt;/SignedSym&gt;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Microsoft.Scripting.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -198,6 +198,11 @@ namespace Microsoft.Scripting {
             public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
                 IScopeVariable variable = Value.GetVariable(binder.Name, binder.IgnoreCase);
                 var tmp = Expression.Parameter(typeof(object));
+                var fallback = binder.FallbackGetMember(this).Expression;
+                if (fallback.Type != typeof(object)) {
+                    // both types need to be object for condition
+                    fallback = Expression.Convert(fallback, typeof(object));
+                }
                 return new DynamicMetaObject(
                     Expression.Block(
                         new[] { tmp },
@@ -208,7 +213,7 @@ namespace Microsoft.Scripting {
                                 tmp
                             ),
                             tmp,
-                            binder.FallbackGetMember(this).Expression
+                            fallback
                         )
                     ),
                     BindingRestrictions.GetInstanceRestriction(Expression, Value)</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Runtime/ScopeStorage.cs</filename>
    </modified>
    <modified>
      <diff>@@ -70,7 +70,7 @@ namespace System.Dynamic {
 
             var argNameCol = argNames.ToReadOnly();
 
-            ContractUtils.Requires(argCount &gt;= argNameCol.Count, &quot;argCount&quot;, Strings.ArgCntMustBeGreaterThanNameCnt);
+            if (argCount &lt; argNameCol.Count) throw Error.ArgCntMustBeGreaterThanNameCnt();
             ContractUtils.RequiresNotNullItems(argNameCol, &quot;argNames&quot;);
 
             _argCount = argCount;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/CallInfo.cs</filename>
    </modified>
    <modified>
      <diff>@@ -99,7 +99,7 @@ namespace System.Runtime.CompilerServices {
         public static CallSite Create(Type delegateType, CallSiteBinder binder) {
             ContractUtils.RequiresNotNull(delegateType, &quot;delegateType&quot;);
             ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-            ContractUtils.Requires(delegateType.IsSubclassOf(typeof(Delegate)), &quot;delegateType&quot;, Strings.TypeMustBeDerivedFromSystemDelegate);
+            if (!delegateType.IsSubclassOf(typeof(Delegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();
 
             if (_SiteCtors == null) {
                 // It's okay to just set this, worst case we're just throwing away some data</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/CallSite.cs</filename>
    </modified>
    <modified>
      <diff>@@ -66,7 +66,7 @@ namespace System.Dynamic {
         /// &lt;param name=&quot;returnLabel&quot;&gt;A LabelTarget used to return the result of the dynamic binding.&lt;/param&gt;
         /// &lt;returns&gt;
         /// An Expression that performs tests on the dynamic operation arguments, and
-        /// performs the dynamic operation if hte tests are valid. If the tests fail on
+        /// performs the dynamic operation if the tests are valid. If the tests fail on
         /// subsequent occurrences of the dynamic operation, Bind will be called again
         /// to produce a new &lt;see cref=&quot;Expression&quot;/&gt; for the new argument types.
         /// &lt;/returns&gt;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/DynamicMetaObjectBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -580,13 +580,15 @@ namespace System.Dynamic {
             }
 
             /// &lt;summary&gt;
-            /// Returns our Expression converted to our known LimitType
+            /// Returns our Expression converted to DynamicObject
             /// &lt;/summary&gt;
             private Expression GetLimitedSelf() {
-                if (TypeUtils.AreEquivalent(Expression.Type, LimitType)) {
+                // Convert to DynamicObject rather than LimitType, because
+                // the limit type might be non-public.
+                if (TypeUtils.AreEquivalent(Expression.Type, typeof(DynamicObject))) {
                     return Expression;
                 }
-                return Expression.Convert(Expression, LimitType);
+                return Expression.Convert(Expression, typeof(DynamicObject));
             }
 
             private new DynamicObject Value {</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/DynamicObject.cs</filename>
    </modified>
    <modified>
      <diff>@@ -169,7 +169,7 @@ namespace System.Linq.Expressions {
             RequiresCanRead(body, &quot;body&quot;);
             if (filter != null) {
                 RequiresCanRead(filter, &quot;filter&quot;);
-                ContractUtils.Requires(filter.Type == typeof(bool), Strings.ArgumentMustBeBoolean);
+                if (filter.Type != typeof(bool)) throw Error.ArgumentMustBeBoolean();
             }
 
             return new CatchBlock(type, variable, body, filter);</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/CatchBlock.cs</filename>
    </modified>
    <modified>
      <diff>@@ -454,7 +454,7 @@ namespace System.Linq.Expressions {
         public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable&lt;Expression&gt; arguments) {
             ContractUtils.RequiresNotNull(delegateType, &quot;delegateType&quot;);
             ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-            ContractUtils.Requires(delegateType.IsSubclassOf(typeof(Delegate)), &quot;delegateType&quot;, Strings.TypeMustBeDerivedFromSystemDelegate);
+            if (!delegateType.IsSubclassOf(typeof(Delegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();
 
             var method = GetValidMethodForDynamic(delegateType);
 
@@ -480,7 +480,7 @@ namespace System.Linq.Expressions {
         public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0) {
             ContractUtils.RequiresNotNull(delegateType, &quot;delegatType&quot;);
             ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-            ContractUtils.Requires(delegateType.IsSubclassOf(typeof(Delegate)), &quot;delegateType&quot;, Strings.TypeMustBeDerivedFromSystemDelegate);
+            if (!delegateType.IsSubclassOf(typeof(Delegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();
 
             var method = GetValidMethodForDynamic(delegateType);
             var parameters = method.GetParametersCached();
@@ -509,7 +509,7 @@ namespace System.Linq.Expressions {
         public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1) {
             ContractUtils.RequiresNotNull(delegateType, &quot;delegatType&quot;);
             ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-            ContractUtils.Requires(delegateType.IsSubclassOf(typeof(Delegate)), &quot;delegateType&quot;, Strings.TypeMustBeDerivedFromSystemDelegate);
+            if (!delegateType.IsSubclassOf(typeof(Delegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();
 
             var method = GetValidMethodForDynamic(delegateType);
             var parameters = method.GetParametersCached();
@@ -541,7 +541,7 @@ namespace System.Linq.Expressions {
         public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2) {
             ContractUtils.RequiresNotNull(delegateType, &quot;delegatType&quot;);
             ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-            ContractUtils.Requires(delegateType.IsSubclassOf(typeof(Delegate)), &quot;delegateType&quot;, Strings.TypeMustBeDerivedFromSystemDelegate);
+            if (!delegateType.IsSubclassOf(typeof(Delegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();
 
             var method = GetValidMethodForDynamic(delegateType);
             var parameters = method.GetParametersCached();
@@ -576,7 +576,7 @@ namespace System.Linq.Expressions {
         public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
             ContractUtils.RequiresNotNull(delegateType, &quot;delegatType&quot;);
             ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-            ContractUtils.Requires(delegateType.IsSubclassOf(typeof(Delegate)), &quot;delegateType&quot;, Strings.TypeMustBeDerivedFromSystemDelegate);
+            if (!delegateType.IsSubclassOf(typeof(Delegate))) throw Error.TypeMustBeDerivedFromSystemDelegate();
 
             var method = GetValidMethodForDynamic(delegateType);
             var parameters = method.GetParametersCached();
@@ -597,7 +597,7 @@ namespace System.Linq.Expressions {
         private static MethodInfo GetValidMethodForDynamic(Type delegateType) {
             var method = delegateType.GetMethod(&quot;Invoke&quot;);
             var pi = method.GetParametersCached();
-            ContractUtils.Requires(pi.Length &gt; 0 &amp;&amp; pi[0].ParameterType == typeof(CallSite), &quot;delegateType&quot;, Strings.FirstArgumentMustBeCallSite);
+            if (pi.Length == 0 || pi[0].ParameterType != typeof(CallSite)) throw Error.FirstArgumentMustBeCallSite();
             return method;
         }
 
@@ -848,7 +848,7 @@ namespace System.Linq.Expressions {
             var type = arg.Type;
             ContractUtils.RequiresNotNull(type, &quot;type&quot;);
             TypeUtils.ValidateType(type);
-            ContractUtils.Requires(type != typeof(void), Strings.ArgumentTypeCannotBeVoid);
+            if (type == typeof(void)) throw Error.ArgumentTypeCannotBeVoid();
         }
     }
 }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/DynamicExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -141,7 +141,7 @@ namespace System.Linq.Expressions {
         /// &lt;/summary&gt;
         /// &lt;returns&gt;The reduced expression.&lt;/returns&gt;
         public virtual Expression Reduce() {
-            ContractUtils.Requires(!CanReduce, &quot;this&quot;, Strings.ReducibleMustOverrideReduce);
+            if (CanReduce) throw Error.ReducibleMustOverrideReduce();
             return this;
         }
 
@@ -158,7 +158,7 @@ namespace System.Linq.Expressions {
         /// itself with the modified children.
         /// &lt;/remarks&gt;
         protected internal virtual Expression VisitChildren(ExpressionVisitor visitor) {
-            ContractUtils.Requires(CanReduce, &quot;this&quot;, Strings.MustBeReducible);
+            if (!CanReduce) throw Error.MustBeReducible();
             return visitor.Visit(ReduceExtensions());
         }
 
@@ -191,14 +191,14 @@ namespace System.Linq.Expressions {
         /// certain invariants.
         /// &lt;/remarks&gt;
         public Expression ReduceAndCheck() {
-            ContractUtils.Requires(CanReduce, &quot;this&quot;, Strings.MustBeReducible);
+            if (!CanReduce) throw Error.MustBeReducible();
 
             var newNode = Reduce();
 
             // 1. Reduction must return a new, non-null node
             // 2. Reduction must return a new node whose result type can be assigned to the type of the original node
-            ContractUtils.Requires(newNode != null &amp;&amp; newNode != this, &quot;this&quot;, Strings.MustReduceToDifferent);
-            ContractUtils.Requires(TypeUtils.AreReferenceAssignable(Type, newNode.Type), &quot;this&quot;, Strings.ReducedNotCompatible);
+            if (newNode == null || newNode == this) throw Error.MustReduceToDifferent();
+            if (!TypeUtils.AreReferenceAssignable(Type, newNode.Type)) throw Error.ReducedNotCompatible();
             return newNode;
         }
 </diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/Expression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -354,7 +354,7 @@ namespace System.Linq.Expressions {
         private static void ValidateGoto(LabelTarget target, ref Expression value, string targetParameter, string valueParameter) {
             ContractUtils.RequiresNotNull(target, targetParameter);
             if (value == null) {
-                ContractUtils.Requires(target.Type == typeof(void), Strings.LabelMustBeVoidOrHaveExpression);
+                if (target.Type != typeof(void)) throw Error.LabelMustBeVoidOrHaveExpression();
             } else {
                 ValidateGotoType(target.Type, ref value, valueParameter);
             }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/GotoExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -359,8 +359,8 @@ namespace System.Linq.Expressions {
             // Accessor parameters cannot be ByRef.
 
             ContractUtils.RequiresNotNull(property, &quot;property&quot;);
-            ContractUtils.Requires(!property.PropertyType.IsByRef, &quot;property&quot;, Strings.PropertyCannotHaveRefType);
-            ContractUtils.Requires(property.PropertyType != typeof(void), &quot;property&quot;, Strings.PropertyTypeCannotBeVoid);
+            if (property.PropertyType.IsByRef) throw Error.PropertyCannotHaveRefType();
+            if (property.PropertyType == typeof(void)) throw Error.PropertyTypeCannotBeVoid();
 
             ParameterInfo[] getParameters = null;
             MethodInfo getter = property.GetGetMethod(true);
@@ -372,20 +372,20 @@ namespace System.Linq.Expressions {
             MethodInfo setter = property.GetSetMethod(true);
             if (setter != null) {
                 ParameterInfo[] setParameters = setter.GetParametersCached();
-                ContractUtils.Requires(setParameters.Length &gt; 0, &quot;property&quot;, Strings.SetterHasNoParams);
+                if (setParameters.Length == 0) throw Error.SetterHasNoParams();
 
                 // valueType is the type of the value passed to the setter (last parameter)
                 Type valueType = setParameters[setParameters.Length - 1].ParameterType;
-                ContractUtils.Requires(!valueType.IsByRef, &quot;property&quot;, Strings.PropertyCannotHaveRefType);
-                ContractUtils.Requires(setter.ReturnType == typeof(void), &quot;property&quot;, Strings.SetterMustBeVoid);
-                ContractUtils.Requires(property.PropertyType == valueType, &quot;property&quot;, Strings.PropertyTyepMustMatchSetter);
+                if (valueType.IsByRef) throw Error.PropertyCannotHaveRefType();
+                if (setter.ReturnType != typeof(void)) throw Error.SetterMustBeVoid();
+                if (property.PropertyType != valueType) throw Error.PropertyTyepMustMatchSetter();
 
                 if (getter != null) {
-                    ContractUtils.Requires(!(getter.IsStatic ^ setter.IsStatic), &quot;property&quot;, Strings.BothAccessorsMustBeStatic);
-                    ContractUtils.Requires(getParameters.Length == setParameters.Length - 1, &quot;property&quot;, Strings.IndexesOfSetGetMustMatch);
+                    if (getter.IsStatic ^ setter.IsStatic) throw Error.BothAccessorsMustBeStatic();
+                    if (getParameters.Length != setParameters.Length - 1) throw Error.IndexesOfSetGetMustMatch();
 
                     for (int i = 0; i &lt; getParameters.Length; i++) {
-                        ContractUtils.Requires(getParameters[i].ParameterType == setParameters[i].ParameterType, &quot;property&quot;, Strings.IndexesOfSetGetMustMatch);
+                        if (getParameters[i].ParameterType != setParameters[i].ParameterType) throw Error.IndexesOfSetGetMustMatch();
                     }
                 } else {
                     ValidateAccessor(instance, setter, setParameters.RemoveLast(), ref argList);
@@ -401,11 +401,11 @@ namespace System.Linq.Expressions {
             ContractUtils.RequiresNotNull(arguments, &quot;arguments&quot;);
 
             ValidateMethodInfo(method);
-            ContractUtils.Requires((method.CallingConvention &amp; CallingConventions.VarArgs) == 0, &quot;method&quot;, Strings.AccessorsCannotHaveVarArgs);
+            if ((method.CallingConvention &amp; CallingConventions.VarArgs) != 0) throw Error.AccessorsCannotHaveVarArgs();
             if (method.IsStatic) {
-                ContractUtils.Requires(instance == null, &quot;instance&quot;, Strings.OnlyStaticMethodsHaveNullInstance);
+                if (instance != null) throw Error.OnlyStaticMethodsHaveNullInstance();
             } else {
-                ContractUtils.Requires(instance != null, &quot;method&quot;, Strings.OnlyStaticMethodsHaveNullInstance);
+                if (instance == null) throw Error.OnlyStaticMethodsHaveNullInstance();
                 RequiresCanRead(instance, &quot;instance&quot;);
                 ValidateCallInstanceType(instance.Type, method);
             }
@@ -425,7 +425,7 @@ namespace System.Linq.Expressions {
                     RequiresCanRead(arg, &quot;arguments&quot;);
 
                     Type pType = pi.ParameterType;
-                    ContractUtils.Requires(!pType.IsByRef, &quot;indexes&quot;, Strings.AccessorsCannotHaveByRefArgs);
+                    if (pType.IsByRef) throw Error.AccessorsCannotHaveByRefArgs();
                     TypeUtils.ValidateType(pType);
 
                     if (!TypeUtils.AreReferenceAssignable(pType, arg.Type)) {</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/IndexExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -161,7 +161,7 @@ namespace System.Linq.Expressions {
             ContractUtils.RequiresNotNull(method, &quot;method&quot;);
             ContractUtils.Requires(method.IsStatic, &quot;method&quot;);
             var type = method.DeclaringType as TypeBuilder;
-            ContractUtils.Requires(type != null, &quot;method&quot;, Strings.MethodBuilderDoesNotHaveTypeBuilder);
+            if (type == null) throw Error.MethodBuilderDoesNotHaveTypeBuilder();
 
             LambdaCompiler.Compile(this, method, debugInfoGenerator);
         }
@@ -584,7 +584,7 @@ namespace System.Linq.Expressions {
         /// &lt;param name=&quot;typeArgs&quot;&gt;An array of Type objects that specify the type arguments for the System.Func delegate type.&lt;/param&gt;
         /// &lt;returns&gt;The type of a System.Func delegate that has the specified type arguments.&lt;/returns&gt;
         public static Type GetFuncType(params Type[] typeArgs) {
-            ContractUtils.Requires(ValidateTryGetFuncActionArgs(typeArgs), &quot;typeArgs&quot;, Strings.TypeMustNotBeByRef);
+            if (!ValidateTryGetFuncActionArgs(typeArgs)) throw Error.TypeMustNotBeByRef();
 
             Type result = DelegateHelpers.GetFuncType(typeArgs);
             if (result == null) {
@@ -614,7 +614,7 @@ namespace System.Linq.Expressions {
         /// &lt;param name=&quot;typeArgs&quot;&gt;An array of Type objects that specify the type arguments for the System.Action delegate type.&lt;/param&gt;
         /// &lt;returns&gt;The type of a System.Action delegate that has the specified type arguments.&lt;/returns&gt;
         public static Type GetActionType(params Type[] typeArgs) {
-            ContractUtils.Requires(ValidateTryGetFuncActionArgs(typeArgs), &quot;typeArgs&quot;, Strings.TypeMustNotBeByRef);
+            if (!ValidateTryGetFuncActionArgs(typeArgs)) throw Error.TypeMustNotBeByRef();
 
             Type result = DelegateHelpers.GetActionType(typeArgs);
             if (result == null) {</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/LambdaExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -134,7 +134,7 @@ namespace System.Linq.Expressions {
         /// &lt;returns&gt;The created &lt;see cref=&quot;LoopExpression&quot;/&gt;.&lt;/returns&gt;
         public static LoopExpression Loop(Expression body, LabelTarget @break, LabelTarget @continue) {
             RequiresCanRead(body, &quot;body&quot;);
-            ContractUtils.Requires(@continue == null || @continue.Type == typeof(void), &quot;continue&quot;, Strings.LabelTypeMustBeVoid);
+            if (@continue != null &amp;&amp; @continue.Type != typeof(void)) throw Error.LabelTypeMustBeVoid();
             return new LoopExpression(body, @break, @continue);
         }
     }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/LoopExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -149,9 +149,9 @@ namespace System.Linq.Expressions {
             ContractUtils.RequiresNotNull(field, &quot;field&quot;);
 
             if (field.IsStatic) {
-                ContractUtils.Requires(expression == null, &quot;expression&quot;, Strings.OnlyStaticFieldsHaveNullInstance);
+                if (expression != null) throw new ArgumentException(Strings.OnlyStaticFieldsHaveNullInstance, &quot;expression&quot;);
             } else {
-                ContractUtils.Requires(expression != null, &quot;field&quot;, Strings.OnlyStaticFieldsHaveNullInstance);
+                if (expression == null) throw new ArgumentException(Strings.OnlyStaticFieldsHaveNullInstance, &quot;field&quot;);
                 RequiresCanRead(expression, &quot;expression&quot;);
                 if (!TypeUtils.AreReferenceAssignable(field.DeclaringType, expression.Type)) {
                     throw Error.FieldInfoNotDefinedForType(field.DeclaringType, field.Name, expression.Type);
@@ -265,9 +265,9 @@ namespace System.Linq.Expressions {
             }
 
             if (mi.IsStatic) {
-                ContractUtils.Requires(expression == null, &quot;expression&quot;, Strings.OnlyStaticPropertiesHaveNullInstance); 
+                if (expression != null) throw new ArgumentException(Strings.OnlyStaticPropertiesHaveNullInstance, &quot;expression&quot;);
             } else {
-                ContractUtils.Requires(expression != null, &quot;property&quot;, Strings.OnlyStaticPropertiesHaveNullInstance);
+                if (expression == null) throw new ArgumentException(Strings.OnlyStaticPropertiesHaveNullInstance, &quot;property&quot;);
                 RequiresCanRead(expression, &quot;expression&quot;);
                 if (!TypeUtils.IsValidInstanceType(property, expression.Type)) {
                     throw Error.PropertyNotDefinedForType(property, expression.Type);</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/MemberExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -814,9 +814,9 @@ namespace System.Linq.Expressions {
 
         private static void ValidateStaticOrInstanceMethod(Expression instance, MethodInfo method) {
             if (method.IsStatic) {
-                ContractUtils.Requires(instance == null, &quot;instance&quot;, Strings.OnlyStaticMethodsHaveNullInstance);
+                if (instance != null) throw new ArgumentException(Strings.OnlyStaticMethodsHaveNullInstance, &quot;instance&quot;);
             } else {
-                ContractUtils.Requires(instance != null, &quot;method&quot;, Strings.OnlyStaticMethodsHaveNullInstance);
+                if (instance == null) throw new ArgumentException(Strings.OnlyStaticMethodsHaveNullInstance, &quot;method&quot;);
                 RequiresCanRead(instance, &quot;instance&quot;);
                 ValidateCallInstanceType(instance.Type, method);
             }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/MethodCallExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -214,7 +214,7 @@ namespace System.Linq.Expressions {
             ReadOnlyCollection&lt;Expression&gt; boundsList = bounds.ToReadOnly();
 
             int dimensions = boundsList.Count;
-            ContractUtils.Requires(dimensions &gt; 0, &quot;bounds&quot;, Strings.BoundsCannotBeLessThanOne);
+            if (dimensions &lt;= 0) throw Error.BoundsCannotBeLessThanOne();
 
             for (int i = 0; i &lt; dimensions; i++) {
                 Expression expr = boundsList[i];</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/NewArrayExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -220,8 +220,8 @@ namespace System.Linq.Expressions {
         /// &lt;returns&gt;A &lt;see cref=&quot;ParameterExpression&quot; /&gt; node with the specified name and type.&lt;/returns&gt;
         public static ParameterExpression Variable(Type type, string name) {
             ContractUtils.RequiresNotNull(type, &quot;type&quot;);
-            ContractUtils.Requires(type != typeof(void), &quot;type&quot;, Strings.ArgumentCannotBeOfTypeVoid);
-            ContractUtils.Requires(!type.IsByRef, &quot;type&quot;, Strings.TypeMustNotBeByRef);
+            if (type == typeof(void)) throw Error.ArgumentCannotBeOfTypeVoid();
+            if (type.IsByRef) throw Error.TypeMustNotBeByRef();
             return ParameterExpression.Make(type, name, false);
         }
     }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/ParameterExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -199,7 +199,7 @@ namespace System.Linq.Expressions {
         /// &lt;returns&gt;The created &lt;see cref=&quot;SwitchExpression&quot;/&gt;.&lt;/returns&gt;
         public static SwitchExpression Switch(Type type, Expression switchValue, Expression defaultBody, MethodInfo comparison, IEnumerable&lt;SwitchCase&gt; cases) {
             RequiresCanRead(switchValue, &quot;switchValue&quot;);
-            ContractUtils.Requires(switchValue.Type != typeof(void), &quot;switchValue&quot;, Strings.ArgumentCannotBeOfTypeVoid);
+            if (switchValue.Type == typeof(void)) throw Error.ArgumentCannotBeOfTypeVoid();
 
             var caseList = cases.ToReadOnly();
             ContractUtils.RequiresNotEmpty(caseList, &quot;cases&quot;);
@@ -269,7 +269,7 @@ namespace System.Linq.Expressions {
             }
 
             if (defaultBody == null) {
-                ContractUtils.Requires(resultType == typeof(void), &quot;defaultBody&quot;, Strings.DefaultBodyMustBeSupplied);
+                if (resultType != typeof(void)) throw Error.DefaultBodyMustBeSupplied();
             } else {
                 ValidateSwitchCaseType(defaultBody, customType, resultType, &quot;defaultBody&quot;);
             }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/SwitchExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -195,7 +195,7 @@ namespace System.Linq.Expressions {
         public static TypeBinaryExpression TypeIs(Expression expression, Type type) {
             RequiresCanRead(expression, &quot;expression&quot;);
             ContractUtils.RequiresNotNull(type, &quot;type&quot;);
-            ContractUtils.Requires(!type.IsByRef, &quot;type&quot;, Strings.TypeMustNotBeByRef);
+            if (type.IsByRef) throw Error.TypeMustNotBeByRef();
 
             return new TypeBinaryExpression(expression, type, ExpressionType.TypeIs);
         }
@@ -209,7 +209,7 @@ namespace System.Linq.Expressions {
         public static TypeBinaryExpression TypeEqual(Expression expression, Type type) {
             RequiresCanRead(expression, &quot;expression&quot;);
             ContractUtils.RequiresNotNull(type, &quot;type&quot;);
-            ContractUtils.Requires(!type.IsByRef, &quot;type&quot;, Strings.TypeMustNotBeByRef);
+            if (type.IsByRef) throw Error.TypeMustNotBeByRef();
 
             return new TypeBinaryExpression(expression, type, ExpressionType.TypeEqual);
         }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/TypeBinaryExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -678,11 +678,10 @@ namespace System.Linq.Expressions {
         public static UnaryExpression Unbox(Expression expression, Type type) {
             RequiresCanRead(expression, &quot;expression&quot;);
             ContractUtils.RequiresNotNull(type, &quot;type&quot;);
-            ContractUtils.Requires(
-                expression.Type.IsInterface || expression.Type == typeof(object),
-                &quot;expression&quot;, Strings.InvalidUnboxType
-            );
-            ContractUtils.Requires(type.IsValueType, &quot;type&quot;, Strings.InvalidUnboxType);
+            if (!expression.Type.IsInterface &amp;&amp; expression.Type != typeof(object)) {
+                throw Error.InvalidUnboxType();
+            }
+            if (!type.IsValueType) throw Error.InvalidUnboxType();
             TypeUtils.ValidateType(type);
             return new UnaryExpression(ExpressionType.Unbox, expression, type, null);
         }
@@ -788,7 +787,7 @@ namespace System.Linq.Expressions {
         ///&lt;paramref name=&quot;expression&quot; /&gt; is null.&lt;/exception&gt;
         public static UnaryExpression Quote(Expression expression) {
             RequiresCanRead(expression, &quot;expression&quot;);
-            ContractUtils.Requires(expression is LambdaExpression, Strings.QuotedExpressionMustBeLambda);
+            if (!(expression is LambdaExpression)) throw Error.QuotedExpressionMustBeLambda();
             return new UnaryExpression(ExpressionType.Quote, expression, expression.GetType(), null);
         }
 
@@ -830,7 +829,7 @@ namespace System.Linq.Expressions {
 
             if (value != null) {
                 RequiresCanRead(value, &quot;value&quot;);
-                ContractUtils.Requires(!value.Type.IsValueType, &quot;value&quot;, Strings.ArgumentMustNotHaveValueType);
+                if (value.Type.IsValueType) throw Error.ArgumentMustNotHaveValueType();
             }
             return new UnaryExpression(ExpressionType.Throw, value, type, null);
         }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/UnaryExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -308,7 +308,7 @@ namespace System.Linq.Expressions.Compiler {
             ContractUtils.RequiresNotNull(paramTypes, &quot;paramTypes&quot;);
 
             ConstructorInfo ci = type.GetConstructor(paramTypes);
-            ContractUtils.Requires(ci != null, &quot;type&quot;, Strings.TypeDoesNotHaveConstructorForTheSignature);
+            if (ci == null) throw Error.TypeDoesNotHaveConstructorForTheSignature();
             il.EmitNew(ci);
         }
 
@@ -915,7 +915,7 @@ namespace System.Linq.Expressions.Compiler {
         internal static void EmitArray(this ILGenerator il, Type elementType, int count, Action&lt;int&gt; emit) {
             ContractUtils.RequiresNotNull(elementType, &quot;elementType&quot;);
             ContractUtils.RequiresNotNull(emit, &quot;emit&quot;);
-            ContractUtils.Requires(count &gt;= 0, &quot;count&quot;, Strings.CountCannotBeNegative);
+            if (count &lt; 0) throw Error.CountCannotBeNegative();
 
             il.EmitInt(count);
             il.Emit(OpCodes.Newarr, elementType);
@@ -936,7 +936,7 @@ namespace System.Linq.Expressions.Compiler {
         /// &lt;/summary&gt;
         internal static void EmitArray(this ILGenerator il, Type arrayType) {
             ContractUtils.RequiresNotNull(arrayType, &quot;arrayType&quot;);
-            ContractUtils.Requires(arrayType.IsArray, &quot;arrayType&quot;, Strings.ArrayTypeMustBeArray);
+            if (!arrayType.IsArray) throw Error.ArrayTypeMustBeArray();
 
             int rank = arrayType.GetArrayRank();
             if (rank == 1) {</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Compiler/ILGen.cs</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,6 @@
     &lt;ProjectGuid&gt;{2AE75F5A-CD1F-4925-9647-AF4D1C282FB4}&lt;/ProjectGuid&gt;
     &lt;OutputType&gt;Library&lt;/OutputType&gt;
     &lt;AppDesignerFolder&gt;Properties&lt;/AppDesignerFolder&gt;
-    &lt;AllowUnsafeBlocks&gt;true&lt;/AllowUnsafeBlocks&gt;
     &lt;RootNamespace&gt;System.Scripting&lt;/RootNamespace&gt;
     &lt;AssemblyName&gt;Microsoft.Scripting.Core&lt;/AssemblyName&gt;
     &lt;SccProjectName&gt;SAK&lt;/SccProjectName&gt;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Microsoft.Scripting.Core.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -51,14 +51,6 @@ namespace System.Dynamic.Utils {
             }
         }
 
-        internal static void Requires(bool precondition, string paramName, string message) {
-            Debug.Assert(!string.IsNullOrEmpty(paramName));
-
-            if (!precondition) {
-                throw new ArgumentException(message, paramName);
-            }
-        }
-
         internal static void RequiresNotNull(object value, string paramName) {
             Debug.Assert(!string.IsNullOrEmpty(paramName));
 </diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Utils/ContractUtils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-/* ****************************************************************************
+&#65279;/* ****************************************************************************
  *
  * Copyright (c) Microsoft Corporation. 
  *
@@ -1510,6 +1510,209 @@ namespace System.Linq.Expressions {
 
     internal static partial class Error {
         /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Argument count must be greater than number of named arguments.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception ArgCntMustBeGreaterThanNameCnt() {
+            return new ArgumentException(Strings.ArgCntMustBeGreaterThanNameCnt);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;reducible nodes must override Expression.Reduce()&quot;
+        /// &lt;/summary&gt;
+        internal static Exception ReducibleMustOverrideReduce() {
+            return new ArgumentException(Strings.ReducibleMustOverrideReduce);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;node cannot reduce to itself or null&quot;
+        /// &lt;/summary&gt;
+        internal static Exception MustReduceToDifferent() {
+            return new ArgumentException(Strings.MustReduceToDifferent);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;cannot assign from the reduced node type to the original node type&quot;
+        /// &lt;/summary&gt;
+        internal static Exception ReducedNotCompatible() {
+            return new ArgumentException(Strings.ReducedNotCompatible);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Setter must have parameters.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception SetterHasNoParams() {
+            return new ArgumentException(Strings.SetterHasNoParams);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Property cannot have a managed pointer type.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception PropertyCannotHaveRefType() {
+            return new ArgumentException(Strings.PropertyCannotHaveRefType);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Indexing parameters of getter and setter must match.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception IndexesOfSetGetMustMatch() {
+            return new ArgumentException(Strings.IndexesOfSetGetMustMatch);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Accessor method should not have VarArgs.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception AccessorsCannotHaveVarArgs() {
+            return new ArgumentException(Strings.AccessorsCannotHaveVarArgs);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Accessor indexes cannot be passed ByRef.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception AccessorsCannotHaveByRefArgs() {
+            return new ArgumentException(Strings.AccessorsCannotHaveByRefArgs);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Bounds count cannot be less than 1&quot;
+        /// &lt;/summary&gt;
+        internal static Exception BoundsCannotBeLessThanOne() {
+            return new ArgumentException(Strings.BoundsCannotBeLessThanOne);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;type must not be ByRef&quot;
+        /// &lt;/summary&gt;
+        internal static Exception TypeMustNotBeByRef() {
+            return new ArgumentException(Strings.TypeMustNotBeByRef);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Type doesn't have constructor with a given signature&quot;
+        /// &lt;/summary&gt;
+        internal static Exception TypeDoesNotHaveConstructorForTheSignature() {
+            return new ArgumentException(Strings.TypeDoesNotHaveConstructorForTheSignature);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Count must be non-negative.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception CountCannotBeNegative() {
+            return new ArgumentException(Strings.CountCannotBeNegative);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;arrayType must be an array type&quot;
+        /// &lt;/summary&gt;
+        internal static Exception ArrayTypeMustBeArray() {
+            return new ArgumentException(Strings.ArrayTypeMustBeArray);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Setter should have void type.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception SetterMustBeVoid() {
+            return new ArgumentException(Strings.SetterMustBeVoid);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Property type must match the value type of setter&quot;
+        /// &lt;/summary&gt;
+        internal static Exception PropertyTyepMustMatchSetter() {
+            return new ArgumentException(Strings.PropertyTyepMustMatchSetter);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Both accessors must be static.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception BothAccessorsMustBeStatic() {
+            return new ArgumentException(Strings.BothAccessorsMustBeStatic);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Static method requires null instance, non-static method requires non-null instance.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception OnlyStaticMethodsHaveNullInstance() {
+            return new ArgumentException(Strings.OnlyStaticMethodsHaveNullInstance);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Property cannot have a void type.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception PropertyTypeCannotBeVoid() {
+            return new ArgumentException(Strings.PropertyTypeCannotBeVoid);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Can only unbox from an object or interface type to a value type.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception InvalidUnboxType() {
+            return new ArgumentException(Strings.InvalidUnboxType);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Argument must not have a value type.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception ArgumentMustNotHaveValueType() {
+            return new ArgumentException(Strings.ArgumentMustNotHaveValueType);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;must be reducible node&quot;
+        /// &lt;/summary&gt;
+        internal static Exception MustBeReducible() {
+            return new ArgumentException(Strings.MustBeReducible);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Default body must be supplied if case bodies are not System.Void.&quot;
+        /// &lt;/summary&gt;
+        internal static Exception DefaultBodyMustBeSupplied() {
+            return new ArgumentException(Strings.DefaultBodyMustBeSupplied);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;MethodBuilder does not have a valid TypeBuilder&quot;
+        /// &lt;/summary&gt;
+        internal static Exception MethodBuilderDoesNotHaveTypeBuilder() {
+            return new ArgumentException(Strings.MethodBuilderDoesNotHaveTypeBuilder);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Type must be derived from System.Delegate&quot;
+        /// &lt;/summary&gt;
+        internal static Exception TypeMustBeDerivedFromSystemDelegate() {
+            return new ArgumentException(Strings.TypeMustBeDerivedFromSystemDelegate);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Argument type cannot be void&quot;
+        /// &lt;/summary&gt;
+        internal static Exception ArgumentTypeCannotBeVoid() {
+            return new ArgumentException(Strings.ArgumentTypeCannotBeVoid);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Label type must be System.Void if an expression is not supplied&quot;
+        /// &lt;/summary&gt;
+        internal static Exception LabelMustBeVoidOrHaveExpression() {
+            return new ArgumentException(Strings.LabelMustBeVoidOrHaveExpression);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Type must be System.Void for this label argument&quot;
+        /// &lt;/summary&gt;
+        internal static Exception LabelTypeMustBeVoid() {
+            return new ArgumentException(Strings.LabelTypeMustBeVoid);
+        }
+
+        /// &lt;summary&gt;
+        /// ArgumentException with message like &quot;Quoted expression must be a lambda&quot;
+        /// &lt;/summary&gt;
+        internal static Exception QuotedExpressionMustBeLambda() {
+            return new ArgumentException(Strings.QuotedExpressionMustBeLambda);
+        }
+
+        /// &lt;summary&gt;
         /// ArgumentException with message like &quot;Variable '{0}' uses unsupported type '{1}'. Reference types are not supported for variables.&quot;
         /// &lt;/summary&gt;
         internal static Exception VariableMustNotBeByRef(object p0, object p1) {
@@ -2455,20 +2658,6 @@ namespace System.Linq.Expressions {
         }
 
         /// &lt;summary&gt;
-        /// ArgumentNullException with message like &quot;The value null is not of type '{0}' and cannot be used in this collection.&quot;
-        /// &lt;/summary&gt;
-        internal static Exception InvalidNullValue(object p0) {
-            return new ArgumentNullException(Strings.InvalidNullValue(p0));
-        }
-
-        /// &lt;summary&gt;
-        /// ArgumentException with message like &quot;The value '{0}' is not of type '{1}' and cannot be used in this collection.&quot;
-        /// &lt;/summary&gt;
-        internal static Exception InvalidObjectType(object p0, object p1) {
-            return new ArgumentException(Strings.InvalidObjectType(p0, p1));
-        }
-
-        /// &lt;summary&gt;
         /// NotSupportedException with message like &quot;TryExpression is not supported as an argument to method '{0}' because it has an argument with by-ref type. Construct the tree so the TryExpression is not nested inside of this expression.&quot;
         /// &lt;/summary&gt;
         internal static Exception TryNotSupportedForMethodsWithRefArgs(object p0) {</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Utils/ExceptionFactory.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,8 @@
 	.custom instance void [mscorlib]System.CLSCompliantAttribute::.ctor(bool) = { bool(true) }
 	.custom instance void [mscorlib]System.Runtime.CompilerServices.InternalsVisibleToAttribute::.ctor(string) = { string('Microsoft.CSharp, PublicKey =002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293') }
 	.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = { bool(false) }
+	.custom instance void [mscorlib]System.Security.AllowPartiallyTrustedCallersAttribute::.ctor() = { }
+	.custom instance void [mscorlib]System.Security.SecurityRulesAttribute::.ctor(valuetype [mscorlib]System.Security.SecurityRuleSet) = { uint8(2) property bool SkipVerificationInFullTrust = bool(true) }
 	.permissionset reqmin = (2E 01 80 84 53 79 73 74 65 6D 2E 53 65 63 75 72 69 74 79 2E 50 65 72 6D 69 73 73 69 6F 6E 73 2E 53 65 63 75 72 69 74 79 50 65 72 6D 69 73 73 69 6F 6E 41 74 74 72 69 62 75 74 65 2C 20 6D 73 63 6F 72 6C 69 62 2C 20 56 65 72 73 69 6F 6E 3D 34 2E 30 2E 30 2E 30 2C 20 43 75 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C 2C 20 50 75 62 6C 69 63 4B 65 79 54 6F 6B 65 6E 3D 62 37 37 61 35 63 35 36 31 39 33 34 65 30 38 39 15 01 54 02 10 53 6B 69 70 56 65 72 69 66 69 63 61 74 69 6F 6E 01)
 	.publickey = SYSTEM_DYNAMIC_ASSEMBLY_PUBLIC_KEY_IL
 	.hash algorithm 0x00008004
@@ -102,10 +104,10 @@
 	extends [mscorlib]System.Object
 {
 	.field static assembly literal string Copyright = bytearray(A9 00 20 00 4D 00 69 00 63 00 72 00 6F 00 73 00 6F 00 66 00 74 00 20 00 43 00 6F 00 72 00 70 00 6F 00 72 00 61 00 74 00 69 00 6F 00 6E 00 2E 00 20 00 20 00 41 00 6C 00 6C 00 20 00 72 00 69 00 67 00 68 00 74 00 73 00 20 00 72 00 65 00 73 00 65 00 72 00 76 00 65 00 64 00 2E 00)
-	.field static assembly literal int32 DailyBuildNumber = int32(0x000050E2)
+	.field static assembly literal int32 DailyBuildNumber = int32(0x000051AF)
 	.field static assembly literal string DefaultAlias = &quot;System.Dynamic.dll&quot;
 	.field static assembly literal string Description = &quot;System.Dynamic.dll&quot;
-	.field static assembly literal string InformationalVersion = &quot;4.0.20706.0&quot;
+	.field static assembly literal string InformationalVersion = &quot;4.0.20911.0&quot;
 	.field static assembly literal string Title = &quot;System.Dynamic.dll&quot;
 	.field static assembly literal string Version = &quot;4.0.0.0&quot;
 }
@@ -288,6 +290,7 @@
 		.method public static hidebysig 
 			bool TryBindGetMember(class [System.Core]System.Dynamic.GetMemberBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject 'instance', [out] class [System.Core]System.Dynamic.DynamicMetaObject&amp; result, bool delayInvocation)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
@@ -298,46 +301,55 @@
 		.method public static hidebysig 
 			bool TryBindSetMember(class [System.Core]System.Dynamic.SetMemberBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject 'instance', class [System.Core]System.Dynamic.DynamicMetaObject 'value', [out] class [System.Core]System.Dynamic.DynamicMetaObject&amp; result)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			bool TryBindInvoke(class [System.Core]System.Dynamic.InvokeBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject 'instance', class [System.Core]System.Dynamic.DynamicMetaObject[] args, [out] class [System.Core]System.Dynamic.DynamicMetaObject&amp; result)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			bool TryBindInvokeMember(class [System.Core]System.Dynamic.InvokeMemberBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject 'instance', class [System.Core]System.Dynamic.DynamicMetaObject[] args, [out] class [System.Core]System.Dynamic.DynamicMetaObject&amp; result)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			bool TryBindGetIndex(class [System.Core]System.Dynamic.GetIndexBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject 'instance', class [System.Core]System.Dynamic.DynamicMetaObject[] args, [out] class [System.Core]System.Dynamic.DynamicMetaObject&amp; result)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			bool TryBindSetIndex(class [System.Core]System.Dynamic.SetIndexBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject 'instance', class [System.Core]System.Dynamic.DynamicMetaObject[] args, class [System.Core]System.Dynamic.DynamicMetaObject 'value', [out] class [System.Core]System.Dynamic.DynamicMetaObject&amp; result)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			bool TryConvert(class [System.Core]System.Dynamic.ConvertBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject 'instance', [out] class [System.Core]System.Dynamic.DynamicMetaObject&amp; result)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			class [mscorlib]'System.Collections.Generic.IEnumerable`1'&lt;string&gt; GetDynamicMemberNames(object 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			class [mscorlib]'System.Collections.Generic.IList`1'&lt;string&gt; GetDynamicDataMemberNames(object 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			class [mscorlib]'System.Collections.Generic.IList`1'&lt;valuetype [mscorlib]'System.Collections.Generic.KeyValuePair`2'&lt;string,object&gt;&gt; GetDynamicDataMembers(object 'value', class [mscorlib]'System.Collections.Generic.IEnumerable`1'&lt;string&gt; names)
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 	}
@@ -395,6 +407,7 @@
 		.method public static hidebysig 
 			class System.Dynamic.ComEventSink FromRuntimeCallableWrapper(object rcw, valuetype [mscorlib]System.Guid sourceIid, bool createIfNotFound)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
@@ -405,6 +418,7 @@
 		.method public hidebysig 
 			instance void RemoveHandler(int32 dispid, object func)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
@@ -475,11 +489,13 @@
 		.method public final virtual hidebysig newslot 
 			instance void Dispose()
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method family virtual hidebysig 
 			instance void Finalize()
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.property instance class [mscorlib]System.Type UnderlyingSystemType()
@@ -490,19 +506,23 @@
 	.class private sealed ComEventSinkProxy
 		extends [mscorlib]System.Runtime.Remoting.Proxies.RealProxy
 	{
+		.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 		.method public hidebysig specialname 
 			instance void .ctor(class System.Dynamic.ComEventSink sink, valuetype [mscorlib]System.Guid sinkIid)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public virtual hidebysig 
 			instance native int SupportsInterface(valuetype [mscorlib]System.Guid&amp; iid)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public virtual hidebysig 
 			instance class [mscorlib]System.Runtime.Remoting.Messaging.IMessage Invoke(class [mscorlib]System.Runtime.Remoting.Messaging.IMessage msg)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 	}
@@ -513,16 +533,19 @@
 		.method public static hidebysig 
 			class System.Dynamic.ComEventSinksContainer FromRuntimeCallableWrapper(object rcw, bool createIfNotFound)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public final virtual hidebysig newslot 
 			instance void Dispose()
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method family virtual hidebysig 
 			instance void Finalize()
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 	}
@@ -770,6 +793,7 @@
 		.method public static hidebysig 
 			class System.Dynamic.ComObject ObjectToComObject(object rcw)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
@@ -814,6 +838,7 @@
 		.method public static hidebysig 
 			void CheckThrowException(int32 'hresult', valuetype System.Dynamic.ExcepInfo&amp; excepInfo, uint32 argErr, string message)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
@@ -839,16 +864,19 @@
 		.method assembly static hidebysig 
 			class [mscorlib]System.Runtime.InteropServices.ComTypes.ITypeInfo GetITypeInfoFromIDispatch(class System.Dynamic.IDispatch dispatch, bool throwIfMissingExpectedTypeInfo)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			valuetype [mscorlib]'System.Runtime.InteropServices.ComTypes.TYPEATTR' GetTypeAttrForTypeInfo(class [mscorlib]System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			valuetype [mscorlib]'System.Runtime.InteropServices.ComTypes.TYPELIBATTR' GetTypeAttrForTypeLib(class [mscorlib]System.Runtime.InteropServices.ComTypes.ITypeLib typeLib)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
@@ -868,6 +896,7 @@
 		.method assembly hidebysig specialname 
 			instance void .ctor(class [mscorlib]System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly hidebysig 
@@ -887,6 +916,7 @@
 		.method assembly static hidebysig 
 			class System.Dynamic.ComTypeDesc FromITypeInfo(class [mscorlib]System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo, valuetype [mscorlib]'System.Runtime.InteropServices.ComTypes.TYPEATTR' typeAttr)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
@@ -1069,6 +1099,7 @@
 		.method assembly static hidebysig 
 			class System.Dynamic.ComTypeLibDesc GetFromTypeLib(class [mscorlib]System.Runtime.InteropServices.ComTypes.ITypeLib typeLib)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly hidebysig 
@@ -1292,6 +1323,7 @@
 		.method public virtual hidebysig 
 			instance class [System.Core]System.Dynamic.DynamicMetaObject BindSetIndex(class [System.Core]System.Dynamic.SetIndexBinder binder, class [System.Core]System.Dynamic.DynamicMetaObject[] indexes, class [System.Core]System.Dynamic.DynamicMetaObject 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = { }
 			ret
 		}
 	}
@@ -1463,6 +1495,7 @@
 		.method assembly hidebysig 
 			instance class [mscorlib]System.Exception GetException()
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 
@@ -2086,87 +2119,104 @@
 		.method assembly static hidebysig 
 			native int ConvertSByteByrefToPtr(int8&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertInt16ByrefToPtr(int16&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			native int ConvertInt32ByrefToPtr(int32&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertInt64ByrefToPtr(int64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertByteByrefToPtr(uint8&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertUInt16ByrefToPtr(uint16&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertUInt32ByrefToPtr(uint32&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertUInt64ByrefToPtr(uint64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertIntPtrByrefToPtr(native int&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertUIntPtrByrefToPtr(native uint&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertSingleByrefToPtr(float32&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertDoubleByrefToPtr(float64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			native int ConvertDecimalByrefToPtr(valuetype [mscorlib]System.Decimal&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			native int ConvertVariantByrefToPtr(valuetype System.Dynamic.Variant&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			valuetype System.Dynamic.Variant GetVariantForObject(object obj)
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig 
 			void InitVariantForObject(object obj, valuetype System.Dynamic.Variant&amp; 'variant')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			object GetObjectForVariant(valuetype System.Dynamic.Variant 'variant')
 		{
 			.custom instance void [mscorlib]System.ObsoleteAttribute::.ctor(string, bool) = { string('do not use this method') bool(true) }
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
@@ -2185,12 +2235,14 @@
 			int32 IDispatchInvoke(native int dispatchPointer, int32 memberDispId, valuetype [mscorlib]'System.Runtime.InteropServices.ComTypes.INVOKEKIND' 'flags', valuetype [mscorlib]'System.Runtime.InteropServices.ComTypes.DISPPARAMS'&amp; dispParams, [out] valuetype System.Dynamic.Variant&amp; result, [out] valuetype System.Dynamic.ExcepInfo&amp; excepInfo, [out] uint32&amp; argErr)
 		{
 			.custom instance void [mscorlib]System.ObsoleteAttribute::.ctor(string, bool) = { string('do not use this method') bool(true) }
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public static hidebysig 
 			native int GetIdsOfNamedParameters(class System.Dynamic.IDispatch dispatch, string[] names, int32 methodDispId, [out] valuetype [mscorlib]System.Runtime.InteropServices.GCHandle&amp; pinningHandle)
 		{
 			.custom instance void [mscorlib]System.ObsoleteAttribute::.ctor(string, bool) = { string('do not use this method') bool(true) }
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig specialname 
@@ -2243,11 +2295,13 @@
 		.method public hidebysig 
 			instance object ToObject()
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
 			instance void Clear()
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2273,6 +2327,7 @@
 		.method public hidebysig 
 			instance void SetAsIConvertible(class [mscorlib]System.IConvertible 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2288,6 +2343,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefI1(int8&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2303,6 +2359,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefI2(int16&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2318,6 +2375,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefI4(int32&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2333,6 +2391,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefI8(int64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2348,6 +2407,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefUi1(uint8&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2363,6 +2423,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefUi2(uint16&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2378,6 +2439,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefUi4(uint32&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2393,6 +2455,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefUi8(uint64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2408,6 +2471,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefInt(native int&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2423,6 +2487,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefUint(native uint&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2438,6 +2503,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefBool(int16&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2453,6 +2519,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefError(int32&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2468,6 +2535,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefR4(float32&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2483,6 +2551,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefR8(float64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2498,6 +2567,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefDecimal(valuetype [mscorlib]System.Decimal&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2513,6 +2583,7 @@
 		.method public hidebysig 
 			instance void SetAsByrefCy(int64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
@@ -2528,71 +2599,85 @@
 		.method public hidebysig 
 			instance void SetAsByrefDate(float64&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance string get_AsBstr()
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance void set_AsBstr(string 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
 			instance void SetAsByrefBstr(native int&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance object get_AsUnknown()
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance void set_AsUnknown(object 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
 			instance void SetAsByrefUnknown(native int&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance object get_AsDispatch()
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance void set_AsDispatch(object 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
 			instance void SetAsByrefDispatch(native int&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance object get_AsVariant()
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig specialname 
 			instance void set_AsVariant(object 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
 			instance void SetAsByrefVariant(valuetype System.Dynamic.Variant&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method public hidebysig 
 			instance void SetAsByrefVariantIndirect(valuetype System.Dynamic.Variant&amp; 'value')
 		{
+			.custom instance void [mscorlib]System.Security.SecurityCriticalAttribute::.ctor() = { }
 			ret
 		}
 		.method assembly static hidebysig </diff>
      <filename>ndp/fx/src/Dynamic/System.Dynamic.asmmeta</filename>
    </modified>
    <modified>
      <diff>@@ -32,6 +32,9 @@ using System.Security;
 [assembly: AssemblyCopyright(&quot;&#169; Microsoft Corporation.  All rights reserved.&quot;)]
 [assembly: AssemblyTrademark(&quot;&quot;)]
 [assembly: AssemblyCulture(&quot;&quot;)]
+#if !CLR2
+[assembly: SecurityRules(SecurityRuleSet.Level1)]
+#endif
 
 // Setting ComVisible to false makes the types in this assembly not visible 
 // to COM components.  If you need to access a type in this assembly from </diff>
      <filename>ndp/fx/src/Dynamic/System/Dynamic/Properties/AssemblyInfo.cs</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/GenericRegex.cs</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>f939ae8b2133e3ef0216871b5378ec2bd33fff72</id>
    </parent>
  </parents>
  <author>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </author>
  <url>http://github.com/ironruby/ironruby/commit/b7baebdea0a2fe7a80dadcba40591bf31cf32b21</url>
  <id>b7baebdea0a2fe7a80dadcba40591bf31cf32b21</id>
  <committed-date>2009-10-14T15:17:29-07:00</committed-date>
  <authored-date>2009-10-14T15:17:29-07:00</authored-date>
  <message>sync to head of tfs</message>
  <tree>eba09b77046bc5da4d9de82f93564c496c3823eb</tree>
  <committer>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </committer>
</commit>
