<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/NamespaceTrackerOps.cs</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -37,15 +37,17 @@ namespace IronPython.Modules {
 
         [SpecialName]
         public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
-            dict.Add(SymbolTable.StringToId(_keyDefaultAction), &quot;default&quot;);
-            dict.Add(SymbolTable.StringToId(_keyOnceRegistry), new PythonDictionary());
-            dict.Add(SymbolTable.StringToId(_keyFilters), new List() {
-                // Default filters
-                PythonTuple.MakeTuple(&quot;ignore&quot;, null, PythonExceptions.PendingDeprecationWarning, null, 0),
-                PythonTuple.MakeTuple(&quot;ignore&quot;, null, PythonExceptions.ImportWarning, null, 0),
-                PythonTuple.MakeTuple(&quot;ignore&quot;, null, PythonExceptions.BytesWarning, null, 0)
+            context.GetOrCreateModuleState(_keyFields, () =&gt; {
+                dict.Add(SymbolTable.StringToId(_keyDefaultAction), &quot;default&quot;);
+                dict.Add(SymbolTable.StringToId(_keyOnceRegistry), new PythonDictionary());
+                dict.Add(SymbolTable.StringToId(_keyFilters), new List() {
+                    // Default filters
+                    PythonTuple.MakeTuple(&quot;ignore&quot;, null, PythonExceptions.PendingDeprecationWarning, null, 0),
+                    PythonTuple.MakeTuple(&quot;ignore&quot;, null, PythonExceptions.ImportWarning, null, 0),
+                    PythonTuple.MakeTuple(&quot;ignore&quot;, null, PythonExceptions.BytesWarning, null, 0)
+                });
+                return dict;
             });
-            context.SetModuleState(_keyFields, dict);
         }
 
         #region Public API
@@ -185,10 +187,18 @@ namespace IronPython.Modules {
                     throw PythonOps.RuntimeError(&quot;Unrecognized action ({0}) in warnings.filters:\n {1}&quot;, action, last_filter);
             }
 
-            showwarning(context, msg, category, filename, lineno, null, null);
+            object warnings = pContext.GetWarningsModule();
+            if (warnings != null) {
+                PythonCalls.Call(
+                    context,
+                    PythonOps.GetBoundAttr(context, warnings, SymbolTable.StringToId(&quot;showwarning&quot;)),
+                    msg, category, filename, lineno, null, null);
+            } else {
+                showwarning(context, msg, category, filename, lineno, null, null);
+            }
         }
 
-        public static string formatwarning(object message, PythonType category, string filename, int lineno, [DefaultParameterValue(null)]string line) {
+        internal static string formatwarning(object message, PythonType category, string filename, int lineno, [DefaultParameterValue(null)]string line) {
             StringBuilder sb = new StringBuilder();
             sb.AppendFormat(&quot;{0}:{1}: {2}: {3}\n&quot;, filename, lineno, category.Name, message);
             if (line == null &amp;&amp; lineno &gt; 0 &amp;&amp; File.Exists(filename)) {
@@ -204,7 +214,7 @@ namespace IronPython.Modules {
             return sb.ToString();
         }
 
-        public static void showwarning(CodeContext context, object message, PythonType category, string filename, int lineno, [DefaultParameterValue(null)]object file, [DefaultParameterValue(null)]string line) {
+        internal static void showwarning(CodeContext context, object message, PythonType category, string filename, int lineno, [DefaultParameterValue(null)]object file, [DefaultParameterValue(null)]string line) {
             string text = formatwarning(message, category, filename, lineno, line);
 
             try {
@@ -229,6 +239,7 @@ namespace IronPython.Modules {
             }
         }
 
+
         #endregion
     }
 }</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython.Modules/_warnings.cs</filename>
    </modified>
    <modified>
      <diff>@@ -28,29 +28,65 @@ using Microsoft.Scripting.Runtime;
 [assembly: PythonModule(&quot;binascii&quot;, typeof(IronPython.Modules.PythonBinaryAscii))]
 namespace IronPython.Modules {
     public static class PythonBinaryAscii {
+        private static readonly object _ErrorKey = new object();
+        private static readonly object _IncompleteKey = new object();
+
+        private static Exception Error(CodeContext/*!*/ context, params object[] args) {
+            return PythonExceptions.CreateThrowable((PythonType)PythonContext.GetContext(context).GetModuleState(_ErrorKey), args);
+        }
+        private static Exception Incomplete(CodeContext/*!*/ context, params object[] args) {
+            return PythonExceptions.CreateThrowable((PythonType)PythonContext.GetContext(context).GetModuleState(_IncompleteKey), args);
+        }
+
         [SpecialName]
         public static void PerformModuleReload(PythonContext/*!*/ context, IAttributesCollection/*!*/ dict) {
-            context.EnsureModuleException(&quot;binasciierror&quot;, dict, &quot;Error&quot;, &quot;binascii&quot;);
+            context.EnsureModuleException(_ErrorKey, dict, &quot;Error&quot;, &quot;binascii&quot;);
+            context.EnsureModuleException(_IncompleteKey, dict, &quot;Incomplete&quot;, &quot;binascii&quot;);
         }
 
-        public static string a2b_uu(string data) {
-            if (data == null) throw PythonOps.TypeError(&quot;expected string, got NoneType&quot;);
-            if (data.Length &lt; 1) throw PythonOps.ValueError(&quot;data is too short&quot;);
-
-            StringBuilder res = DecodeWorker(data.Substring(1), Char.MinValue, delegate(char val) {
-                return val - 32;
-            });
+        private static int UuDecFunc(char val) {
+            if (val &gt; 32 &amp;&amp; val &lt; 96) return val - 32;
+            switch (val) {
+                case '\n':
+                case '\r':
+                case (char)32:
+                case (char)96:
+                    return EmptyByte;
+                default:
+                    return InvalidByte;
+            }
+        }
 
+        public static string a2b_uu(CodeContext/*!*/ context, string data) {
+            if (data == null) throw PythonOps.TypeError(&quot;expected string, got NoneType&quot;);
+            if (data.Length &lt; 1) return new string(Char.MinValue, 32);
+
+            int lenDec = (data[0] + 32) % 64; // decoded length in bytes
+            int lenEnc = (lenDec * 4 + 2) / 3; // encoded length in 6-bit chunks
+            string suffix = null;
+            if (data.Length - 1 &gt; lenEnc) {
+                suffix = data.Substring(1 + lenEnc);
+                data = data.Substring(1, lenEnc);
+            } else {
+                data = data.Substring(1);
+            }
 
-            return res.ToString(0, data[0] - 32);
+            StringBuilder res = DecodeWorker(context, data, true, UuDecFunc);
+            if (suffix == null) {
+                res.Append((char)0, lenDec - res.Length);
+            } else {
+                ProcessSuffix(context, suffix, UuDecFunc);
+            }
+            
+            return res.ToString();
         }
 
-        public static string b2a_uu(string data) {
+        public static string b2a_uu(CodeContext/*!*/ context, string data) {
             if (data == null) throw PythonOps.TypeError(&quot;expected string, got NoneType&quot;);
-            if (data.Length &gt; 45) throw PythonOps.ValueError(&quot;at most 45 characters&quot;);
+            if (data.Length &gt; 45) throw Error(context, &quot;At most 45 bytes at once&quot;);
 
-            StringBuilder res = EncodeWorker(data, Int32.MaxValue, ' ', delegate(int val) {
-                return (char)(' ' + val);
+            StringBuilder res = EncodeWorker(data, ' ', delegate(int val) {
+                return (char)(32 + (val % 64));
             });
 
             res.Insert(0, ((char)(32 + data.Length)).ToString());
@@ -59,23 +95,28 @@ namespace IronPython.Modules {
             return res.ToString();
         }
 
-        public static object a2b_base64(string data) {
+        private static int Base64DecFunc(char val) {
+            if (val &gt;= 'A' &amp;&amp; val &lt;= 'Z') return val - 'A';
+            if (val &gt;= 'a' &amp;&amp; val &lt;= 'z') return val - 'a' + 26;
+            if (val &gt;= '0' &amp;&amp; val &lt;= '9') return val - '0' + 52;
+            switch (val) {
+                case '+':
+                    return 62;
+                case '/':
+                    return 63;
+                case '=':
+                    return PadByte;
+                default:
+                    return IgnoreByte;
+            }
+        }
+
+        public static object a2b_base64(CodeContext/*!*/ context, string data) {
             if (data == null) throw PythonOps.TypeError(&quot;expected string, got NoneType&quot;);
+            data = RemovePrefix(context, data, Base64DecFunc);
             if (data.Length == 0) return String.Empty;
 
-            // remove all newline and carriage feeds before processing...
-            data = RemoveWhiteSpace(data);
-
-            StringBuilder res = DecodeWorker(data, '=', delegate(char val) {
-                if (val &gt;= 'A' &amp;&amp; val &lt;= 'Z') return val - 'A';
-                if (val &gt;= 'a' &amp;&amp; val &lt;= 'z') return val - 'a' + 26;
-                if (val &gt;= '0' &amp;&amp; val &lt;= '9') return val - '0' + 52;
-                if (val == '+') return 62;
-                if (val == '/') return 63; 
-
-                return -1;
-            });
-
+            StringBuilder res = DecodeWorker(context, data, false, Base64DecFunc);
             return res.ToString();
         }
 
@@ -83,16 +124,21 @@ namespace IronPython.Modules {
             if (data == null) throw PythonOps.TypeError(&quot;expected string, got NoneType&quot;);
             if (data.Length == 0) return String.Empty;
 
-            StringBuilder res = EncodeWorker(data, 76, '=', delegate(int val) {
+            StringBuilder res = EncodeWorker(data, '=', delegate(int val) {
                 if (val &lt; 26) return (char)('A' + val);
                 if (val &lt; 52) return (char)('a' + val - 26);
                 if (val &lt; 62) return (char)('0' + val - 52);
-                if (val == 62) return '+';
-                if (val == 63) return '/';
-                throw new InvalidOperationException(String.Format(&quot;Bad int val: {0}&quot;, val));
+                switch (val) {
+                    case 62:
+                        return '+';
+                    case 63:
+                        return '/';
+                    default:
+                        throw new InvalidOperationException(String.Format(&quot;Bad int val: {0}&quot;, val));
+                }
             });
 
-            if (res[res.Length - 1] != '\n') res.Append('\n');
+            res.Append('\n');
             return res.ToString();
         }
 
@@ -183,9 +229,10 @@ namespace IronPython.Modules {
         public static object hexlify(string data) {
             return b2a_hex(data);
         }
-        public static object a2b_hex(string data) {
+
+        public static object a2b_hex(CodeContext/*!*/ context, string data) {
             if (data == null) throw PythonOps.TypeError(&quot;expected string, got NoneType&quot;);
-            if ((data.Length &amp; 0x01) != 0) throw PythonOps.ValueError(&quot;string must be even lengthed&quot;);
+            if ((data.Length &amp; 0x01) != 0) throw Error(context, &quot;string must be even lengthed&quot;);
             StringBuilder res = new StringBuilder(data.Length / 2);
 
             for (int i = 0; i &lt; data.Length; i += 2) {
@@ -201,8 +248,8 @@ namespace IronPython.Modules {
             return res.ToString();
         }
 
-        public static object unhexlify(string hexstr) {
-            return a2b_hex(hexstr);
+        public static object unhexlify(CodeContext/*!*/ context, string hexstr) {
+            return a2b_hex(context, hexstr);
         }
 
         #region Private implementation
@@ -210,11 +257,10 @@ namespace IronPython.Modules {
         private delegate char EncodeChar(int val);
         private delegate int DecodeByte(char val);
 
-        private static StringBuilder EncodeWorker(string data, int lineBreak, char empty, EncodeChar encFunc) {
+        private static StringBuilder EncodeWorker(string data, char empty, EncodeChar encFunc) {
             StringBuilder res = new StringBuilder();
 
             int bits;
-            int lineCount = 0;
             for (int i = 0; i &lt; data.Length; i += 3) {
                 switch (data.Length - i) {
                     case 1:
@@ -246,57 +292,109 @@ namespace IronPython.Modules {
                         res.Append(encFunc(bits &amp; 0x3f));
                         break;
                 }
-                if (((res.Length - (lineCount)) % lineBreak) == 0) {
-                    res.Append('\n');
-                    lineCount++;
-                }
             }
             return res;
         }
 
-        const int NoMoreData = -1;
-        const int EmptyChar = -2;
+        private const int IgnoreByte = -1; // skip this byte
+        private const int EmptyByte = -2; // byte evaluates to 0 and may appear off the end of the stream
+        private const int PadByte = -3; // pad bytes signal the end of the stream, unless there are too few to properly align
+        private const int InvalidByte = -4; // raise exception for illegal byte
+        private const int NoMoreBytes = -5; // signals end of stream
+
+        private static int NextVal(CodeContext/*!*/ context, string data, ref int index, DecodeByte decFunc) {
+            int res;
+            while (index &lt; data.Length) {
+                res = decFunc(data[index++]);
+                switch (res) {
+                    case EmptyByte:
+                        return 0;
+                    case InvalidByte:
+                        throw Error(context, &quot;Illegal char&quot;);
+                    case IgnoreByte:
+                        break;
+                    default:
+                        return res;
+                }
+            }
 
-        private static int GetVal(DecodeByte decFunc, char empty, string data, ref int index) {
-            int res = NoMoreData;
-            do {
-                if (index &gt;= data.Length) break;
+            return NoMoreBytes;
+        }
 
-                char curChar = data[index++];
-                if (curChar == empty) return EmptyChar;
+        private static int CountPadBytes(CodeContext/*!*/ context, string data, int bound, ref int index, DecodeByte decFunc) {
+            int res = PadByte;
+            int count = 0;
+            while ((bound &lt; 0 || count &lt; bound) &amp;&amp;
+                   (res = NextVal(context, data, ref index, decFunc)) == PadByte) {
+                count++;
+            }
 
-                res = decFunc(curChar);
-            } while (res == NoMoreData);
-            if (res &lt; 0 &amp;&amp; empty != Char.MinValue) throw PythonOps.TypeError(&quot;Incorrect padding&quot;);
-            return res;
+            // we only want NextVal() to eat PadBytes - not real data
+            if (res != PadByte &amp;&amp; res != NoMoreBytes) index--;
+
+            return count;
+        }
+
+        private static int GetVal(CodeContext/*!*/ context, string data, int align, bool bounded, ref int index, DecodeByte decFunc) {
+            int res;
+            while (true) {
+                res = NextVal(context, data, ref index, decFunc);
+                switch (res) {
+                    case PadByte:
+                        switch (align) {
+                            case 0:
+                            case 1:
+                                CountPadBytes(context, data, -1, ref index, decFunc);
+                                continue;
+                            case 2:
+                                if (CountPadBytes(context, data, 1, ref index, decFunc) &gt; 0) {
+                                    return NoMoreBytes;
+                                } else {
+                                    continue;
+                                }
+                            default:
+                                return NoMoreBytes;
+                        }
+                    case NoMoreBytes:
+                        if (bounded || align == 0) {
+                            return NoMoreBytes;
+                        } else {
+                            throw Error(context, &quot;Incorrect padding&quot;);
+                        }
+                    case EmptyByte:
+                        return 0;
+                    default:
+                        return res;
+                }
+            }
         }
 
-        private static StringBuilder DecodeWorker(string data, char empty, DecodeByte decFunc) {
+        private static StringBuilder DecodeWorker(CodeContext/*!*/ context, string data, bool bounded, DecodeByte decFunc) {
             StringBuilder res = new StringBuilder();
 
             int i = 0;
             while (i &lt; data.Length) {
                 int intVal;
 
-                int val1 = GetVal(decFunc, empty, data, ref i);
-                if (val1 &lt; 0) break;  // no more bytes...                
+                int val0 = GetVal(context, data, 0, bounded, ref i, decFunc);
+                if (val0 &lt; 0) break;  // no more bytes...
 
-                int val2 = GetVal(decFunc, empty, data, ref i);
+                int val1 = GetVal(context, data, 1, bounded, ref i, decFunc);
                 if (val1 &lt; 0) break;  // no more bytes...
 
-                int val3 = GetVal(decFunc, empty, data, ref i);
-                if (val3 &lt; 0) {
+                int val2 = GetVal(context, data, 2, bounded, ref i, decFunc);
+                if (val2 &lt; 0) {
                     // 2 byte partial
-                    intVal = (val1 &lt;&lt; 18) | (val2 &lt;&lt; 12);
+                    intVal = (val0 &lt;&lt; 18) | (val1 &lt;&lt; 12);
 
                     res.Append((char)((intVal &gt;&gt; 16) &amp; 0xff));
                     break;
                 }
 
-                int val4 = GetVal(decFunc, empty, data, ref i);
-                if (val4 &lt; 0) {
+                int val3 = GetVal(context, data, 3, bounded, ref i, decFunc);
+                if (val3 &lt; 0) {
                     // 3 byte partial
-                    intVal = (val1 &lt;&lt; 18) | (val2 &lt;&lt; 12) | (val3 &lt;&lt; 6);
+                    intVal = (val0 &lt;&lt; 18) | (val1 &lt;&lt; 12) | (val2 &lt;&lt; 6);
 
                     res.Append((char)((intVal &gt;&gt; 16) &amp; 0xff));
                     res.Append((char)((intVal &gt;&gt; 8) &amp; 0xff));
@@ -304,7 +402,7 @@ namespace IronPython.Modules {
                 }
 
                 // full 4-bytes
-                intVal = (val1 &lt;&lt; 18) | (val2 &lt;&lt; 12) | (val3 &lt;&lt; 6) | (val4);
+                intVal = (val0 &lt;&lt; 18) | (val1 &lt;&lt; 12) | (val2 &lt;&lt; 6) | (val3);
                 res.Append((char)((intVal &gt;&gt; 16) &amp; 0xff));
                 res.Append((char)((intVal &gt;&gt; 8) &amp; 0xff));
                 res.Append((char)(intVal &amp; 0xff));
@@ -313,19 +411,26 @@ namespace IronPython.Modules {
             return res;
         }
 
-        private static string RemoveWhiteSpace(string data) {
-            StringBuilder str = null;
+        private static string RemovePrefix(CodeContext/*!*/ context, string data, DecodeByte decFunc) {
+            int count = 0;
+            while (count &lt; data.Length) {
+                int current = decFunc(data[count]);
+                if (current == InvalidByte) {
+                    throw Error(context, &quot;Illegal char&quot;);
+                }
+                if (current &gt;= 0) break;
+                count++;
+            }
+            return count == 0 ? data : data.Substring(count);
+        }
+
+        private static void ProcessSuffix(CodeContext/*!*/ context, string data, DecodeByte decFunc) {
             for (int i = 0; i &lt; data.Length; i++) {
-                if (data[i] == '\r' || data[i] == '\n' || data[i] == ' ') {
-                    if (str == null) {
-                        str = new StringBuilder(data, 0, i, data.Length);
-                    }
-                } else if (str != null) {
-                    str.Append(data[i]);
+                int current = decFunc(data[i]);
+                if (current &gt;= 0 || current == InvalidByte) {
+                    throw Error(context, &quot;Trailing garbage&quot;);
                 }
             }
-            if (str != null) data = str.ToString();
-            return data;
         }
 
         #endregion</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython.Modules/binascii.cs</filename>
    </modified>
    <modified>
      <diff>@@ -109,6 +109,7 @@ namespace IronPython.Modules {
             Scope res = PythonContext.GetContext(context).CreateModule().Scope;
             res.SetName(Symbols.Name, name);
             res.SetName(Symbols.Doc, null);
+            res.SetName(Symbols.Package, null);
             return res;
         }
 </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython.Modules/imp.cs</filename>
    </modified>
    <modified>
      <diff>@@ -775,10 +775,6 @@ namespace IronPython.Compiler {
             if (MaybeEat(TokenKind.Multiply)) {
                 names = FromImportStatement.Star;
                 asNames = null;
-
-                if (dname is RelativeModuleName) {
-                    ReportSyntaxError(&quot;'import *' not allowed with 'from .'&quot;);
-                }
             } else {
                 List&lt;SymbolId&gt; l = new List&lt;SymbolId&gt;();
                 List&lt;SymbolId&gt; las = new List&lt;SymbolId&gt;();</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Compiler/Parser.cs</filename>
    </modified>
    <modified>
      <diff>@@ -376,8 +376,7 @@ namespace IronPython.Hosting {
             }
 
 
-            SourceUnit su = Language.CreateSnippet(s, &quot;&lt;stdin&gt;&quot;, 
-                (s.Contains(Environment.NewLine))? SourceCodeKind.Statements : SourceCodeKind.InteractiveCode);
+            SourceUnit su = Language.CreateSnippet(s, &quot;&lt;stdin&gt;&quot;, SourceCodeKind.InteractiveCode);
             PythonCompilerOptions pco = (PythonCompilerOptions)Language.GetCompilerOptions(Scope);
             pco.Module |= ModuleOptions.ExecOrEvalCode;
 </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Hosting/PythonCommandLine.cs</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/IronPython.Build.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -382,7 +382,7 @@
     &lt;Compile Include=&quot;Runtime\Operations\PythonOps.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\Operations\PythonOps.Generated.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\Operations\PythonCalls.cs&quot; /&gt;
-    &lt;Compile Include=&quot;Runtime\Operations\ReflectedPackageOps.cs&quot; /&gt;
+    &lt;Compile Include=&quot;Runtime\Operations\NamespaceTrackerOps.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\Operations\StringOps.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\Operations\TypeTrackerOps.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\Operations\TypeGroupOps.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/IronPython.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -139,7 +139,7 @@ class formatter:
 
 # helper functions for sys.path
 _saved_syspath = []
-def perserve_syspath(): 
+def preserve_syspath(): 
     _saved_syspath[:] = list(set(sys.path))
     
 def restore_syspath():  </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Lib/iptest/assert_util.py</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,7 @@ from iptest.util import get_env_var, get_temp_dir
 is_silverlight = sys.platform == 'silverlight'
 is_cli =         sys.platform == 'cli'
 is_ironpython =  is_silverlight or is_cli
+is_cpython    =  sys.platform == 'win32'
 
 if is_ironpython:
     #We'll use System, if available, to figure out more info on the test</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Lib/iptest/test_env.py</filename>
    </modified>
    <modified>
      <diff>@@ -49,14 +49,8 @@ using System;
 // by using the '*' as shown below:
 
 #if !SILVERLIGHT
-[assembly: AssemblyFileVersion(&quot;2.0.0.00&quot;)]
-[assembly: AssemblyInformationalVersion(&quot;2.0&quot;)]
+[assembly: AssemblyFileVersion(&quot;2.6.0.00&quot;)]
+[assembly: AssemblyInformationalVersion(&quot;2.6&quot;)]
 #endif
 [assembly: SecurityTransparent]
 [assembly: CLSCompliant(false)]
-
-// hack in order to pass AssemblyInfoTask 
-// AssemblyVersion attribute has been decorated in AssemblyVersion.cs
-#if FALSE
-[assembly: AssemblyVersion(&quot;2.0.0.00&quot;)]
-#endif</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Properties/AssemblyInfo.cs</filename>
    </modified>
    <modified>
      <diff>@@ -29,9 +29,6 @@ namespace IronPython.Runtime.Binding {
         internal Func&lt;CallSite, object, CodeContext, object&gt; _func;
         internal int _hitCount;
 
-        public FastGetBase() {
-        }
-
         public abstract bool IsValid(PythonType type);
 
         internal virtual bool ShouldCache {</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/FastGetBase.cs</filename>
    </modified>
    <modified>
      <diff>@@ -723,7 +723,7 @@ namespace IronPython.Runtime.Binding {
             res[typeof(DynamicNull)] = new ExtensionTypeInfo(typeof(NoneTypeOps), &quot;NoneType&quot;);
             res[typeof(BaseSymbolDictionary)] = new ExtensionTypeInfo(typeof(DictionaryOps), &quot;dict&quot;);
             res[typeof(IAttributesCollection)] = new ExtensionTypeInfo(typeof(DictionaryOps), &quot;dict&quot;);
-            res[typeof(NamespaceTracker)] = new ExtensionTypeInfo(typeof(ReflectedPackageOps), &quot;namespace#&quot;);
+            res[typeof(NamespaceTracker)] = new ExtensionTypeInfo(typeof(NamespaceTrackerOps), &quot;namespace#&quot;);
             res[typeof(TypeGroup)] = new ExtensionTypeInfo(typeof(TypeGroupOps), &quot;type-collision&quot;);
             res[typeof(TypeTracker)] = new ExtensionTypeInfo(typeof(TypeTrackerOps), &quot;type-collision&quot;);
             res[typeof(Scope)] = new ExtensionTypeInfo(typeof(ScopeOps), &quot;module&quot;);</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/PythonBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -17,12 +17,15 @@ using System;
 using System.Diagnostics;
 using System.Dynamic;
 using System.Linq.Expressions;
+using System.Reflection;
 using System.Runtime.CompilerServices;
+using System.Text;
 
 using Microsoft.Scripting;
 using Microsoft.Scripting.Actions;
 using Microsoft.Scripting.Generation;
 using Microsoft.Scripting.Runtime;
+using Microsoft.Scripting.Utils;
 
 using IronPython.Runtime.Operations;
 using IronPython.Runtime.Types;
@@ -71,7 +74,7 @@ namespace IronPython.Runtime.Binding {
                 return GetForeignObject(target);
             }
 #if !SILVERLIGHT
-            else if (ComOps.IsComObject(target.Value)) {
+ else if (ComOps.IsComObject(target.Value)) {
                 return GetForeignObject(target);
             }
 #endif
@@ -80,7 +83,7 @@ namespace IronPython.Runtime.Binding {
 
         public override T BindDelegate&lt;T&gt;(CallSite&lt;T&gt; site, object[] args) {
             Debug.Assert(args[1].GetType() == typeof(CodeContext));
-            
+
             IFastGettable fastGet = args[0] as IFastGettable;
             if (fastGet != null) {
                 T res = fastGet.MakeGetBinding&lt;T&gt;(site, this, (CodeContext)args[1], Name);
@@ -90,6 +93,7 @@ namespace IronPython.Runtime.Binding {
                 }
 
                 PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;IFastGettable&quot;);
+                return base.BindDelegate&lt;T&gt;(site, args);
             }
 
             IPythonObject pyObj = args[0] as IPythonObject;
@@ -104,6 +108,7 @@ namespace IronPython.Runtime.Binding {
                 }
 
                 PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;IPythonObject Get&quot;);
+                return base.BindDelegate&lt;T&gt;(site, args);
             }
 
             if (args[0] != null) {
@@ -114,7 +119,7 @@ namespace IronPython.Runtime.Binding {
                         return (T)(object)new Func&lt;CallSite, object, CodeContext, object&gt;(new ScopeDelegate(_name).NoThrowTarget);
                     }
                 } else if (args[0].GetType() == typeof(NamespaceTracker)) {
-                    switch(Name) {
+                    switch (Name) {
                         case &quot;__str__&quot;:
                         case &quot;__repr__&quot;:
                             // need to return the built in method descriptor for these...
@@ -128,14 +133,303 @@ namespace IronPython.Runtime.Binding {
                         default:
                             return (T)(object)new Func&lt;CallSite, object, CodeContext, object&gt;(new NamespaceTrackerDelegate(_name).Target);
                     }
-                    
                 }
             }
 
+            if (args[0] != null &amp;&amp;
+#if !SILVERLIGHT
+ !ComOps.IsComObject(args[0]) &amp;&amp;
+#endif
+ !(args[0] is IDynamicMetaObjectProvider)) {
+                Type selfType = typeof(T).GetMethod(&quot;Invoke&quot;).GetParameters()[1].ParameterType;
+                T res = null;
+                if (selfType == typeof(object)) {
+                    res = (T)(object)MakeGetMemberTarget&lt;object&gt;(Name, args[0]);
+                } else if (selfType == typeof(List)) {
+                    res = (T)(object)MakeGetMemberTarget&lt;List&gt;(Name, args[0]);
+                } else if (selfType == typeof(string)) {
+                    res = (T)(object)MakeGetMemberTarget&lt;string&gt;(Name, args[0]);
+                }
+
+                if (res != null) {
+                    return (T)(object)res;
+                }
+                return base.BindDelegate&lt;T&gt;(site, args);
+            }
+
             PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast &quot; + IsNoThrow + &quot; &quot; + CompilerHelpers.GetType(args[0]));
             return base.BindDelegate&lt;T&gt;(site, args);
         }
 
+        class FastErrorGet&lt;TSelfType&gt; : FastGetBase {
+            private readonly Type _type;
+            private readonly string _name;
+
+            public FastErrorGet(Type type, string name) {
+                _type = type;
+                _name = name;
+            }
+
+            public override bool IsValid(PythonType type) {
+                // only used for built-in types, we never become invalid.
+                return true;
+            }
+
+            public object GetError(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    throw PythonOps.AttributeErrorForMissingAttribute(DynamicHelpers.GetPythonType(target).Name, SymbolTable.StringToId(_name));
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+
+            public object GetErrorNoThrow(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    return OperationFailed.Value;
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+
+            public object GetAmbiguous(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    throw new AmbiguousMatchException(_name);
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+
+        }
+
+        class BuiltinBase&lt;TSelfType&gt; : FastGetBase {
+            public override bool IsValid(PythonType type) {
+                // only used for built-in types, we never become invalid.
+                return true;
+            }
+        }
+
+        class FastMethodGet&lt;TSelfType&gt; : BuiltinBase&lt;TSelfType&gt; {
+            private readonly Type _type;
+            private readonly BuiltinMethodDescriptor _method;
+
+            public FastMethodGet(Type type, BuiltinMethodDescriptor method) {
+                _type = type;
+                _method = method;
+            }
+
+            public object GetMethod(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    return _method.UncheckedGetAttribute(target);
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+        }
+
+        class FastSlotGet&lt;TSelfType&gt; : BuiltinBase&lt;TSelfType&gt; {
+            private readonly Type _type;
+            private readonly PythonTypeSlot _slot;
+            private readonly PythonType _owner;
+
+            public FastSlotGet(Type type, PythonTypeSlot slot, PythonType owner) {
+                _type = type;
+                _slot = slot;
+                _owner = owner;
+            }
+
+            public object GetRetSlot(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    return _slot;
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+
+            public object GetBindSlot(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    object value;
+                    _slot.TryGetValue(context, target, _owner, out value);
+                    return value;
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+        }
+
+        class FastTypeGet&lt;TSelfType&gt; : BuiltinBase&lt;TSelfType&gt; {
+            private readonly Type _type;
+            private readonly object _pyType;
+
+            public FastTypeGet(Type type, object pythonType) {
+                _type = type;
+                _pyType = pythonType;
+            }
+
+            public object GetTypeObject(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    return _pyType;
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+        }
+
+        class FastPropertyGet&lt;TSelfType&gt; : BuiltinBase&lt;TSelfType&gt; {
+            private readonly Type _type;
+            private readonly Func&lt;object, object&gt; _propGetter;
+
+            public FastPropertyGet(Type type, Func&lt;object, object&gt; propGetter) {
+                _type = type;
+                _propGetter = propGetter;
+            }
+
+            public object GetProperty(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    return _propGetter(target);
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+
+            public object GetPropertyBool(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    return ScriptingRuntimeHelpers.BooleanToObject((bool)_propGetter(target));
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+
+            public object GetPropertyInt(CallSite site, TSelfType target, CodeContext context) {
+                if (target != null &amp;&amp; target.GetType() == _type) {
+                    return ScriptingRuntimeHelpers.Int32ToObject((int)_propGetter(target));
+                }
+
+                return ((CallSite&lt;Func&lt;CallSite, TSelfType, CodeContext, object&gt;&gt;)site).Update(site, target, context);
+            }
+        }
+
+        private Func&lt;CallSite, TSelfType, CodeContext, object&gt; MakeGetMemberTarget&lt;TSelfType&gt;(string name, object target) {
+            Type type = CompilerHelpers.GetType(target);
+
+            // needed for GetMember call until DynamicAction goes away
+            OldDynamicAction act = OldGetMemberAction.Make(Context.Binder, name);
+
+            if (typeof(TypeTracker).IsAssignableFrom(type)) {
+                // no fast path for TypeTrackers
+                PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast TypeTracker&quot;);
+                return null;
+            }
+
+            MemberGroup members = Context.Binder.GetMember(act, type, name);
+
+            if (members.Count == 0 &amp;&amp; type.IsInterface) {
+                // all interfaces have object members
+                type = typeof(object);
+                members = Context.Binder.GetMember(act, type, name);
+            }
+
+            if (members.Count == 0 &amp;&amp; typeof(IStrongBox).IsAssignableFrom(type)) {
+                // no fast path for strong box access
+                PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast StrongBox&quot;);
+                return null;
+            }
+
+            MethodInfo getMem = Context.Binder.GetMethod(type, &quot;GetCustomMember&quot;);
+            if (getMem != null &amp;&amp; getMem.IsSpecialName) {
+                // no fast path for custom member access
+                PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast GetCustomMember &quot; + type);
+                return null;
+            }
+
+            Expression error;
+            TrackerTypes memberType = Context.Binder.GetMemberType(members, out error);
+
+            if (error == null) {
+                PythonType argType = DynamicHelpers.GetPythonTypeFromType(type);
+                bool isHidden = argType.IsHiddenMember(name);
+                if (isHidden) {
+                    PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast FilteredMember &quot; + memberType);
+                    return null;
+                }
+
+                switch (memberType) {
+                    case TrackerTypes.TypeGroup:
+                    case TrackerTypes.Type:
+                        object typeObj;
+                        if (members.Count == 1) {
+                            typeObj = DynamicHelpers.GetPythonTypeFromType(((TypeTracker)members[0]).Type);
+                        } else {
+                            TypeTracker typeTracker = (TypeTracker)members[0];
+                            for (int i = 1; i &lt; members.Count; i++) {
+                                typeTracker = TypeGroup.UpdateTypeEntity(typeTracker, (TypeTracker)members[i]);
+                            }
+                            typeObj = typeTracker;
+                        }
+
+                        return new FastTypeGet&lt;TSelfType&gt;(type, typeObj).GetTypeObject;
+                    case TrackerTypes.Method:
+                        PythonTypeSlot slot = PythonTypeOps.GetSlot(members, name, _context.DomainManager.Configuration.PrivateBinding);
+                        if (slot is BuiltinMethodDescriptor) {
+                            return new FastMethodGet&lt;TSelfType&gt;(type, (BuiltinMethodDescriptor)slot).GetMethod;
+                        } else if (slot is BuiltinFunction) {
+                            return new FastSlotGet&lt;TSelfType&gt;(type, slot, DynamicHelpers.GetPythonTypeFromType(type)).GetRetSlot;
+                        }
+                        return new FastSlotGet&lt;TSelfType&gt;(type, slot, DynamicHelpers.GetPythonTypeFromType(type)).GetBindSlot;
+                    case TrackerTypes.Event:
+                        if (members.Count == 1 &amp;&amp; !((EventTracker)members[0]).IsStatic) {
+                            slot = PythonTypeOps.GetSlot(members, name, _context.DomainManager.Configuration.PrivateBinding);
+                            return new FastSlotGet&lt;TSelfType&gt;(type, slot, DynamicHelpers.GetPythonTypeFromType(((EventTracker)members[0]).DeclaringType)).GetBindSlot;
+                        }
+                        PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast Event &quot; + members.Count + &quot; &quot; + ((EventTracker)members[0]).IsStatic);
+                        return null;
+                    case TrackerTypes.Property:
+                        if (members.Count == 1) {
+                            PropertyTracker pt = (PropertyTracker)members[0];
+                            if (!pt.IsStatic &amp;&amp; pt.GetIndexParameters().Length == 0) {
+                                MethodInfo prop = pt.GetGetMethod();
+
+                                if (prop != null &amp;&amp; prop.GetParameters().Length == 0) {
+                                    if (prop.ReturnType == typeof(bool)) {
+                                        return new FastPropertyGet&lt;TSelfType&gt;(type, ReflectedCaller.Create(prop).Invoke).GetPropertyBool;
+                                    } else if (prop.ReturnType == typeof(int)) {
+                                        return new FastPropertyGet&lt;TSelfType&gt;(type, ReflectedCaller.Create(prop).Invoke).GetPropertyInt;
+                                    } else {
+                                        return new FastPropertyGet&lt;TSelfType&gt;(type, ReflectedCaller.Create(prop).Invoke).GetProperty;
+                                    }
+                                }
+                            }
+                        }
+                        PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast Property &quot; + members.Count + &quot; &quot; + ((PropertyTracker)members[0]).IsStatic);
+                        return null;
+                    case TrackerTypes.All:
+                        getMem = Context.Binder.GetMethod(type, &quot;GetBoundMember&quot;);
+                        if (getMem != null &amp;&amp; getMem.IsSpecialName) {
+                            PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast GetBoundMember &quot; + type);
+                            return null;
+                        }
+
+                        if (IsNoThrow) {
+                            return new FastErrorGet&lt;TSelfType&gt;(type, name).GetErrorNoThrow;
+                        } else {
+                            return new FastErrorGet&lt;TSelfType&gt;(type, name).GetError;
+                        }
+                    default:
+                        PerfTrack.NoteEvent(PerfTrack.Categories.BindingSlow, &quot;GetNoFast &quot; + memberType);
+                        return null;
+                }
+            } else {
+                StringBuilder sb = new StringBuilder();
+                foreach (MemberTracker mi in members) {
+                    if (sb.Length != 0) sb.Append(&quot;, &quot;);
+                    sb.Append(mi.MemberType);
+                    sb.Append(&quot; : &quot;);
+                    sb.Append(mi.ToString());
+                }
+
+                return new FastErrorGet&lt;TSelfType&gt;(type, sb.ToString()).GetAmbiguous;
+            }
+        }
+
         class ScopeDelegate : FastGetBase {
             private readonly string _name;
 
@@ -144,7 +438,7 @@ namespace IronPython.Runtime.Binding {
             }
 
             public object Target(CallSite site, object self, CodeContext context) {
-                if(self != null &amp;&amp; self.GetType() == typeof(Scope)) {
+                if (self != null &amp;&amp; self.GetType() == typeof(Scope)) {
                     return ScopeOps.__getattribute__(context, (Scope)self, _name);
                 }
 
@@ -173,7 +467,7 @@ namespace IronPython.Runtime.Binding {
 
             public object Target(CallSite site, object self, CodeContext context) {
                 if (self != null &amp;&amp; self.GetType() == typeof(NamespaceTracker)) {
-                    object res = ReflectedPackageOps.GetCustomMember(context, (NamespaceTracker)self, _name);
+                    object res = NamespaceTrackerOps.GetCustomMember(context, (NamespaceTracker)self, _name);
                     if (res != OperationFailed.Value) {
                         return res;
                     }
@@ -186,7 +480,7 @@ namespace IronPython.Runtime.Binding {
 
             public object GetName(CallSite site, object self, CodeContext context) {
                 if (self != null &amp;&amp; self.GetType() == typeof(NamespaceTracker)) {
-                    return ReflectedPackageOps.Get__name__(context, (NamespaceTracker)self);
+                    return NamespaceTrackerOps.Get__name__(context, (NamespaceTracker)self);
                 }
 
                 return Update(site, self, context);
@@ -194,7 +488,7 @@ namespace IronPython.Runtime.Binding {
 
             public object GetFile(CallSite site, object self, CodeContext context) {
                 if (self != null &amp;&amp; self.GetType() == typeof(NamespaceTracker)) {
-                    return ReflectedPackageOps.Get__file__((NamespaceTracker)self);
+                    return NamespaceTrackerOps.Get__file__((NamespaceTracker)self);
                 }
 
                 return Update(site, self, context);
@@ -202,7 +496,7 @@ namespace IronPython.Runtime.Binding {
 
             public object GetDict(CallSite site, object self, CodeContext context) {
                 if (self != null &amp;&amp; self.GetType() == typeof(NamespaceTracker)) {
-                    return ReflectedPackageOps.Get__dict__(context, (NamespaceTracker)self);
+                    return NamespaceTrackerOps.Get__dict__(context, (NamespaceTracker)self);
                 }
 
                 return Update(site, self, context);
@@ -243,7 +537,7 @@ namespace IronPython.Runtime.Binding {
             PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, &quot;FallbackGet&quot;);
 
             bool isNoThrow = ((options &amp; GetMemberOptions.IsNoThrow) != 0) ? true : false;
-            Type limitType = self.GetLimitType() ;
+            Type limitType = self.GetLimitType();
 
             if (limitType == typeof(DynamicNull) || PythonBinder.IsPythonType(limitType)) {
                 // look up in the PythonType so that we can 
@@ -313,7 +607,7 @@ namespace IronPython.Runtime.Binding {
                     PythonContext.GetPythonContext(action).Binder.MakeMissingMemberError(
                         limitType,
                         name
-                    ), 
+                    ),
                     typeof(object)
                 );
         }</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/PythonGetMemberBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,7 @@ using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Text;
+using System.Threading;
 
 using Microsoft.Scripting;
 using Microsoft.Scripting.Actions;
@@ -1741,11 +1742,30 @@ namespace IronPython.Runtime {
             }
         }
 
+        [ThreadStatic]
+        private static List&lt;Scope&gt; _reloadStack; 
+
         public static object reload(CodeContext/*!*/ context, Scope/*!*/ scope) {
             if (scope == null) {
                 throw PythonOps.TypeError(&quot;unexpected type: NoneType&quot;);
             }
-            return Importer.ReloadModule(context, scope);
+
+            if (_reloadStack == null) {
+                Interlocked.CompareExchange(ref _reloadStack, new List&lt;Scope&gt;(), null);
+            }
+
+            // if a module attempts to reload it's self while already reloading it's 
+            // self we just return the original module.
+            if (_reloadStack.Contains(scope)) {
+                return scope;
+            }
+
+            _reloadStack.Add(scope);
+            try {
+                return Importer.ReloadModule(context, scope);
+            } finally {
+                _reloadStack.RemoveAt(_reloadStack.Count - 1);
+            }
         }
 
         public static object repr(CodeContext/*!*/ context, object o) {</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Builtin.cs</filename>
    </modified>
    <modified>
      <diff>@@ -834,7 +834,8 @@ namespace IronPython.Runtime.Exceptions {
         /// Creates a PythonType for a built-in module.  These types are mutable like
         /// normal user types.
         /// &lt;/summary&gt;
-        internal static PythonType CreateSubType(PythonContext/*!*/ context, PythonType baseType, string name, string module, string documentation) {
+        [PythonHidden]
+        public static PythonType CreateSubType(PythonContext/*!*/ context, PythonType baseType, string name, string module, string documentation) {
             return new PythonType(null, baseType, name, module, documentation);            
         }
 </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Exceptions/PythonExceptions.cs</filename>
    </modified>
    <modified>
      <diff>@@ -118,7 +118,7 @@ namespace IronPython.Runtime {
                         return res;
                     }
                 } else if ((nt = from as NamespaceTracker) != null) {
-                    object res = ReflectedPackageOps.GetCustomMember(context, nt, name);
+                    object res = NamespaceTrackerOps.GetCustomMember(context, nt, name);
                     if (res != OperationFailed.Value) {
                         return res;
                     }
@@ -166,18 +166,44 @@ namespace IronPython.Runtime {
         /// &lt;/summary&gt;        
         public static object ImportModule(CodeContext/*!*/ context, object globals, string/*!*/ modName, bool bottom, int level) {
             if (modName.IndexOf(Path.DirectorySeparatorChar) != -1) {
-                return null;
+                throw PythonOps.ImportError(&quot;Import by filename is not supported.&quot;, modName);
+            }
+
+            string package = null;
+            object attribute;
+            if (TryGetGlobalValue(globals, Symbols.Package, out attribute)) {
+                package = attribute as string;
+                if (package == null &amp;&amp; attribute != null) {
+                    throw PythonOps.ValueError(&quot;__package__ set to non-string&quot;);
+                }
+            } else {
+                package = null;
+                if (level &gt; 0) {
+                    // explicit relative import, calculate and store __package__
+                    object pathAttr, nameAttr;
+                    if (TryGetGlobalValue(globals, Symbols.Name, out nameAttr) &amp;&amp; nameAttr is string) {
+                        if (TryGetGlobalValue(globals, Symbols.Path, out pathAttr)) {
+                            ((IAttributesCollection)globals)[Symbols.Package] = nameAttr;
+                        } else {
+                            ((IAttributesCollection)globals)[Symbols.Package] = ((string)nameAttr).rpartition(&quot;.&quot;)[0];
+                        }
+                    }
+                }
             }
 
             object newmod = null;
             string[] parts = modName.Split('.');
+            string finalName = null;
 
             if (level != 0) {
+                // try a relative import
+            
                 // if importing a.b.c, import &quot;a&quot; first and then import b.c from a
                 string name;    // name of the module we are to import in relation to the current module
-                List path;      // path to search
                 Scope parentScope;
-                if (TryGetNameAndPath(context, globals, parts[0], level, out name, out path, out parentScope)) {
+                List path;      // path to search
+                if (TryGetNameAndPath(context, globals, parts[0], level, package, out name, out path, out parentScope)) {
+                    finalName = name;
                     // import relative
                     if (!TryGetExistingOrMetaPathModule(context, name, path, out newmod)) {
                         newmod = ImportTopRelative(context, parts[0], name, path);
@@ -197,26 +223,51 @@ namespace IronPython.Runtime {
             }
             
             if (level &lt;= 0) {
+                // try an absolute import
                 if (newmod == null) {
+                    object parentPkg;
+                    if (package != null &amp;&amp; !PythonContext.GetContext(context).SystemStateModules.TryGetValue(package, out parentPkg)) {
+                        Scope warnScope = new Scope();
+                        warnScope.SetName(Symbols.File, package);
+                        warnScope.SetName(Symbols.Name, package);
+                        PythonOps.Warn(
+                            new CodeContext(warnScope, context.LanguageContext), 
+                            PythonExceptions.RuntimeWarning, 
+                            &quot;Parent module '{0}' not found while handling absolute import&quot;, 
+                            package);
+                    }
+
                     newmod = ImportTopAbsolute(context, parts[0]);
-                    
+                    finalName = parts[0];
                     if (newmod == null) {
                         return null;
                     }
                 }
             }
             
-            // now import the b.c etc.
+            // now import the a.b.c etc.  a needs to be included here
+            // because the process of importing could have modified
+            // sys.modules.
             object next = newmod;
-            string curName = parts[0];
-            for (int i = 1; i &lt; parts.Length; i++) {
-                curName = curName + &quot;.&quot; + parts[i];
+            string curName = null;
+            for (int i = 0; i &lt; parts.Length; i++) {
+                curName = i == 0 ? finalName : curName + &quot;.&quot; + parts[i];
                 object tmpNext;
                 if (TryGetExistingModule(context, curName, out tmpNext)) {
                     next = tmpNext;
-                    continue;
+                    if (i == 0) {
+                        // need to update newmod if we pulled it out of sys.modules
+                        // just in case we're in bottom mode.
+                        newmod = next;
+                    }
+                } else if(i != 0) {
+                    // child module isn't loaded yet, import it.
+                    next = ImportModuleFrom(context, next, parts[i]);
+                } else {
+                    // top-level module doesn't exist in sys.modules, probably
+                    // came from some weird meta path hook.
+                    newmod = next;
                 }
-                next = ImportModuleFrom(context, next, parts[i]);
             }
 
             return bottom ? next : newmod;
@@ -246,8 +297,9 @@ namespace IronPython.Runtime {
         /// &lt;param name=&quot;path&quot;&gt;Path to use to search for &quot;full&quot;&lt;/param&gt;
         /// &lt;param name=&quot;level&quot;&gt;the import level for relaive imports&lt;/param&gt;
         /// &lt;param name=&quot;parentScope&quot;&gt;the parent scope&lt;/param&gt;
+        /// &lt;param name=&quot;package&quot;&gt;the global __package__ value&lt;/param&gt;
         /// &lt;returns&gt;&lt;/returns&gt;
-         private static bool TryGetNameAndPath(CodeContext/*!*/ context, object globals, string name, int level, out string full, out List path, out Scope parentScope) {
+         private static bool TryGetNameAndPath(CodeContext/*!*/ context, object globals, string name, int level, string package, out string full, out List path, out Scope parentScope) {
            Debug.Assert(level != 0);   // shouldn't be here for absolute imports
 
             // Unless we can find enough information to perform relative import,
@@ -259,6 +311,7 @@ namespace IronPython.Runtime {
             // We need to get __name__ to find the name of the imported module.
             // If absent, fall back to absolute import
             object attribute;
+
             if (!TryGetGlobalValue(globals, Symbols.Name, out attribute)) {
                 return false;
             }
@@ -268,10 +321,10 @@ namespace IronPython.Runtime {
             if (modName == null) {
                 return false;
             }
-
+           
             // If the module has __path__ (and __path__ is list), nested module is being imported
             // otherwise, importing sibling to the importing module
-            if (TryGetGlobalValue(globals, Symbols.Path, out attribute) &amp;&amp; (path = attribute as List) != null) {
+            if (package == null &amp;&amp; TryGetGlobalValue(globals, Symbols.Path, out attribute) &amp;&amp; (path = attribute as List) != null) {
                 // found __path__, importing nested module. The actual name of the nested module
                 // is the name of the mod plus the name of the imported module
                 if (level == -1) {
@@ -284,26 +337,28 @@ namespace IronPython.Runtime {
                     // relative import of some ancestors child
                     full = (StringOps.rsplit(modName, &quot;.&quot;, level - 1)[0] as string) + &quot;.&quot; + name;
                 }
-                return true;                
+                return true;
             }
-
+             
             // importing sibling. The name of the imported module replaces
             // the last element in the importing module name
             string[] names = modName.Split('.');
             if (names.Length == 1) {
                 // name doesn't include dot, only absolute import possible
+                if (level &gt; 0) {
+                    throw PythonOps.ValueError(&quot;Attempted relative import in non-package&quot;);
+                }
+
                 return false;
             }
 
-            StringBuilder parentName = new StringBuilder(names[0]);
-
-            if (level == -1) level = 1;
-            for (int i = 1; i &lt; names.Length - level; i++) {
-                parentName.Append('.');
-                parentName.Append(names[i]);
+            string pn;
+            if (package == null) {
+                pn = GetParentPackageName(level, names);
+            } else {
+                // __package__ doesn't include module name, so level is - 1.
+                pn = GetParentPackageName(level - 1, package.Split('.'));
             }
-            
-            string pn = parentName.ToString();
 
             path = GetParentPathAndScope(context, pn, out parentScope);
             if (path != null) {
@@ -315,10 +370,24 @@ namespace IronPython.Runtime {
                 return true;
             }
 
+            if (level &gt; 0) {
+                throw PythonOps.SystemError(&quot;Parent module '{0}' not loaded, cannot perform relative import&quot;, pn);
+            }
             // not enough information - absolute import
             return false;
         }
 
+         private static string GetParentPackageName(int level, string[] names) {
+             StringBuilder parentName = new StringBuilder(names[0]);
+
+             if (level &lt; 0) level = 1;
+             for (int i = 1; i &lt; names.Length - level; i++) {
+                 parentName.Append('.');
+                 parentName.Append(names[i]);
+             }
+             return parentName.ToString();
+         }
+
         private static bool TryGetGlobalValue(object globals, SymbolId symbol, out object attribute) {
             IAttributesCollection attrGlobals = globals as IAttributesCollection;
             if (attrGlobals != null) {
@@ -608,6 +677,9 @@ namespace IronPython.Runtime {
             }
 
             ret = MemberTrackerToPython(context, ret);
+            if (ret != null) {
+                PythonContext.GetContext(context).SystemStateModules[name] = ret;
+            }
             return ret;
         }
 </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Importer.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1689,7 +1689,7 @@ namespace IronPython.Runtime.Operations {
                 if (scope != null) {
                     context.Scope.SetName(fieldId, scope.Dict[fieldId]);
                 } else if (nt != null) {
-                    object value = ReflectedPackageOps.GetCustomMember(context, nt, name);
+                    object value = NamespaceTrackerOps.GetCustomMember(context, nt, name);
                     if (value != OperationFailed.Value) {
                         context.Scope.SetName(fieldId, value);
                     }
@@ -3166,16 +3166,7 @@ namespace IronPython.Runtime.Operations {
 
         public static void Warn(CodeContext/*!*/ context, PythonType category, string message, params object[] args) {
             PythonContext pc = PythonContext.GetContext(context);
-            object warnings = null, warn = null;
-
-            try {
-                if (!pc._importWarningThrows) {
-                    warnings = Importer.ImportModule(context, new PythonDictionary(), &quot;warnings&quot;, false, -1);
-                }
-            } catch {
-                // don't repeatedly import after it fails
-                pc._importWarningThrows = true;
-            }
+            object warnings = pc.GetWarningsModule(), warn = null;
 
             if (warnings != null) {
                 warn = PythonOps.GetBoundAttr(context, warnings, SymbolTable.StringToId(&quot;warn&quot;));</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/PythonOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -914,6 +914,7 @@ namespace IronPython.Runtime {
 
             PythonModule mod = CreateModule(null, new Scope(dict), null, options);
             mod.Scope.SetName(Symbols.Name, moduleName);
+            mod.Scope.SetName(Symbols.Package, null);
             return mod;
         }
 
@@ -941,6 +942,10 @@ namespace IronPython.Runtime {
 
             if ((options &amp; ModuleOptions.Initialize) != 0) {
                 scriptCode.Run(module.Scope);
+                
+                if (!scope.ContainsName(Symbols.Package)) {
+                    scope.SetName(Symbols.Package, null);
+                }
             }
 
             return module;
@@ -1003,6 +1008,19 @@ namespace IronPython.Runtime {
 
         #endregion
 
+        public object GetWarningsModule() {
+            object warnings = null;
+            try {
+                if (!_importWarningThrows) {
+                    warnings = Importer.ImportModule(SharedContext, new PythonDictionary(), &quot;warnings&quot;, false, -1);
+                }
+            } catch {
+                // don't repeatedly import after it fails
+                _importWarningThrows = true;
+            }
+            return warnings;
+        }
+
         /// &lt;summary&gt;
         /// Python's global scope includes looking at built-ins.  First check built-ins, and if
         /// not there then fallback to any DLR globals.</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/PythonContext.cs</filename>
    </modified>
    <modified>
      <diff>@@ -194,6 +194,7 @@ namespace IronPython.Runtime {
             return !EnforceRecursion &amp;&amp;
                 args.Length &gt;= (NormalArgumentCount - _defaults.Length) &amp;&amp;
                 args.Length &lt;= NormalArgumentCount &amp;&amp;
+                Defaults.Length &lt;= 13 &amp;&amp;
                 !binder.Signature.HasDictionaryArgument() &amp;&amp;
                 !binder.Signature.HasKeywordArgument() &amp;&amp;
                 !binder.Signature.HasListArgument() &amp;&amp;</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/PythonFunction.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -512,6 +512,7 @@ namespace IronPython.Runtime {
         private static SymbolId _AbsoluteImport;
         private static SymbolId _PrintFunction;
         private static SymbolId _UnicodeLiterals;
+        private static SymbolId _Package;
         ///&lt;summary&gt;Symbol for '__neg__'&lt;/summary&gt; 
         public static SymbolId OperatorNegate {
             get {
@@ -1268,6 +1269,13 @@ namespace IronPython.Runtime {
                 return _UnicodeLiterals;
             }
         }
+        ///&lt;summary&gt;Symbol for '__package__'&lt;/summary&gt; 
+        public static SymbolId Package {
+            get {
+                if (_Package == SymbolId.Empty) _Package = MakeSymbolId(&quot;__package__&quot;);
+                return _Package;
+            }
+        }
 
         // *** END GENERATED CODE ***
 </diff>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Symbols.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -357,6 +357,7 @@ namespace IronRuby.Tests {
                 ClrIndexers1,
                 ClrGenericMethods1,
                 ClrOverloadSelection1,
+                ClrOverloadSelection2,
                 ClrInterfaces1,
                 ClrRequireAssembly1,
                 ClrInclude1,
@@ -372,7 +373,8 @@ namespace IronRuby.Tests {
                 ClrEvents4,
                 ClrOverride1,
                 ClrConstructor1,
-                // TODO: ClrConstructor2,
+                ClrConstructor2,
+                ClrConstructor3,
                 ClrPrimitiveNumericTypes1,
                 ClrArrays1,
                 ClrChar1,</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -355,15 +355,15 @@ Hidden: 1, 2
             public class Y : X { }
             
             public static void Load(RubyContext/*!*/ context) {
-                context.ObjectClass.SetConstant(&quot;A&quot;, context.GetClass(typeof(OverloadInheritance2.A)));
-                context.ObjectClass.SetConstant(&quot;B&quot;, context.GetClass(typeof(OverloadInheritance2.B)));
-                context.ObjectClass.SetConstant(&quot;C&quot;, context.GetClass(typeof(OverloadInheritance2.C)));
-                context.ObjectClass.SetConstant(&quot;D&quot;, context.GetClass(typeof(OverloadInheritance2.D)));
-                context.ObjectClass.SetConstant(&quot;E&quot;, context.GetClass(typeof(OverloadInheritance2.E)));
-                context.ObjectClass.SetConstant(&quot;F&quot;, context.GetClass(typeof(OverloadInheritance2.F)));
-                context.ObjectClass.SetConstant(&quot;G&quot;, context.GetClass(typeof(OverloadInheritance2.G)));
-                context.ObjectClass.SetConstant(&quot;X&quot;, context.GetClass(typeof(OverloadInheritance2.X)));
-                context.ObjectClass.SetConstant(&quot;Y&quot;, context.GetClass(typeof(OverloadInheritance2.Y)));
+                context.ObjectClass.SetConstant(&quot;A&quot;, context.GetClass(typeof(A)));
+                context.ObjectClass.SetConstant(&quot;B&quot;, context.GetClass(typeof(B)));
+                context.ObjectClass.SetConstant(&quot;C&quot;, context.GetClass(typeof(C)));
+                context.ObjectClass.SetConstant(&quot;D&quot;, context.GetClass(typeof(D)));
+                context.ObjectClass.SetConstant(&quot;E&quot;, context.GetClass(typeof(E)));
+                context.ObjectClass.SetConstant(&quot;F&quot;, context.GetClass(typeof(F)));
+                context.ObjectClass.SetConstant(&quot;G&quot;, context.GetClass(typeof(G)));
+                context.ObjectClass.SetConstant(&quot;X&quot;, context.GetClass(typeof(X)));
+                context.ObjectClass.SetConstant(&quot;Y&quot;, context.GetClass(typeof(Y)));
             }
         }
 
@@ -743,6 +743,63 @@ end
             );
         }
 
+        public static class OverloadSelection2 {
+            public class A {
+                public A() {
+                }
+
+                public A(int a) {
+                }
+
+                public A(RubyClass cls, double a) {
+                }
+
+                public static int Foo() { return 1; }
+                public static int Foo(RubyScope scope, BlockParam block, int a) { return 2; }
+            }
+
+            public class B : A {
+                public static int Foo(double a) { return 3; }
+                public static int Foo(RubyClass cls, string b) { return 4; }
+            }
+
+            public static void Load(RubyContext/*!*/ context) {
+                context.ObjectClass.SetConstant(&quot;A&quot;, context.GetClass(typeof(A)));
+                context.ObjectClass.SetConstant(&quot;B&quot;, context.GetClass(typeof(B)));
+            }
+        }
+
+        public void ClrOverloadSelection2() {
+            OverloadSelection2.Load(Context);
+
+            // TODO: constructor overload selection
+            // B.overloads(Fixnum).new(1) ???
+
+            // static methods:
+            TestOutput(@&quot;
+m = B.method(:foo)
+puts m.overloads(Fixnum).clr_members.size          # RubyScope and BlockParam are hidden
+puts m.overloads(System::String) rescue p $!       # RubyClass is not hidden here
+&quot;, @&quot;
+1
+#&lt;ArgumentError: no overload of `foo' matches given parameter types&gt;
+&quot;);
+
+            // library methods:
+            TestOutput(@&quot;
+m = method(:print)
+puts m.arity
+puts m.overloads().arity
+puts m.overloads(Object).arity
+puts m.overloads(System::Array[Object]).arity
+&quot;, @&quot;
+-1
+0
+1
+-1
+&quot;);
+        }
+
         public class ClassWithInterfaces1 : IEnumerable {
             public IEnumerator GetEnumerator() {
                 yield return 1;
@@ -1143,52 +1200,161 @@ RM1CM2CP1CP2RP3
         }
 
         public class ClassWithNonEmptyConstructor {
-            public string P { get; set; }
+            public int P { get; set; }
+
             public ClassWithNonEmptyConstructor() {
             }
-            public ClassWithNonEmptyConstructor(string p) {
+
+            public ClassWithNonEmptyConstructor(BinaryOpStorage storage, RubyScope scope, RubyClass self, string p) {
+            }
+
+            public ClassWithNonEmptyConstructor(RubyContext context, int i) {
+                P = i;
+            }
+
+            public ClassWithNonEmptyConstructor(RubyContext context, RubyClass cls1, RubyClass cls2) {
+            }
+        }
+
+        public class ClassWithNonEmptyConstructor2 {
+            public int P { get; set; }
+
+            public ClassWithNonEmptyConstructor2() {
+                P = 0;
+            }
+
+            public ClassWithNonEmptyConstructor2(RubyClass cls) {
+                P = 1;
+            }
+
+            public ClassWithNonEmptyConstructor2(RubyContext context) {
+                P = 2;
+            }
+        }
+
+        public class ExceptionWithDefaultConstructor1 : Exception {
+            public ExceptionWithDefaultConstructor1() {
+            }
+        }
+
+        public class ExceptionWithStdConstructors1 : Exception {
+            public int P { get; set; }
+            public ExceptionWithStdConstructors1() {
+                P = 0;
+            }
+
+            public ExceptionWithStdConstructors1(string message) : base(message) {
+                P = 1;
+            }
+        }
+
+        public class ClassWithNoDefaultConstructor {
+            public string P { get; set; }
+
+            public ClassWithNoDefaultConstructor(string p) {
                 P = p;
             }
         }
 
-        private static bool IsAvailable(MethodBase method) {
+        private static bool IsCtorAvailable(RubyClass cls, params Type[] parameters) {
+            var method = cls.GetUnderlyingSystemType().GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, parameters, null);
             return method != null &amp;&amp; !method.IsPrivate &amp;&amp; !method.IsFamilyAndAssembly;
         }
 
         public void ClrConstructor1() {
-            Context.ObjectClass.SetConstant(&quot;C&quot;, Context.GetClass(typeof(ClassWithNonEmptyConstructor)));
-            var cls = Engine.Execute(@&quot;
-class D &lt; C; end
-D.new
-D
-&quot;);
-            var rubyClass = (cls as RubyClass);
-            Debug.Assert(rubyClass != null);
-
-            Type baseType = rubyClass.GetUnderlyingSystemType();
-            Assert(IsAvailable(baseType.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(RubyClass) }, null)));
-            Assert(IsAvailable(baseType.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(RubyClass), typeof(string) }, null)));
-#if !SILVERLIGHT
-            Assert(IsAvailable(baseType.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new[] {
-                typeof(SerializationInfo), typeof(StreamingContext) }, null)));
-#endif
+            Context.ObjectClass.SetConstant(&quot;C1&quot;, Context.GetClass(typeof(ClassWithNonEmptyConstructor)));
+
+            var cls1 = Engine.Execute&lt;RubyClass&gt;(&quot;class D1 &lt; C1; self; end&quot;);
+            Assert(IsCtorAvailable(cls1, typeof(RubyClass)));
+            Assert(IsCtorAvailable(cls1, typeof(BinaryOpStorage), typeof(RubyScope), typeof(RubyClass), typeof(string)));
+            Assert(IsCtorAvailable(cls1, typeof(RubyClass), typeof(int)));
+            Assert(IsCtorAvailable(cls1, typeof(RubyClass), typeof(RubyClass), typeof(RubyClass)));
+
+            Context.ObjectClass.SetConstant(&quot;C2&quot;, Context.GetClass(typeof(ClassWithNonEmptyConstructor2)));
+            var cls2 = Engine.Execute&lt;RubyClass&gt;(&quot;class D2 &lt; C2; self; end&quot;);
+            Assert(IsCtorAvailable(cls2, typeof(RubyClass)));
+            Assert(!IsCtorAvailable(cls2, typeof(RubyContext)));
+            Assert(!IsCtorAvailable(cls2));
+
+            Assert(Engine.Execute&lt;int&gt;(&quot;D2.new.p&quot;) == 1);
+
+            Context.ObjectClass.SetConstant(&quot;E1&quot;, Context.GetClass(typeof(ExceptionWithDefaultConstructor1)));
+            var ex1 = Engine.Execute&lt;RubyClass&gt;(&quot;class F1 &lt; E1; self; end&quot;);
+            Assert(IsCtorAvailable(ex1, typeof(RubyClass)));
+
+            Context.ObjectClass.SetConstant(&quot;E2&quot;, Context.GetClass(typeof(ExceptionWithStdConstructors1)));
+            var ex2 = Engine.Execute&lt;RubyClass&gt;(&quot;class F2 &lt; E2; self; end&quot;);
+            Assert(IsCtorAvailable(ex2, typeof(RubyClass)));
+            Assert(IsCtorAvailable(ex2, typeof(RubyClass), typeof(string)));
+
+            Assert(Engine.Execute&lt;int&gt;(&quot;F2.new.p&quot;) == 1);
         }
 
         public void ClrConstructor2() {
-            // TODO: Requires allocator support
-            Context.ObjectClass.SetConstant(&quot;C&quot;, Context.GetClass(typeof(ClassWithNonEmptyConstructor)));
+            Context.ObjectClass.SetConstant(&quot;DefaultAndParam&quot;, Context.GetClass(typeof(ClassWithNonEmptyConstructor)));
             AssertOutput(delegate() {
                 CompilerTest(@&quot;
-class D &lt; C; end
+class D &lt; DefaultAndParam; end
 
-$d = D.new 'test'
-puts $d.p
+d = D.new 123
+puts d.p
 &quot;);
             }, @&quot;
-test
+123
 &quot;);
         }
 
+        public class ClassWithDefaultAndParamConstructor {
+            public string P { get; set; }
+
+            public ClassWithDefaultAndParamConstructor() {
+            }
+
+            public ClassWithDefaultAndParamConstructor(string p) {
+                P = p;
+            }
+        }
+
+        public void ClrConstructor3() {
+            Context.ObjectClass.SetConstant(&quot;DefaultAndParam&quot;, Context.GetClass(typeof(ClassWithDefaultAndParamConstructor)));
+            Context.ObjectClass.SetConstant(&quot;NoDefault&quot;, Context.GetClass(typeof(ClassWithNoDefaultConstructor)));
+            AssertOutput(delegate() {
+                CompilerTest(@&quot;
+module I
+  def initialize(arg)
+    self.p = arg
+    puts 'init'
+  end
+end
+
+class D &lt; DefaultAndParam
+  include I
+end
+
+class E &lt; NoDefault
+  include I
+end
+
+class F &lt; NoDefault
+  def self.new(*args)
+    puts 'ctor'
+    super args.join(' ')
+  end
+end
+
+puts D.new('test').p
+E.new('test').p rescue p $!
+puts F.new('hello', 'world').p
+&quot;);
+            }, @&quot;
+init
+test
+#&lt;TypeError: can't allocate class `E' that derives from type `*::ClassWithNoDefaultConstructor' with no default constructor; define E#new singleton method instead of I#initialize&gt;
+ctor
+hello world
+&quot;, OutputFlags.Match);
+        }
+
         /// &lt;summary&gt;
         /// TODO: Currently we don't narrow results of arithmetic operations to the self-type even if the value fits.
         /// That might by just fine, but in some scenarios (overload resolution) it might be better to narrow the result type.</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ClrTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -132,9 +132,7 @@ Global
 		{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}.Release|Any CPU.Build.0 = Release|Any CPU
 		{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}.Silverlight Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}.Silverlight Debug|Any CPU.Build.0 = Debug|Any CPU
 		{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}.Silverlight Release|Any CPU.ActiveCfg = Release|Any CPU
-		{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}.Silverlight Release|Any CPU.Build.0 = Release|Any CPU
 		{77323B06-15A2-4CF4-8A7A-86EAA2B66498}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{77323B06-15A2-4CF4-8A7A-86EAA2B66498}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{77323B06-15A2-4CF4-8A7A-86EAA2B66498}.FxCop|Any CPU.ActiveCfg = Release|Any CPU</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby.sln</filename>
    </modified>
    <modified>
      <diff>@@ -1005,7 +1005,9 @@ namespace IronRuby.Builtins {
             argsBuilder.AddCallArguments(metaBuilder, args);
 
             if (!metaBuilder.Error) {
-                BuildAllocatorCall(metaBuilder, args, () =&gt; AstUtils.Constant(Name));
+                if (!BuildAllocatorCall(metaBuilder, args, () =&gt; AstUtils.Constant(Name))) {
+                    metaBuilder.SetError(Methods.MakeAllocatorUndefinedError.OpCall(Ast.Convert(args.TargetExpression, typeof(RubyClass))));
+                }
             }
         }
         
@@ -1033,36 +1035,44 @@ namespace IronRuby.Builtins {
                 Debug.Assert(initializer != null);
             }
 
-            // Ruby libraries: should initialize fully via factories/constructors.
-            // C# &quot;initialize&quot; methods: ignored - we don't consider them initializers.
-            RubyMethodInfo overriddenInitializer = initializer as RubyMethodInfo;
+            bool hasRubyInitializer = initializer is RubyMethodInfo;
+            bool hasLibraryInitializer = !hasRubyInitializer &amp;&amp; initializer.DeclaringModule != Context.ObjectClass;
 
-            // Initializer is overridden =&gt; initializer is invoked on an uninitialized instance.
-            // Is user class (defined in Ruby code) =&gt; construct it as if it had initializer that calls super immediately
-            // (we need to &quot;inherit&quot; factories/constructors from the base class (e.g. class S &lt; String; self; end.new('foo')).
-            if (overriddenInitializer != null || (_isRubyClass &amp;&amp; _structInfo == null)) {
-                BuildAllocatorCall(metaBuilder, args, () =&gt; AstUtils.Constant(Name));
+            if (hasRubyInitializer || hasLibraryInitializer &amp;&amp; _isRubyClass) {
+                // allocate and initialize:
+                bool allocatorFound = BuildAllocatorCall(metaBuilder, args, () =&gt; AstUtils.Constant(Name));
+                if (metaBuilder.Error) {
+                    return;
+                }
 
-                if (!metaBuilder.Error) {
-                    if (overriddenInitializer != null || (_isRubyClass &amp;&amp; initializer != null &amp;&amp; !initializer.IsEmpty)) {
-                        BuildOverriddenInitializerCall(metaBuilder, args, initializer);
-                    }
+                if (!allocatorFound) {
+                    metaBuilder.SetError(Methods.MakeMissingDefaultConstructorError.OpCall(
+                        Ast.Convert(args.TargetExpression, typeof(RubyClass)),
+                        Ast.Constant(initializer.DeclaringModule.Name)
+                    ));
+                    return;
+                }
+
+                if (!initializer.IsEmpty) {
+                    BuildOverriddenInitializerCall(metaBuilder, args, initializer);
                 }
-            } else if (typeof(Delegate).IsAssignableFrom(type)) {
-                BuildDelegateConstructorCall(metaBuilder, args, type);
             } else {
+                // construct:
                 MethodBase[] constructionOverloads;
                 SelfCallConvention callConvention;
 
-                if (_structInfo != null) {
+                if (typeof(Delegate).IsAssignableFrom(type)) {
+                    BuildDelegateConstructorCall(metaBuilder, args, type);
+                    return;
+                } else if (type.IsArray &amp;&amp; type.GetArrayRank() == 1) {
+                    constructionOverloads = ClrVectorFactories;
+                    callConvention = SelfCallConvention.SelfIsParameter;
+                } else if (_structInfo != null) {
                     constructionOverloads = new MethodBase[] { Methods.CreateStructInstance };
                     callConvention = SelfCallConvention.SelfIsParameter;
                 } else if (_factories.Length != 0) {
                     constructionOverloads = (MethodBase[])ReflectionUtils.GetMethodInfos(_factories);
                     callConvention = SelfCallConvention.SelfIsParameter;
-                } else if (type.IsArray &amp;&amp; type.GetArrayRank() == 1) {
-                    constructionOverloads = ClrVectorFactories;
-                    callConvention = SelfCallConvention.SelfIsParameter;
                 } else {
                     // TODO: handle protected constructors
                     constructionOverloads = type.GetConstructors();
@@ -1118,46 +1128,41 @@ namespace IronRuby.Builtins {
             }
         }
 
-        public void BuildAllocatorCall(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, Func&lt;Expression&gt;/*!*/ defaultExceptionMessage) {
+        public bool BuildAllocatorCall(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, Func&lt;Expression&gt;/*!*/ defaultExceptionMessage) {
             Type type = GetUnderlyingSystemType();
 
             if (_structInfo != null) {
                 metaBuilder.Result = Methods.AllocateStructInstance.OpCall(AstUtils.Convert(args.TargetExpression, typeof(RubyClass)));
-                return;
-            }
-
-            if (type.IsSubclassOf(typeof(Delegate))) {
-                BuildDelegateConstructorCall(metaBuilder, args, type);
-                return;
+                return true;
             }
 
             ConstructorInfo ctor;
             if (IsException()) {
                 if ((ctor = type.GetConstructor(new[] { typeof(string) })) != null) {
                     metaBuilder.Result = Ast.New(ctor, defaultExceptionMessage());
-                    return;
+                    return true;
                 } else if ((ctor = type.GetConstructor(new[] { typeof(string), typeof(Exception) })) != null) {
                     metaBuilder.Result = Ast.New(ctor, defaultExceptionMessage(), AstUtils.Constant(null));
-                    return;
+                    return true;
                 }
             }
 
             if ((ctor = type.GetConstructor(new[] { typeof(RubyClass) })) != null) {
                 metaBuilder.Result = Ast.New(ctor, AstUtils.Convert(args.TargetExpression, typeof(RubyClass)));
-                return;
+                return true;
             }
 
             if ((ctor = type.GetConstructor(new[] { typeof(RubyContext) })) != null) {
                 metaBuilder.Result = Ast.New(ctor, AstUtils.Convert(args.MetaContext.Expression, typeof(RubyContext)));
-                return;
+                return true;
             }
 
             if ((ctor = type.GetConstructor(Type.EmptyTypes)) != null) {
                 metaBuilder.Result = Ast.New(ctor);
-                return;
+                return true;
             }
 
-            metaBuilder.SetError(Methods.MakeAllocatorUndefinedError.OpCall(Ast.Convert(args.TargetExpression, typeof(RubyClass))));
+            return false;
         }
 
         private void BuildDelegateConstructorCall(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, Type/*!*/ type) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,8 @@ using Microsoft.Scripting.Runtime;
 using Microsoft.Scripting.Utils;
 using IronRuby.Builtins;
 using IronRuby.Runtime;
+using IronRuby.Runtime.Calls;
+using System.Diagnostics;
 
 namespace IronRuby.Compiler.Generation {
     internal class RubyTypeBuilder : IFeatureBuilder {
@@ -99,143 +101,185 @@ namespace IronRuby.Compiler.Generation {
 #endif
         private static readonly Type/*!*/[]/*!*/ _classArgSignature = new Type[] { typeof(RubyClass) };
 
-        private static bool IsAvailable(MethodBase method) {
+        private static readonly Type/*!*/[]/*!*/ _exceptionMessageSignature = new Type[] { typeof(string) };
+
+        private static bool IsAvailable(MethodBase/*!*/ method) {
             return method != null &amp;&amp; !method.IsPrivate &amp;&amp; !method.IsFamilyAndAssembly;
         }
 
+        private enum SignatureAdjustment {
+            // ordered by priority:
+            None = 0,
+            ConvertClassToContext = 1,
+            InsertClass = 2
+        }
+
+        private sealed class ConstructorBuilderInfo {
+            public ConstructorInfo BaseCtor;
+            public Type[] ParameterTypes;
+            public int ContextArgIndex;
+            public int ClassArgIndex;
+            public int ClassParamIndex;
+            public SignatureAdjustment Adjustment;
+        }
+
         private void DefineConstructors() {
             BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
-            ConstructorInfo defaultCtor = _tb.BaseType.GetConstructor(bindingFlags, null, Type.EmptyTypes, null);
+            ConstructorInfo defaultBaseCtor = _tb.BaseType.GetConstructor(bindingFlags, null, Type.EmptyTypes, null);
 
-            // constructor with a single parameter of type RubyClass:
-            ConstructorInfo defaultRubyCtor = null;
+            var ctors = new List&lt;ConstructorBuilderInfo&gt;();
 
-            bool deserializerFound = false;
             foreach (var baseCtor in _tb.BaseType.GetConstructors(bindingFlags)) {
                 if (!baseCtor.IsPublic &amp;&amp; !baseCtor.IsFamily) {
                     continue;
                 }
 
-                Type[] paramTypes;
                 ParameterInfo[] baseParams = baseCtor.GetParameters();
 
-                int additionalParamCount;
-                bool isDeserializer = false;
-                bool isDefaultRubyCtor = false;
-                if (baseParams.Length &gt; 0 &amp;&amp; baseParams[0].ParameterType == typeof(RubyClass)) {
-                    // Build a simple pass-through constructor
-                    paramTypes = ReflectionUtils.GetParameterTypes(baseParams);
-                    additionalParamCount = 0;
-                    isDefaultRubyCtor = true;
 #if !SILVERLIGHT
-                } else if (baseParams.Length == 2 &amp;&amp; 
+                if (baseParams.Length == 2 &amp;&amp;
                     baseParams[0].ParameterType == typeof(SerializationInfo) &amp;&amp; baseParams[1].ParameterType == typeof(StreamingContext)) {
-
-                    // Build a deserializer
-                    deserializerFound = true;
-                    isDeserializer = true;
-                    paramTypes = ReflectionUtils.GetParameterTypes(baseParams);
-                    additionalParamCount = 0;
+                    OverrideDeserializer(baseCtor);
+                    continue;
+                }
 #endif
-                } else {
-                    // Special-case for Exception
-                    if (_tb.IsSubclassOf(typeof(Exception)) &amp;&amp; IsAvailable(defaultCtor)) {
-                        if (baseParams.Length == 0) {
-                            // Skip this constructor; it would conflict with the one we're going to build next
-                            continue;
-                        } else if (baseParams.Length == 1 &amp;&amp; baseParams[0].ParameterType == typeof(string)) {
-                            // Special case exceptions to improve interop. Ruby's default message for an exception is the name of the exception class.
-                            BuildExceptionConstructor(baseCtor);
-                        }
-                    }
+                AddConstructor(ctors, MakeConstructor(baseCtor, baseParams));
+            }
 
-                    // Add RubyClass to the head of the parameter list
-                    paramTypes = new Type[baseParams.Length + 1];
-                    paramTypes[0] = typeof(RubyClass);
-                    for (int i = 0; i &lt; baseParams.Length; i++) {
-                        paramTypes[i + 1] = baseParams[i].ParameterType;
-                    }
+            BuildConstructors(ctors);
+        }
 
-                    additionalParamCount = 1;
-                    if (baseParams.Length == 0) {
-                        isDefaultRubyCtor = true;
-                    }
+        private static void AddConstructor(List&lt;ConstructorBuilderInfo&gt;/*!*/ ctors, ConstructorBuilderInfo/*!*/ ctor) {
+            int existing = ctors.FindIndex((c) =&gt; c.ParameterTypes.ValueEquals(ctor.ParameterTypes));
+            if (existing != -1) {
+                if (ctors[existing].Adjustment &gt; ctor.Adjustment) {
+                    ctors[existing] = ctor;
                 }
+            } else {
+                ctors.Add(ctor);
+            }
+        }
+
+        private ConstructorBuilderInfo/*!*/ MakeConstructor(ConstructorInfo/*!*/ baseCtor, ParameterInfo/*!*/[]/*!*/ baseParams) {
+            int contextArgIndex = -1;
+            int classArgIndex = -1;
+            for (int i = 0; i &lt; baseParams.Length; i++) {
+                if (baseParams[i].ParameterType == typeof(RubyContext)) {
+                    contextArgIndex = i;
+                    break;
+                } else if (baseParams[i].ParameterType == typeof(RubyClass)) {
+                    classArgIndex = i;
+                    break;
+                }
+            }
+
+            int classParamIndex;
+            SignatureAdjustment adjustment;
+            if (classArgIndex == -1) {
+                if (contextArgIndex == -1) {                    
+                    adjustment = SignatureAdjustment.InsertClass;
+                    classParamIndex = 0;
+                } else {
+                    adjustment = SignatureAdjustment.ConvertClassToContext;
+                    classParamIndex = contextArgIndex;
+                }
+            } else {
+                adjustment = SignatureAdjustment.None;
+                classParamIndex = classArgIndex;
+            }
+
+            Debug.Assert(classParamIndex &gt;= 0);
+
+            Type[] paramTypes = new Type[(adjustment == SignatureAdjustment.InsertClass ? 1 : 0) + baseParams.Length];
+            int paramIndex = 0, argIndex = 0;
+            if (adjustment == SignatureAdjustment.InsertClass) {
+                paramIndex++;
+            }
+
+            while (paramIndex &lt; paramTypes.Length) {
+                paramTypes[paramIndex++] = baseParams[argIndex++].ParameterType;
+            }
 
-                // Build a new constructor based on this base class ctor
-                ConstructorBuilder cb = _tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, paramTypes);
+            paramTypes[classParamIndex] = typeof(RubyClass);
+
+            return new ConstructorBuilderInfo() {
+                BaseCtor = baseCtor,
+                ParameterTypes = paramTypes,
+                ContextArgIndex = contextArgIndex,
+                ClassArgIndex = classArgIndex,
+                ClassParamIndex = classParamIndex,
+                Adjustment = adjustment,
+            };
+        }
+
+        private void BuildConstructors(IList&lt;ConstructorBuilderInfo&gt;/*!*/ ctors) {
+            foreach (var ctor in ctors) {
+                // ctor(... RubyClass! class ..., &lt;visible params&gt;) : base(&lt;hidden params&gt;, &lt;visible params&gt;) { _class = class; }
+                // ctor(... RubyClass! class ..., &lt;visible params&gt;) : base(... RubyOps.GetContextFromClass(class) ..., &lt;visible params&gt;) { _class = class; }
+                // ctor(RubyClass! class) : base(RubyOps.GetDefaultExceptionMessage(class)) { _class = class; }
+                ConstructorBuilder cb = _tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, ctor.ParameterTypes);
                 ILGen il = new ILGen(cb.GetILGenerator());
+
+                int paramIndex = 0;
+                int argIndex = 0;
+
+                // base ctor call:
                 il.EmitLoadArg(0);
-                for (int i = 1; i &lt; baseParams.Length + 1; i++) {
-                    il.EmitLoadArg(i + additionalParamCount);
-                }
-                il.Emit(OpCodes.Call, baseCtor);
 
-                if (!isDeserializer) {
-                    // ctor(RubyClass! class, {params}) : base({params}) { this._class = class; } 
-                    il.EmitLoadArg(0);
+                ConstructorInfo msgCtor;
+                if (ctor.ParameterTypes.Length == 1 &amp;&amp; ctor.Adjustment == SignatureAdjustment.InsertClass &amp;&amp;
+                    _tb.IsSubclassOf(typeof(Exception)) &amp;&amp; IsAvailable(msgCtor = _tb.BaseType.GetConstructor(_exceptionMessageSignature))) {
+
+                    // a parameterless exception constructor should use Ruby default message:
                     il.EmitLoadArg(1);
-                    il.EmitFieldSet(_classField);
+                    il.EmitCall(Methods.GetDefaultExceptionMessage);
+                    il.Emit(OpCodes.Call, msgCtor);
+                } else {
+                    if (ctor.Adjustment == SignatureAdjustment.InsertClass) {
+                        paramIndex++;
+                    }
 
-                    if (isDefaultRubyCtor) {
-                        defaultRubyCtor = cb;
+                    while (paramIndex &lt; ctor.ParameterTypes.Length) {
+                        if (ctor.Adjustment == SignatureAdjustment.ConvertClassToContext &amp;&amp; argIndex == ctor.ContextArgIndex) {
+                            il.EmitLoadArg(1 + ctor.ClassParamIndex);
+                            il.EmitCall(Methods.GetContextFromModule);
+                        } else {
+                            il.EmitLoadArg(1 + paramIndex);
+                        }
+                        argIndex++;
+                        paramIndex++;
                     }
-                } else {
-                    // ctor(SerializationInfo! info, StreamingContext! context) : base(info, context) {
-                    //   RubyOps.DeserializeObject(out this._instanceData, out this._class, info);
-                    // }
-                    il.EmitLoadArg(0);
-                    il.EmitFieldAddress(_instanceDataField);
-                    il.EmitLoadArg(0);
-                    il.EmitFieldAddress(_classField);
-                    il.EmitLoadArg(1);
-                    il.EmitCall(typeof(RubyOps).GetMethod(&quot;DeserializeObject&quot;));
+                    il.Emit(OpCodes.Call, ctor.BaseCtor);
                 }
+
+                // _class = class:
+                il.EmitLoadArg(0);
+                il.EmitLoadArg(1 + ctor.ClassParamIndex);
+                il.EmitFieldSet(_classField);
                 il.Emit(OpCodes.Ret);
             }
-#if !SILVERLIGHT
-            if (defaultRubyCtor != null &amp;&amp; !deserializerFound) {
-                // We didn't previously find a deserialization constructor.  If we can, build one now.
-                BuildDeserializationConstructor(defaultRubyCtor);
-            }
-#endif
-        }
-
-        private void BuildExceptionConstructor(ConstructorInfo baseCtor) {
-            // ctor(RubyClass! class) : base(RubyOps.GetDefaultExceptionMessage(class)) {
-            //   this._class = class;
-            // }
-            ConstructorBuilder ctor = _tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, _classArgSignature);
-            ILGen il = new ILGen(ctor.GetILGenerator());
-            il.EmitLoadArg(0);
-            il.EmitLoadArg(1);
-            il.Emit(OpCodes.Call, Methods.GetDefaultExceptionMessage);
-            il.Emit(OpCodes.Call, baseCtor);
-            il.EmitLoadArg(0);
-            il.EmitLoadArg(1);
-            il.EmitFieldSet(_classField);
-            il.Emit(OpCodes.Ret);
         }
 
 #if !SILVERLIGHT
-        private void BuildDeserializationConstructor(ConstructorInfo thisCtor) {
-            // ctor(SerializationInfo! info, StreamingContext! context) : this((RubyClass)context.Context) {
+        private void OverrideDeserializer(ConstructorInfo/*!*/ baseCtor) {
+            // ctor(SerializationInfo! info, StreamingContext! context) : base(info, context) {
             //   RubyOps.DeserializeObject(out this._instanceData, out this._class, info);
             // }
-            ConstructorBuilder ctor = _tb.DefineConstructor(MethodAttributes.Family, CallingConventions.Standard, _deserializerSignature);
-            ILGen il = new ILGen(ctor.GetILGenerator());
+
+            ConstructorBuilder cb = _tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, _deserializerSignature);
+            ILGen il = new ILGen(cb.GetILGenerator());
+
             il.EmitLoadArg(0);
-            il.EmitLoadArgAddress(2);
-            il.EmitCall(typeof(StreamingContext).GetProperty(&quot;Context&quot;).GetGetMethod());
-            il.Emit(OpCodes.Castclass, typeof(RubyClass));
-            il.Emit(OpCodes.Call, thisCtor);
+            il.EmitLoadArg(1);
+            il.EmitLoadArg(2);
+            il.Emit(OpCodes.Call, baseCtor);
 
             il.EmitLoadArg(0);
             il.EmitFieldAddress(_instanceDataField);
             il.EmitLoadArg(0);
             il.EmitFieldAddress(_classField);
             il.EmitLoadArg(1);
-            il.EmitCall(typeof(RubyOps).GetMethod(&quot;DeserializeObject&quot;));
+            il.EmitCall(Methods.DeserializeObject);
             il.Emit(OpCodes.Ret);
         }
 #endif</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeBuilder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -304,6 +304,8 @@ namespace IronRuby.Compiler {
         private static MethodInfo _MakeHash0;
         public static MethodInfo/*!*/ MakeInvalidArgumentTypesError { get { return _MakeInvalidArgumentTypesError ?? (_MakeInvalidArgumentTypesError = GetMethod(typeof(RubyOps), &quot;MakeInvalidArgumentTypesError&quot;)); } }
         private static MethodInfo _MakeInvalidArgumentTypesError;
+        public static MethodInfo/*!*/ MakeMissingDefaultConstructorError { get { return _MakeMissingDefaultConstructorError ?? (_MakeMissingDefaultConstructorError = GetMethod(typeof(RubyOps), &quot;MakeMissingDefaultConstructorError&quot;)); } }
+        private static MethodInfo _MakeMissingDefaultConstructorError;
         public static MethodInfo/*!*/ MakeMissingSuperException { get { return _MakeMissingSuperException ?? (_MakeMissingSuperException = GetMethod(typeof(RubyOps), &quot;MakeMissingSuperException&quot;)); } }
         private static MethodInfo _MakeMissingSuperException;
         public static MethodInfo/*!*/ MakePrivateMethodCalledError { get { return _MakePrivateMethodCalledError ?? (_MakePrivateMethodCalledError = GetMethod(typeof(RubyOps), &quot;MakePrivateMethodCalledError&quot;)); } }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/ReflectionCache.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -81,11 +81,7 @@ namespace IronRuby.Runtime.Calls {
             bool hasOptional = false;
             foreach (MethodBase method in MethodBases) {
                 int mandatory, optional;
-                bool acceptsBlock;
-                RubyOverloadResolver.GetParameterCount(method.GetParameters(), out mandatory, out optional, out acceptsBlock);
-                if (mandatory &gt; 0) {
-                    mandatory--; // account for &quot;self&quot;
-                }
+                RubyOverloadResolver.GetParameterCount(method, method.GetParameters(), CallConvention, out mandatory, out optional);
                 if (mandatory &lt; minParameters) {
                     minParameters = mandatory;
                 }
@@ -143,13 +139,10 @@ namespace IronRuby.Runtime.Calls {
             return Copy(boundMethods.ToArray());
         }
 
-        private static bool IsOverloadSignature(MethodBase/*!*/ method, Type/*!*/[]/*!*/ parameterTypes) {
+        private bool IsOverloadSignature(MethodBase/*!*/ method, Type/*!*/[]/*!*/ parameterTypes) {
             var infos = method.GetParameters();
-            int firstInfo = 0;
-            while (firstInfo &lt; infos.Length &amp;&amp; RubyOverloadResolver.IsHiddenParameter(infos[firstInfo])) {
-                firstInfo++;
-            }
-
+            int firstInfo = RubyOverloadResolver.GetHiddenParameterCount(method, infos, CallConvention);
+            
             if (infos.Length - firstInfo != parameterTypes.Length) {
                 return false;
             }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupBase.cs</filename>
    </modified>
    <modified>
      <diff>@@ -104,6 +104,9 @@ namespace IronRuby.Runtime.Calls {
                 } else if (info.ParameterType == typeof(RubyContext)) {
                     mapping.AddBuilder(new RubyContextArgBuilder(info));
                     special[i++] = true;
+                } else if (method.IsConstructor &amp;&amp; info.ParameterType == typeof(RubyClass)) {
+                    mapping.AddBuilder(new RubyClassCtorArgBuilder(info));
+                    special[i++] = true;
                 }
             }
 
@@ -148,23 +151,61 @@ namespace IronRuby.Runtime.Calls {
             return special;
         }
 
-        internal static void GetParameterCount(ParameterInfo/*!*/[]/*!*/ parameterInfos, out int mandatory, out int optional, out bool acceptsBlock) {
-            acceptsBlock = false;
+        internal static int GetHiddenParameterCount(MethodBase/*!*/ method, ParameterInfo/*!*/[]/*!*/ infos, SelfCallConvention callConvention) {
+            int i = 0;
+
+            if (callConvention == SelfCallConvention.SelfIsInstance) {
+                if (CompilerHelpers.IsStatic(method)) {
+                    Debug.Assert(RubyClass.IsOperator(method) || CompilerHelpers.IsExtension(method));
+                    i++;
+                }
+            }
+
+            while (i &lt; infos.Length &amp;&amp; infos[i].ParameterType.IsSubclassOf(typeof(RubyCallSiteStorage))) {
+                i++;
+            }
+
+            if (i &lt; infos.Length) {
+                var info = infos[i];
+
+                if (info.ParameterType == typeof(RubyScope)) {
+                    i++;
+                } else if (info.ParameterType == typeof(RubyContext)) {
+                    i++;
+                } else if (method.IsConstructor &amp;&amp; info.ParameterType == typeof(RubyClass)) {
+                    i++;
+                }
+            }
+
+            if (i &lt; infos.Length &amp;&amp; infos[i].ParameterType == typeof(BlockParam)) {
+                i++;
+            }
+
+            if (callConvention == SelfCallConvention.SelfIsParameter) {
+                Debug.Assert(i &lt; infos.Length);
+                Debug.Assert(CompilerHelpers.IsStatic(method));
+                i++;
+            }
+
+            return i;
+        }
+
+        internal static void GetParameterCount(MethodBase/*!*/ method, ParameterInfo/*!*/[]/*!*/ parameterInfos, SelfCallConvention callConvention, 
+            out int mandatory, out int optional) {
+
             mandatory = 0;
             optional = 0;
-            foreach (ParameterInfo parameterInfo in parameterInfos) {
-                if (IsHiddenParameter(parameterInfo)) {
-                    continue;
-                } else if (parameterInfo.ParameterType == typeof(BlockParam)) {
-                    acceptsBlock = true;
-                } else if (CompilerHelpers.IsParamArray(parameterInfo)) {
+            for (int i = GetHiddenParameterCount(method, parameterInfos, callConvention); i &lt; parameterInfos.Length; i++) {
+                var info = parameterInfos[i];
+
+                if (CompilerHelpers.IsParamArray(info)) {
                     // TODO: indicate splat args separately?
                     optional++;
-                } else if (CompilerHelpers.IsOutParameter(parameterInfo)) {
+                } else if (CompilerHelpers.IsOutParameter(info)) {
                     // Python allows passing of optional &quot;clr.Reference&quot; to capture out parameters
                     // Ruby should allow similar
                     optional++;
-                } else if (CompilerHelpers.IsMandatoryParameter(parameterInfo)) {
+                } else if (CompilerHelpers.IsMandatoryParameter(info)) {
                     mandatory++;
                 } else {
                     optional++;
@@ -172,12 +213,6 @@ namespace IronRuby.Runtime.Calls {
             }
         }
 
-        internal static bool IsHiddenParameter(ParameterInfo/*!*/ parameterInfo) {
-            return parameterInfo.ParameterType == typeof(RubyScope)
-                || parameterInfo.ParameterType == typeof(RubyContext)
-                || parameterInfo.ParameterType.IsSubclassOf(typeof(RubyCallSiteStorage));
-        }
-
         #endregion
 
         #region Step 2: Actual Arguments
@@ -508,6 +543,24 @@ namespace IronRuby.Runtime.Calls {
             }
         }
 
+        internal sealed class RubyClassCtorArgBuilder : ArgBuilder {
+            public RubyClassCtorArgBuilder(ParameterInfo/*!*/ info)
+                : base(info) {
+            }
+
+            public override int Priority {
+                get { return -1; }
+            }
+
+            public override int ConsumedArgumentCount {
+                get { return 0; }
+            }
+
+            protected override Expression ToExpression(OverloadResolver/*!*/ resolver, IList&lt;Expression&gt;/*!*/ parameters, bool[]/*!*/ hasBeenUsed) {
+                return ((RubyOverloadResolver)resolver)._args.TargetExpression;
+            }
+        }
+
         internal sealed class MissingBlockArgBuilder : SimpleArgBuilder {
             public MissingBlockArgBuilder(int index)
                 : base(typeof(MissingBlockParam), index, false, false) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyOverloadResolver.cs</filename>
    </modified>
    <modified>
      <diff>@@ -30,6 +30,7 @@ using IronRuby.Compiler;
 using IronRuby.Runtime.Calls;
 using System.Runtime.CompilerServices;
 using Microsoft.Scripting.Interpreter;
+using Microsoft.Scripting.Generation;
 
 namespace IronRuby.Runtime {
     /// &lt;summary&gt;
@@ -263,11 +264,13 @@ namespace IronRuby.Runtime {
         }
 
         private const string RubyMethodPrefix = &quot;\u2111\u211c;&quot;;
+        private static int _Id = 0;
 
         internal static string/*!*/ EncodeMethodName(SourceUnit/*!*/ sourceUnit, string/*!*/ methodName, SourceSpan location) {
             // encodes line number, file name into the method name
             string fileName = sourceUnit.HasPath ? Path.GetFileName(sourceUnit.Path) : String.Empty;
-            return String.Format(RubyMethodPrefix + &quot;{0};{1};{2};&quot;, methodName, fileName, location.IsValid ? location.Start.Line : 0);
+            return String.Format(RubyMethodPrefix + &quot;{0};{1};{2};{3}&quot;, methodName, fileName, location.IsValid ? location.Start.Line : 0,
+                Interlocked.Increment(ref _Id));
         }
 
         // \u2111\u211c;{method-name};{file-name};{line-number};{dlr-suffix}</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,7 @@ using System.Runtime.InteropServices;
 using System.Net.Sockets;
 using System.Runtime.CompilerServices;
 using IronRuby.Runtime.Calls;
+using System.Diagnostics;
 
 namespace IronRuby.Runtime {
     /// &lt;summary&gt;
@@ -64,6 +65,18 @@ namespace IronRuby.Runtime {
             return CreateTypeError(String.Format(&quot;allocator undefined for {0}&quot;, rubyClass.Name));
         }
 
+        public static Exception/*!*/ CreateMissingDefaultConstructorError(RubyClass/*!*/ rubyClass, string/*!*/ initializerOwnerName) {
+            Debug.Assert(rubyClass.IsRubyClass);
+
+            Type baseType = rubyClass.GetUnderlyingSystemType().BaseType;
+            Debug.Assert(baseType != null);
+
+            return CreateTypeError(String.Format(&quot;can't allocate class `{1}' that derives from type `{0}' with no default constructor;&quot; +
+                &quot; define {1}#new singleton method instead of {2}#initialize&quot;,
+                rubyClass.Context.GetTypeName(baseType), rubyClass.Name, initializerOwnerName
+            ));
+        }
+
         public static Exception/*!*/ CreateArgumentError(string/*!*/ message) {
             return new ArgumentException(message);
         }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptions.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1304,6 +1304,11 @@ namespace IronRuby.Runtime {
         }
 
         [Emitted]
+        public static Exception/*!*/ MakeMissingDefaultConstructorError(RubyClass/*!*/ classObj, string/*!*/ initializerOwnerName) {
+            return RubyExceptions.CreateMissingDefaultConstructorError(classObj, initializerOwnerName);
+        }
+
+        [Emitted]
         public static Exception/*!*/ MakePrivateMethodCalledError(RubyContext/*!*/ context, object target, string/*!*/ methodName) {
             return RubyExceptions.CreatePrivateMethodCalled(context, target, methodName);
         }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -182,7 +182,7 @@ namespace Microsoft.Scripting.Actions {
             );
         }
 
-        protected TrackerTypes GetMemberType(MemberGroup members, out Expression error) {
+        public TrackerTypes GetMemberType(MemberGroup members, out Expression error) {
             error = null;
             TrackerTypes memberType = TrackerTypes.All;
             for (int i = 0; i &lt; members.Count; i++) {
@@ -198,7 +198,7 @@ namespace Microsoft.Scripting.Actions {
             return memberType;
         }
 
-        internal MethodInfo GetMethod(Type type, string name) {
+        public MethodInfo GetMethod(Type type, string name) {
             // declaring type takes precedence
             MethodInfo mi = type.GetMethod(name);
             if (mi != null) {</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Actions/DefaultBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -309,5 +309,19 @@ namespace Microsoft.Scripting.Utils {
             }
             return res;
         }
+
+        public static bool ValueEquals&lt;T&gt;(this T[] array, T[] other) {
+            if (other.Length != array.Length) {
+                return false;
+            }
+
+            for (int i = 0; i &lt; array.Length; i++) {
+                if (!array[i].Equals(other[i])) {
+                    return false;
+                }
+            }
+
+            return true;
+        }
     }
 }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Utils/ArrayUtils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -157,5 +157,17 @@ namespace Microsoft.Scripting.Utils {
                 }
             }
         }
+
+        public static int FindIndex&lt;T&gt;(this IList&lt;T&gt; collection, Predicate&lt;T&gt; predicate) {
+            ContractUtils.RequiresNotNull(collection, &quot;collection&quot;);
+            ContractUtils.RequiresNotNull(predicate, &quot;predicate&quot;);
+
+            for (int i = 0; i &lt; collection.Count; i++) {
+                if (predicate(collection[i])) {
+                    return i;
+                }
+            }
+            return -1;
+        }
     }
 }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Utils/CollectionUtils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -35,18 +35,7 @@ namespace Microsoft.Scripting.Utils {
         [StateIndependent]
         public bool Equals(ValueArray&lt;T&gt; other) {
             if (other == null) return false;
-
-            if (other._array.Length != _array.Length) {
-                return false;
-            }
-
-            for (int i = 0; i &lt; _array.Length; i++) {
-                if (!_array[i].Equals(other._array[i])) {
-                    return false;
-                }
-            }
-
-            return true;
+            return _array.ValueEquals(other._array);
         }
 
         #endregion</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Utils/ValueArray.cs</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/ReflectedPackageOps.cs</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>ca434900d8286818333b24865a98dc18fff25224</id>
    </parent>
  </parents>
  <author>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </author>
  <url>http://github.com/ironruby/ironruby/commit/66f3e5e68d76f6819478b24b012faa8a1cae0d20</url>
  <id>66f3e5e68d76f6819478b24b012faa8a1cae0d20</id>
  <committed-date>2009-05-13T11:50:49-07:00</committed-date>
  <authored-date>2009-05-13T11:50:49-07:00</authored-date>
  <message>syncing to head of tfs</message>
  <tree>fa5aaf701519c812e33eeee2905f8cff95ed259f</tree>
  <committer>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </committer>
</commit>
