Merge branch 'contrib/TekuConcept'

* contrib/TekuConcept:
  Dev Checkpoint 201908200213
  Dev Checkpoint 201906261312
  Dev Checkpoint 201906252227
  Dev Checkpoint 201906252221
  Dev Checkpoint 201906252210
  Dev Checkpoint 201906252113
  Add JS Native Directive Testcase
  JS Example Campatibility Update
  Add Native Directive Example
  Update JavaScript Documentation
  Add JS Native Wrapper API
diff --git a/.travis.yml b/.travis.yml
index bede4a0..c9cbd78 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -43,6 +43,10 @@
       env: SWIGLANG= GCC=8
       sudo: required
       dist: xenial
+    - os: linux
+      env: SWIGLANG= GCC=9
+      sudo: required
+      dist: xenial
     - compiler: gcc
       os: linux
       env: SWIGLANG=csharp
@@ -140,16 +144,6 @@
       dist: xenial
     - compiler: gcc
       os: linux
-      env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.2 CPP11=1
-      sudo: required
-      dist: trusty
-    - compiler: gcc
-      os: linux
-      env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1
-      sudo: required
-      dist: trusty
-    - compiler: gcc
-      os: linux
       env: SWIGLANG=perl5
       sudo: required
       dist: xenial
@@ -268,19 +262,44 @@
       dist: xenial
     - compiler: gcc
       os: linux
-      env: SWIGLANG=ruby VER=1.9.3
+      env: SWIGLANG=ruby VER=1.9
       sudo: required
       dist: xenial
     - compiler: gcc
       os: linux
-      env: SWIGLANG=ruby VER=2.0.0
+      env: SWIGLANG=ruby VER=2.0
       sudo: required
       dist: xenial
     - compiler: gcc
       os: linux
-      env: SWIGLANG=ruby VER=2.3.0
+      env: SWIGLANG=ruby VER=2.1
       sudo: required
-      dist: trusty
+      dist: xenial
+    - compiler: gcc
+      os: linux
+      env: SWIGLANG=ruby VER=2.2
+      sudo: required
+      dist: xenial
+    - compiler: gcc
+      os: linux
+      env: SWIGLANG=ruby VER=2.3
+      sudo: required
+      dist: xenial
+    - compiler: gcc
+      os: linux
+      env: SWIGLANG=ruby VER=2.4
+      sudo: required
+      dist: xenial
+    - compiler: gcc
+      os: linux
+      env: SWIGLANG=ruby VER=2.5
+      sudo: required
+      dist: xenial
+    - compiler: gcc
+      os: linux
+      env: SWIGLANG=ruby VER=2.6
+      sudo: required
+      dist: xenial
     - compiler: gcc
       os: linux
       env: SWIGLANG=scilab
@@ -298,11 +317,16 @@
     - os: linux
       env: SWIGLANG=go VER=1.6 CPP11=1
       sudo: required
-      dist: trusty
+      dist: xenial
     - os: linux
       env: SWIGLANG=java CPP11=1
       sudo: required
       dist: xenial
+    - compiler: gcc
+      os: linux
+      env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1
+      sudo: required
+      dist: trusty
     - os: linux
       env: SWIGLANG=python CPP11=1
       sudo: required
@@ -324,9 +348,9 @@
       sudo: required
       dist: xenial
     - os: linux
-      env: SWIGLANG=go GCC=6 CPP14=1
+      env: SWIGLANG=go VER=1.6 GCC=6 CPP14=1
       sudo: required
-      dist: trusty
+      dist: xenial
     - os: linux
       env: SWIGLANG=java GCC=6 CPP14=1
       sudo: required
@@ -363,6 +387,18 @@
       env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.7
       sudo: required
       dist: xenial
+    - os: linux
+      env: SWIGLANG=csharp GCC=9 CPP17=1
+      sudo: required
+      dist: xenial
+    - os: linux
+      env: SWIGLANG=java GCC=9 CPP17=1
+      sudo: required
+      dist: xenial
+    - os: linux
+      env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.7
+      sudo: required
+      dist: xenial
     - compiler: gcc
       os: osx
       env: SWIGLANG=
@@ -386,6 +422,9 @@
       env: SWIGLANG=lua
     - compiler: clang
       os: osx
+      env: SWIGLANG=octave SWIGJOBS=-j2
+    - compiler: clang
+      os: osx
       env: SWIGLANG=perl5
     - compiler: clang
       os: osx
@@ -399,6 +438,14 @@
     - compiler: clang
       os: osx
       env: SWIGLANG=tcl
+    - compiler: clang
+      os: osx
+      env: SWIGLANG=java CPP17=1
+      osx_image: xcode10.2
+    - compiler: clang
+      os: osx
+      env: SWIGLANG=python PY3=3 CPP17=1
+      osx_image: xcode10.2
 
   allow_failures:
     # seg fault in director_basic testcase
@@ -408,11 +455,9 @@
       sudo: required
       dist: xenial
     # Sometimes hits the Travis 50 minute time limit
-    - compiler: gcc
-      os: linux
-      env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1
-      sudo: required
-      dist: trusty
+    - compiler: clang
+      os: osx
+      env: SWIGLANG=octave SWIGJOBS=-j2
     # Experimental languages
     - compiler: gcc
       os: linux
diff --git a/CHANGES b/CHANGES
index 77d570d..7fd6b6d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -939,8 +939,8 @@
             returning pointers by reference.
 
 2017-12-08: olly
-	    [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals - this
-	    should make the generated code work with PHP 7.2.0.
+	    [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals so the
+	    generated code builds when PHP was built with ZTS enabled.
 
 2017-12-04: wsfulton
             [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a
diff --git a/CHANGES.current b/CHANGES.current
index 06373db..6ae17df 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,3 +7,136 @@
 Version 4.0.1 (in progress)
 ===========================
 
+2019-08-20: bkotzz
+            [Java] #1616 Add SWIG_JavaIllegalStateException to support throwing
+            java.lang.IllegalStateException from JNI code.
+
+2019-08-19: sjml
+            [Lua] #1596 tostring output changes to show the underlying C/C++ pointer.
+
+2019-08-08: rokups
+            [C#, Java] #1601 Fix invalid code generated for "%constant enum EnumType.
+
+2019-08-07: wsfulton
+            [Python] Fix method overloading of methods that take STL containers of different
+            types. The following usage (using std::vector) would fail when using -builtin:
+
+              %include <std_string.i>
+              %include <std_vector.i>
+
+              %inline %{
+              struct X {};
+              %}
+
+              %template(VectorX) std::vector<X>;
+              %template(VectorInt) std::vector<int>;
+
+              %inline %{
+              using namespace std;
+              string VectorOverload(vector<X> v);
+              string VectorOverload(vector<int> v);
+              %}
+
+            The following would incorrectly fail:
+
+              s = VectorOverload([1, 2, 3])
+
+            With:
+
+              Traceback (most recent call last):
+                File "runme3.py", line 20, in <module>
+                  ret = VectorOverload([1, 2, 3])
+              TypeError: Wrong number or type of arguments for overloaded function 'VectorOverload'.
+                Possible C/C++ prototypes are:
+                  VectorOverload(std::vector< Number,std::allocator< Number > >)
+                  VectorOverload(std::vector< int,std::allocator< int > >)
+
+            The problem was due to some error handling that was not cleared during typehecking.
+            In this case an error was not cleared when the elements in the list failed the
+            typecheck for converting to X. Only occurs in Python 3+.
+
+            In some combinations of overloaded methods, the following type of error message would
+            occur:
+
+              RuntimeError: in sequence element 0
+
+              The above exception was the direct cause of the following exception:
+
+              Traceback (most recent call last):
+                File "runme3.py", line 23, in <module>
+                  check(VectorOverload(v), "vector<X>")
+              SystemError: <built-in function VectorOverload> returned a result with an error set
+
+2019-08-01: wsfulton
+            #1602 Fix regression in 4.0.0 where a template function containing a parameter
+            with the same name as the function name led to the parameter name used in the
+            target language being incorrectly modified.
+
+2019-07-29: wsfulton
+            Remove all generated files on error. Previously generated files were not removed,
+            potentially breaking Makefiles using file dependencies, especially when -Werror
+            (warnings as errors) was used.
+
+2019-07-23: smithx
+            [C#] #1530 #1532 Fix marshalling of std::wstring to C#.
+
+2019-07-18: gicmo
+            [Python] #1587 Python 3.8 support - remove use of deprecated PyObject_GC_UnTrack.
+
+2019-07-18: cher-nov
+            [Python] #1573 Generated Python code uses consistent string quoting style - double
+            quotes.
+
+2019-07-16: geefr
+            [C#] #616 #1576 Fix C# bool INPUT[], bool OUTPUT[], bool INOUT[] typemaps to marshall
+            as 1-byte.
+
+2019-07-12: vadz
+            [C#, Java] #1568 #1583 Fix std::set<> typemaps for primitive types.
+
+2019-07-12: vadz
+            #1566 #1584 Regression in 4.0.0 - fix missing value for first item of enums with
+            trailing comma.
+
+2019-07-11: mcfarljm
+            #1548 #1578 Fix segfault in Doxygen parser parsing empty lines in some commands like
+            \code.
+
+2019-07-09: IsaacPascual
+            [C#, Java] #1570 Fix name of generated C#/Java classes for %interface macros
+            in swiginterface.i when wrapping nested C++ classes.
+
+2019-07-05: wsfulton
+            [Python] #1547 Whitespace fixes in Doxygen translated comments into pydoc comments
+            for Sphinx compatibility.
+
+2019-06-28: wsfulton
+            [MzScheme, OCaml] #1559 $arg and $input were incorrectly substituted in the
+            argout typemap when two or more arguments were present.
+
+2019-06-24: wsfulton
+            [Python, Ruby] #1538 Remove the UnknownExceptionHandler class in order to be
+            C++17 compliant as it uses std::unexpected_handler which was removed in C++17.
+            This class was intended for director exception handling but was never used by
+            SWIG and was never documented.
+
+            *** POTENTIAL INCOMPATIBILITY ***
+
+2019-06-06: bkotzz
+            [Java] #1552 Improve performance in Java std::vector constructor wrapper that takes
+            a native Java array as input.
+
+2019-06-03: olly
+	    [Python] Fix regression in implicit_conv handling of tuples,
+	    introduced in SWIG 4.0.0.  Fixes #1553, reported by Alexandre
+	    Duret-Lutz.
+
+2019-05-24: wsfulton
+            [Octave] Fix detection of Octave on MacOS.
+
+2019-05-24: opoplawski
+            [Octave] #1522 Adapt OCTAVE_LDFLAGS for Octave 5.1.
+
+2019-05-22: ferdynator
+	    [PHP] #1528 Don't add a closing '?>' PHP tag to generated files.
+	    PSR-2 says it MUST be omitted for files containing only PHP.
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index b013283..5a640fb 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -3031,7 +3031,7 @@
   /* Close the function(error) */
   Printv(wrapper-&gt;code, "return ERROR;\n", "}\n", NIL);
 
-  /* final substititions if applicable */
+  /* final substitutions if applicable */
   ...
 
   /* Dump the function out */
diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html
index cfa56db..c28cc03 100644
--- a/Doc/Manual/Go.html
+++ b/Doc/Manual/Go.html
@@ -607,7 +607,7 @@
 
 <p>
 In order to use C++ templates in Go, you must tell SWIG to create
-wrappers for a particular template instantation.  To do this, use
+wrappers for a particular template instantiation.  To do this, use
 the <tt>%template</tt> directive.
 
 
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index eeb2e5a..5608592 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -1581,8 +1581,8 @@
 }
 
 void halve_in_place(std::vector&lt;double&gt;&amp; v) {
-  std::transform(v.begin(), v.end(), v.begin(),
-                 std::bind2nd(std::divides&lt;double&gt;(), 2.0));
+  for (std::vector&lt;double&gt;::iterator it = v.begin(); it != v.end(); ++it)
+    *it /= 2.0;
 }
 </pre>
 </div>
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index d80731c..d0ec0df 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -231,10 +231,12 @@
 <p>
 There's one peculiarity of how constants work in PHP which it is useful
 to note (this is not specific to SWIG though) - if you try to use an undeclared
-constant, PHP will emit a notice and then expand the constant to a string
-version of the constant's name.  Unfortunately it is easy to miss the notice
-if you're using PHP in a webserver, as it will probably end up in error.log or
-similar.
+constant, PHP will emit a warning (or a notice in PHP 7.1 and earlier) and then
+expand the constant to a string version of the constant's name.  Unfortunately
+it is easy to miss the warning message if you're using PHP in a webserver as
+it will probably end up in error.log or similar.  Apparently this will throw
+an Error in a future version of PHP, but until then it's something to be
+aware of.
 </p>
 
 <p>
@@ -268,8 +270,7 @@
 <p>
 The mis-spelled constant will become the string 'EASY_TO_MISPEL', which
 is treated as true by the if test, when the value of the intended constant
-would be treated as false!  Modern versions of PHP will at least issue
-a PHP notice by default when this happens.
+would be treated as false!
 </p>
 
 <H3><a name="Php_nn2_2">31.2.2 Global Variables</a></H3>
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 5a3947d..ee443be 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -4002,7 +4002,7 @@
 
 <p>
 The class defines each method in two different ways. The first definition is replaced by the second definition and so the second definition is the one used when the method is called.
-While this possibly provides the best of both worlds, the time to import the module will be slighly slower when the class is defined due to the additional method definitions.
+While this possibly provides the best of both worlds, the time to import the module will be slightly slower when the class is defined due to the additional method definitions.
 </p>
 
 <p>
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index aa42126..3cfd129 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -152,7 +152,7 @@
 <H2><a name="Ruby_nn2">34.1 Preliminaries</a></H2>
 
 
-<p> SWIG 3.0 is known to work with Ruby versions 1.8 and later.
+<p> SWIG 4.0 is known to work with Ruby versions 1.9 and later.
 Given the choice, you should use the latest stable version of Ruby. You
 should also determine if your system supports shared libraries and
 dynamic loading. SWIG will work with or without dynamic loading, but
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index d1492d3..aec48ef 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -3438,6 +3438,18 @@
 %}
 </pre></div>
 
+<p>
+Please note that some language backends (e.g. C# or Java) don't have any
+initialization function, hence you should define a global object performing
+the necessary initialization for them instead:
+</p>
+
+<div class="code"><pre>
+%init %{
+  static struct MyInit { MyInit() { init_variables(); } } myInit;
+%}
+</pre></div>
+
 <H2><a name="SWIG_nn45">5.7 An Interface Building Strategy</a></H2>
 
 
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index 8a31dbf..0bacd39 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -4630,37 +4630,69 @@
 <pre>
 Symbolic Name                   Precedence Value
 ------------------------------  ------------------
-SWIG_TYPECHECK_POINTER           0  
-SWIG_TYPECHECK_VOIDPTR           10 
-SWIG_TYPECHECK_BOOL              15 
-SWIG_TYPECHECK_UINT8             20 
-SWIG_TYPECHECK_INT8              25 
-SWIG_TYPECHECK_UINT16            30 
-SWIG_TYPECHECK_INT16             35 
-SWIG_TYPECHECK_UINT32            40 
-SWIG_TYPECHECK_INT32             45 
-SWIG_TYPECHECK_UINT64            50 
-SWIG_TYPECHECK_INT64             55 
-SWIG_TYPECHECK_UINT128           60 
-SWIG_TYPECHECK_INT128            65 
-SWIG_TYPECHECK_INTEGER           70 
-SWIG_TYPECHECK_FLOAT             80 
-SWIG_TYPECHECK_DOUBLE            90 
-SWIG_TYPECHECK_COMPLEX           100 
-SWIG_TYPECHECK_UNICHAR           110 
-SWIG_TYPECHECK_UNISTRING         120 
-SWIG_TYPECHECK_CHAR              130 
-SWIG_TYPECHECK_STRING            140 
-SWIG_TYPECHECK_BOOL_ARRAY        1015 
-SWIG_TYPECHECK_INT8_ARRAY        1025 
-SWIG_TYPECHECK_INT16_ARRAY       1035 
-SWIG_TYPECHECK_INT32_ARRAY       1045 
-SWIG_TYPECHECK_INT64_ARRAY       1055 
-SWIG_TYPECHECK_INT128_ARRAY      1065 
-SWIG_TYPECHECK_FLOAT_ARRAY       1080 
-SWIG_TYPECHECK_DOUBLE_ARRAY      1090 
-SWIG_TYPECHECK_CHAR_ARRAY        1130 
-SWIG_TYPECHECK_STRING_ARRAY      1140 
+SWIG_TYPECHECK_POINTER           0
+SWIG_TYPECHECK_ITERATOR          5
+SWIG_TYPECHECK_VOIDPTR           10
+SWIG_TYPECHECK_BOOL              15
+SWIG_TYPECHECK_UINT8             20
+SWIG_TYPECHECK_INT8              25
+SWIG_TYPECHECK_UINT16            30
+SWIG_TYPECHECK_INT16             35
+SWIG_TYPECHECK_UINT32            40
+SWIG_TYPECHECK_INT32             45
+SWIG_TYPECHECK_SIZE              47
+SWIG_TYPECHECK_PTRDIFF           48
+SWIG_TYPECHECK_UINT64            50
+SWIG_TYPECHECK_INT64             55
+SWIG_TYPECHECK_UINT128           60
+SWIG_TYPECHECK_INT128            65
+SWIG_TYPECHECK_INTEGER           70
+SWIG_TYPECHECK_FLOAT             80
+SWIG_TYPECHECK_DOUBLE            90
+SWIG_TYPECHECK_CPLXFLT           95
+SWIG_TYPECHECK_CPLXDBL           100
+SWIG_TYPECHECK_COMPLEX           105
+SWIG_TYPECHECK_UNICHAR           110
+SWIG_TYPECHECK_STDUNISTRING      115
+SWIG_TYPECHECK_UNISTRING         120
+SWIG_TYPECHECK_CHAR              130
+SWIG_TYPECHECK_STDSTRING         135
+SWIG_TYPECHECK_STRING            140
+SWIG_TYPECHECK_PAIR              150
+SWIG_TYPECHECK_STDARRAY          155
+SWIG_TYPECHECK_VECTOR            160
+SWIG_TYPECHECK_DEQUE             170
+SWIG_TYPECHECK_LIST              180
+SWIG_TYPECHECK_SET               190
+SWIG_TYPECHECK_MULTISET          200
+SWIG_TYPECHECK_MAP               210
+SWIG_TYPECHECK_MULTIMAP          220
+SWIG_TYPECHECK_STACK             230
+SWIG_TYPECHECK_QUEUE             240
+SWIG_TYPECHECK_BOOL_ARRAY        1015
+SWIG_TYPECHECK_INT8_ARRAY        1025
+SWIG_TYPECHECK_INT16_ARRAY       1035
+SWIG_TYPECHECK_INT32_ARRAY       1045
+SWIG_TYPECHECK_INT64_ARRAY       1055
+SWIG_TYPECHECK_INT128_ARRAY      1065
+SWIG_TYPECHECK_FLOAT_ARRAY       1080
+SWIG_TYPECHECK_DOUBLE_ARRAY      1090
+SWIG_TYPECHECK_CHAR_ARRAY        1130
+SWIG_TYPECHECK_STRING_ARRAY      1140
+SWIG_TYPECHECK_OBJECT_ARRAY      1150
+SWIG_TYPECHECK_BOOL_PTR          2015
+SWIG_TYPECHECK_UINT8_PTR         2020
+SWIG_TYPECHECK_INT8_PTR          2025
+SWIG_TYPECHECK_UINT16_PTR        2030
+SWIG_TYPECHECK_INT16_PTR         2035
+SWIG_TYPECHECK_UINT32_PTR        2040
+SWIG_TYPECHECK_INT32_PTR         2045
+SWIG_TYPECHECK_UINT64_PTR        2050
+SWIG_TYPECHECK_INT64_PTR         2055
+SWIG_TYPECHECK_FLOAT_PTR         2080
+SWIG_TYPECHECK_DOUBLE_PTR        2090
+SWIG_TYPECHECK_CHAR_PTR          2130
+SWIG_TYPECHECK_SWIGOBJECT        5000
 </pre>
 </div>
 
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 98be787..6fbca29 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -1436,34 +1436,20 @@
 GO = @GO@
 GOGCC = @GOGCC@
 GCCGO = @GCCGO@
-GO1 = @GO1@
-GO12 = @GO12@
-GO13 = @GO13@
-GO15 = @GO15@
-GOC = @GOC@
 GOOPT = @GOOPT@
 GCCGOOPT = @GCCGOOPT@
 GOVERSIONOPTION = @GOVERSIONOPTION@
 
 GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi`
-GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` `if $(GO13) || $(GO15); then echo -pack ; fi`
 
 GOSRCS = $(INTERFACE:.i=.go)
 GOCSRCS = $(INTERFACE:.i=_gc.c)
 
-GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi`
-GOTOOL = `if $(GO1) ; then echo go tool; fi`
-GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
-
 GOPACKAGE = $(notdir $(INTERFACE:.i=.a))
 
 GOPATHPARENTDIR = gopath/$(GOMOD)/src
 GOPATHDIR = $(GOPATHPARENTDIR)/$(INTERFACE:.i=)
 
-GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
-GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT))
-GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
-
 # ----------------------------------------------------------------
 # Build a Go module (C)
 # ----------------------------------------------------------------
@@ -1478,49 +1464,13 @@
 	echo "go 1.12" >> $(GOPATHDIR)/go.mod
 	mv -f $(GOPATHDIR)/go.mod $(GOPATHPARENTDIR)/go.mod
 
-go_nocgo: $(SRCDIR_SRCS)
-	$(SWIG) -go -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
-	if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
-	  $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
-	else \
-	  $(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
-	  $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
-	fi
-	if $(GOGCC) ; then \
-	  $(COMPILETOOL) $(GCCGO) -g -c -I . $(GOSRCS); \
-	else \
-	  $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS); \
-	  $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \
-	  rm -f $(GOPACKAGE); \
-	  if $(GO13) || $(GO15); then \
-	    cp $(GOGCOBJS) $(GOPACKAGE); \
-	    $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
-	  elif $(GO12); then \
-	    $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
-	  else \
-	    $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
-	  fi; \
-	fi
-	if test -f $(SRCDIR)$(RUNME).go; then \
-	  if $(GOGCC) ; then \
-	    $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \
-	  elif $(GO12) || $(GO13) || $(GO15); then \
-	    $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  else \
-	    $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  fi; \
-	fi
-
 go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
 	$(SWIG) -go -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
 	@mkdir gopath 2>/dev/null || true
 	@mkdir gopath/$(GOMOD) 2>/dev/null || true
 	@mkdir gopath/$(GOMOD)/src 2>/dev/null || true
 	@mkdir $(GOPATHDIR) 2>/dev/null || true
-	rm -f $(GOPATHDIR)/*
+	rm -rf $(GOPATHDIR)/*
 	cp $(ISRCS) $(GOPATHDIR)/
 	if test -f $(IWRAP:.i=.h); then \
 	  cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
@@ -1529,6 +1479,13 @@
 	  cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
 	fi
 	cp $(GOSRCS) $(GOPATHDIR)/
+	@if test -f $(SRCDIR)$(RUNME).go; then \
+	  mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \
+	  rm -f gopath/$(GOMOD)/src/runme/*; \
+	fi
+	if test -f $(SRCDIR)$(RUNME).go; then \
+	  cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \
+	fi
 	GOPATH=`pwd`/gopath/$(GOMOD); \
 	export GOPATH; \
 	CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
@@ -1537,82 +1494,29 @@
 	export CGO_CFLAGS; \
 	CGO_LDFLAGS="$(LDFLAGS) -lm"; \
 	export CGO_LDFLAGS; \
-	(cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
+	(cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \
 	if $(GOGCC); then \
 	  cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \
-	fi
+	fi; \
 	if test -f $(SRCDIR)$(RUNME).go; then \
-	  if $(GOGCC) ; then \
-	    $(COMPILETOOL) $(GCCGO) -c -g -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE); \
-	  elif $(GO12) || $(GO13) || $(GO15); then \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  else \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  fi; \
+	  mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \
+	  mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \
+	  cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \
+	  (cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \
+	  cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \
 	fi
 
 # ----------------------------------------------------------------
 # Build a Go module (C++)
 # ----------------------------------------------------------------
 
-go_cpp_nocgo: $(SRCDIR_SRCS)
-	$(SWIG) -go -c++ -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
-	if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
-	  if test -n "$(SRCDIR_CXXSRCS)$(SRCDIR_SRCS)"; then \
-	    $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_CXXSRCS) $(SRCDIR_SRCS) $(INCLUDES); \
-	  fi; \
-	  $(foreach f,$(ICXXSRCS), \
-	    $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) -o $(addsuffix .@OBJEXT@,$(basename $f)) $f $(INCLUDES); \
-	  ) \
-	else \
-	  $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
-	  $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
-	fi
-	if ! $(GOGCC) ; then \
-	  $(foreach f,$(GOSRCS), \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f \
-	  ); \
-	  $(foreach f,$(GOCSRCS), \
-	    $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} \
-	    -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f; \
-	  ) \
-	  rm -f $(GOPACKAGE); \
-	  if $(GO13) || $(GO15); then \
-	    cp $(GOGCOBJS) $(GOPACKAGE); \
-	    $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
-	  elif $(GO12); then \
-	    $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
-	  else \
-	    $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
-	  fi; \
-	else \
-	  $(foreach f,$(GOSRCS), \
-	    $(COMPILETOOL) $(GCCGO) -g -c -I . -o $(addsuffix .@OBJEXT@,$(basename $f)) $f \
-	  ); \
-	fi
-	if test -f $(SRCDIR)$(RUNME).go; then \
-	  if $(GOGCC) ; then \
-	    $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \
-	  elif $(GO12) || $(GO13) || $(GO15); then \
-	    $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  else \
-	    $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  fi; \
-	fi
-
 go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
 	$(SWIG) -go -c++ -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
 	@mkdir gopath 2>/dev/null || true
 	@mkdir gopath/$(GOMOD) 2>/dev/null || true
 	@mkdir gopath/$(GOMOD)/src 2>/dev/null || true
 	@mkdir $(GOPATHDIR) 2>/dev/null || true
-	rm -f $(GOPATHDIR)/*
+	rm -rf $(GOPATHDIR)/*
 	cp $(ICXXSRCS) $(GOPATHDIR)/
 	if test -f $(IWRAP:.i=.h); then \
 	  cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
@@ -1624,6 +1528,13 @@
 	  cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
 	fi
 	cp $(GOSRCS) $(GOPATHDIR)/
+	@if test -f $(SRCDIR)$(RUNME).go; then \
+	  mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \
+	  rm -f gopath/$(GOMOD)/src/runme/*; \
+	fi
+	if test -f $(SRCDIR)$(RUNME).go; then \
+	  cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \
+	fi
 	GOPATH=`pwd`/gopath/$(GOMOD); \
 	export GOPATH; \
 	CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
@@ -1634,21 +1545,16 @@
 	export CGO_CXXFLAGS; \
 	CGO_LDFLAGS="$(LDFLAGS) -lm"; \
 	export CGO_LDFLAGS; \
-	(cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
+	(cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \
 	if $(GOGCC); then \
 	  cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \
-	fi
+	fi; \
 	if test -f $(SRCDIR)$(RUNME).go; then \
-	  if $(GOGCC) ; then \
-	    $(COMPILETOOL) $(GCCGO) -g -c -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE) -lstdc++; \
-	  elif $(GO12) || $(GO13) || $(GO15); then \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  else \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
-	  fi; \
+	  mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \
+	  mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \
+	  cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \
+	  (cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \
+	  cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \
 	fi
 
 # -----------------------------------------------------------------
diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go
index 2c1d813..7c9ffd6 100644
--- a/Examples/go/callback/runme.go
+++ b/Examples/go/callback/runme.go
@@ -3,7 +3,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/class/runme.go b/Examples/go/class/runme.go
index d2f292e..a09a182 100644
--- a/Examples/go/class/runme.go
+++ b/Examples/go/class/runme.go
@@ -5,7 +5,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/constants/runme.go b/Examples/go/constants/runme.go
index d56fd62..57ef21a 100644
--- a/Examples/go/constants/runme.go
+++ b/Examples/go/constants/runme.go
@@ -3,7 +3,7 @@
 import (
 	"fmt"
 
-	"example"
+	"swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/director/runme.go b/Examples/go/director/runme.go
index 0e0da07..e28eccb 100644
--- a/Examples/go/director/runme.go
+++ b/Examples/go/director/runme.go
@@ -4,7 +4,7 @@
 	"fmt"
 	"os"
 
-	"example"
+	"swigtests/example"
 )
 
 func Compare(name string, got string, exp string) error {
diff --git a/Examples/go/enum/runme.go b/Examples/go/enum/runme.go
index 5088705..c0642e0 100644
--- a/Examples/go/enum/runme.go
+++ b/Examples/go/enum/runme.go
@@ -3,7 +3,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go
index af64a6e..716af52 100644
--- a/Examples/go/extend/runme.go
+++ b/Examples/go/extend/runme.go
@@ -5,7 +5,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/funcptr/runme.go b/Examples/go/funcptr/runme.go
index 4b20db4..87ec7d4 100644
--- a/Examples/go/funcptr/runme.go
+++ b/Examples/go/funcptr/runme.go
@@ -3,7 +3,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/multimap/runme.go b/Examples/go/multimap/runme.go
index 571fac7..2f8b205 100644
--- a/Examples/go/multimap/runme.go
+++ b/Examples/go/multimap/runme.go
@@ -3,7 +3,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go
index 0cf340f..73c6b2b 100644
--- a/Examples/go/pointer/runme.go
+++ b/Examples/go/pointer/runme.go
@@ -3,7 +3,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/reference/runme.go b/Examples/go/reference/runme.go
index 9999733..7391d9c 100644
--- a/Examples/go/reference/runme.go
+++ b/Examples/go/reference/runme.go
@@ -5,7 +5,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/simple/runme.go b/Examples/go/simple/runme.go
index 0bd4657..5bc055f 100644
--- a/Examples/go/simple/runme.go
+++ b/Examples/go/simple/runme.go
@@ -3,7 +3,7 @@
 import (
 	"fmt"
 
-	"example"
+	"swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/template/runme.go b/Examples/go/template/runme.go
index 3477953..e000b15 100644
--- a/Examples/go/template/runme.go
+++ b/Examples/go/template/runme.go
@@ -5,7 +5,7 @@
 import (
 	"fmt"
 
-	. "example"
+	. "swigtests/example"
 )
 
 func main() {
diff --git a/Examples/go/variables/runme.go b/Examples/go/variables/runme.go
index e2dd0c6..85ca8c6 100644
--- a/Examples/go/variables/runme.go
+++ b/Examples/go/variables/runme.go
@@ -5,7 +5,7 @@
 import (
 	"fmt"
 
-	"example"
+	"swigtests/example"
 )
 
 func main() {
diff --git a/Examples/guile/std_vector/example.h b/Examples/guile/std_vector/example.h
index 4f0dac7..52e260d 100644
--- a/Examples/guile/std_vector/example.h
+++ b/Examples/guile/std_vector/example.h
@@ -17,9 +17,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    // would you believe this is the same as the above?
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 
diff --git a/Examples/mzscheme/std_vector/example.h b/Examples/mzscheme/std_vector/example.h
index 4f0dac7..52e260d 100644
--- a/Examples/mzscheme/std_vector/example.h
+++ b/Examples/mzscheme/std_vector/example.h
@@ -17,9 +17,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    // would you believe this is the same as the above?
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 
diff --git a/Examples/ocaml/std_vector/example.h b/Examples/ocaml/std_vector/example.h
index b753592..d968f69 100644
--- a/Examples/ocaml/std_vector/example.h
+++ b/Examples/ocaml/std_vector/example.h
@@ -17,9 +17,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    // would you believe this is the same as the above?
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 
diff --git a/Examples/php/pragmas/example.i b/Examples/php/pragmas/example.i
index b72828b..ea9590b 100644
--- a/Examples/php/pragmas/example.i
+++ b/Examples/php/pragmas/example.i
@@ -21,11 +21,11 @@
   zend_printf("This was %%rshutdown\n");
 }
 
-%pragma(php) include="./include.php";
+%pragma(php) include="include.php";
 
 %pragma(php) code="
 # This code is inserted into example.php
-echo \"this was php code\\n\";
+echo \"This was php code\\n\";
 "
 %pragma(php) version="1.5"
 
diff --git a/Examples/php/pragmas/include.php b/Examples/php/pragmas/include.php
index e19880a..11d985d 100644
--- a/Examples/php/pragmas/include.php
+++ b/Examples/php/pragmas/include.php
@@ -1,7 +1,7 @@
 <?php
 
 # This code is inserted into example.php
-echo "this is include.php\n";
+echo "This is include.php\n";
 
 
 ?>
diff --git a/Examples/php/pragmas/runme.php b/Examples/php/pragmas/runme.php
index b99cf37..7b2c179 100644
--- a/Examples/php/pragmas/runme.php
+++ b/Examples/php/pragmas/runme.php
@@ -1,6 +1,9 @@
 <?php
 
+# For finding include.php
+set_include_path(realpath(dirname(__FILE__)) . PATH_SEPARATOR . get_include_path());
+
 require "example.php";
 
-echo "Version - " . ((new ReflectionExtension('example'))->getVersion());
+echo "Version - " . ((new ReflectionExtension('example'))->getVersion()) . "\n";
 ?>
diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py
index 924142f..0eb8f51 100644
--- a/Examples/python/import_packages/namespace_pkg/normal.py
+++ b/Examples/python/import_packages/namespace_pkg/normal.py
@@ -11,7 +11,7 @@
 print(" Starting subtest " + os.path.basename(__file__))
 
 # Package brave found under one path
-sys.path.insert(0, 'path1')
+sys.path.insert(0, "path1")
 
 from brave import robin
 print("  Finished from brave import robin")
diff --git a/Examples/python/import_packages/namespace_pkg/nstest.py b/Examples/python/import_packages/namespace_pkg/nstest.py
index e80289f..4d618a6 100644
--- a/Examples/python/import_packages/namespace_pkg/nstest.py
+++ b/Examples/python/import_packages/namespace_pkg/nstest.py
@@ -11,7 +11,7 @@
         print("  Finished running: " + commandline)
 
 def copyMods():
-    dirs = ['path1', 'path2', 'path3']
+    dirs = ["path1", "path2", "path3"]
 
     # Clean out any old package paths
     for d in dirs:
@@ -20,20 +20,20 @@
 
     for d in dirs:
         os.mkdir(d)
-        os.mkdir(os.path.join(d, 'brave'))
+        os.mkdir(os.path.join(d, "brave"))
 
-    shutil.copy('robin.py', os.path.join('path1', 'brave'))
-    subprocess.check_call('cp _robin.* ' + os.path.join('path1', 'brave'), shell=True)
+    shutil.copy("robin.py", os.path.join("path1", "brave"))
+    subprocess.check_call("cp _robin.* " + os.path.join("path1", "brave"), shell=True)
 
-    shutil.copy('robin.py', os.path.join('path2', 'brave'))
-    subprocess.check_call('cp _robin.* ' + os.path.join('path3', 'brave'), shell=True)
+    shutil.copy("robin.py", os.path.join("path2", "brave"))
+    subprocess.check_call("cp _robin.* " + os.path.join("path3", "brave"), shell=True)
 
     mkzip()
 
 def mkzip():
     zf = zipfile.ZipFile("path4.zip", "w")
-    zf.writestr("brave/", b'')
-    zf.write('robin.py', 'brave/robin.py')
+    zf.writestr("brave/", b"")
+    zf.write("robin.py", "brave/robin.py")
     zf.close()
 
 
diff --git a/Examples/python/import_packages/namespace_pkg/split.py b/Examples/python/import_packages/namespace_pkg/split.py
index 8989954..9d786dc 100644
--- a/Examples/python/import_packages/namespace_pkg/split.py
+++ b/Examples/python/import_packages/namespace_pkg/split.py
@@ -12,8 +12,8 @@
 
 # Package brave split into two paths.
 # path2/brave/robin.py and path3/brave/_robin.so
-sys.path.insert(0, 'path2')
-sys.path.insert(0, 'path3')
+sys.path.insert(0, "path2")
+sys.path.insert(0, "path3")
 
 from brave import robin
 print("  Finished from brave import robin")
diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py
index 8af9cf0..30434f9 100644
--- a/Examples/python/import_packages/namespace_pkg/zipsplit.py
+++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py
@@ -12,8 +12,8 @@
 
 # Package brave split into two paths.
 # brave/robin.py (in path4.zip) and path3/brave/_robin.so
-sys.path.insert(0, 'path4.zip')
-sys.path.insert(0, 'path3')
+sys.path.insert(0, "path4.zip")
+sys.path.insert(0, "path3")
 
 from brave import robin
 print("  Finished from brave import robin")
diff --git a/Examples/python/performance/constructor/runme.py b/Examples/python/performance/constructor/runme.py
index 1771fba..b00cd45 100644
--- a/Examples/python/performance/constructor/runme.py
+++ b/Examples/python/performance/constructor/runme.py
@@ -1,5 +1,5 @@
 import sys
-sys.path.append('..')
+sys.path.append("..")
 import harness
 
 
diff --git a/Examples/python/performance/func/runme.py b/Examples/python/performance/func/runme.py
index 760a8ab..3b14279 100644
--- a/Examples/python/performance/func/runme.py
+++ b/Examples/python/performance/func/runme.py
@@ -1,5 +1,5 @@
 import sys
-sys.path.append('..')
+sys.path.append("..")
 import harness
 
 
diff --git a/Examples/python/performance/harness.py b/Examples/python/performance/harness.py
index c3d38b4..3468faa 100644
--- a/Examples/python/performance/harness.py
+++ b/Examples/python/performance/harness.py
@@ -17,16 +17,16 @@
 
     except IndexError:
         proc = Popen(
-            [sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
+            [sys.executable, "runme.py", "Simple_baseline"], stdout=PIPE)
         (stdout, stderr) = proc.communicate()
         print stdout
 
         proc = Popen(
-            [sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
+            [sys.executable, "runme.py", "Simple_optimized"], stdout=PIPE)
         (stdout, stderr) = proc.communicate()
         print stdout
 
         proc = Popen(
-            [sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
+            [sys.executable, "runme.py", "Simple_builtin"], stdout=PIPE)
         (stdout, stderr) = proc.communicate()
         print stdout
diff --git a/Examples/python/performance/hierarchy/runme.py b/Examples/python/performance/hierarchy/runme.py
index 8255cdc..3899582 100644
--- a/Examples/python/performance/hierarchy/runme.py
+++ b/Examples/python/performance/hierarchy/runme.py
@@ -1,5 +1,5 @@
 import sys
-sys.path.append('..')
+sys.path.append("..")
 import harness
 
 
diff --git a/Examples/python/performance/hierarchy_operator/runme.py b/Examples/python/performance/hierarchy_operator/runme.py
index eabfae8..48241d4 100644
--- a/Examples/python/performance/hierarchy_operator/runme.py
+++ b/Examples/python/performance/hierarchy_operator/runme.py
@@ -1,5 +1,5 @@
 import sys
-sys.path.append('..')
+sys.path.append("..")
 import harness
 
 
diff --git a/Examples/python/performance/operator/runme.py b/Examples/python/performance/operator/runme.py
index d75ae40..798dd8b 100644
--- a/Examples/python/performance/operator/runme.py
+++ b/Examples/python/performance/operator/runme.py
@@ -1,5 +1,5 @@
 import sys
-sys.path.append('..')
+sys.path.append("..")
 import harness
 
 
diff --git a/Examples/python/std_vector/example.h b/Examples/python/std_vector/example.h
index 4f0dac7..52e260d 100644
--- a/Examples/python/std_vector/example.h
+++ b/Examples/python/std_vector/example.h
@@ -17,9 +17,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    // would you believe this is the same as the above?
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 
diff --git a/Examples/ruby/exceptproxy/example.i b/Examples/ruby/exceptproxy/example.i
index 8e00751..ad0c23a 100644
--- a/Examples/ruby/exceptproxy/example.i
+++ b/Examples/ruby/exceptproxy/example.i
@@ -14,7 +14,7 @@
 %}
 
 
-/* The EmpytError doesn't appear in a throw declaration, and hence
+/* The EmptyError doesn't appear in a throw declaration, and hence
   we need to tell SWIG that the dequeue method throws it.  This can
   now be done via the %catchs feature. */
 %catches(FullError) *::enqueue;
diff --git a/Examples/ruby/std_vector/example.h b/Examples/ruby/std_vector/example.h
index 4f0dac7..52e260d 100644
--- a/Examples/ruby/std_vector/example.h
+++ b/Examples/ruby/std_vector/example.h
@@ -17,9 +17,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    // would you believe this is the same as the above?
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 
diff --git a/Examples/scilab/std_vector/example.h b/Examples/scilab/std_vector/example.h
index 4f0dac7..52e260d 100644
--- a/Examples/scilab/std_vector/example.h
+++ b/Examples/scilab/std_vector/example.h
@@ -17,9 +17,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    // would you believe this is the same as the above?
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 
diff --git a/Examples/tcl/std_vector/example.h b/Examples/tcl/std_vector/example.h
index 4f0dac7..52e260d 100644
--- a/Examples/tcl/std_vector/example.h
+++ b/Examples/tcl/std_vector/example.h
@@ -17,9 +17,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    // would you believe this is the same as the above?
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 67a6328..5f77928 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -324,6 +324,7 @@
 	nested_directors \
 	nested_comment \
 	nested_ignore \
+	nested_inheritance_interface \
 	nested_in_template \
 	nested_scope \
 	nested_template_base \
@@ -620,6 +621,7 @@
 	doxygen_alias \
 	doxygen_basic_notranslate \
 	doxygen_basic_translate \
+	doxygen_basic_translate_style2 \
 	doxygen_ignore \
 	doxygen_misc_constructs \
 	doxygen_nested_class \
@@ -641,6 +643,7 @@
 	director_string \
 	ignore_template_constructor \
 	li_std_combinations \
+	li_std_containers_overload \
 	li_std_deque \
 	li_std_except \
 	li_std_except_as_class \
@@ -653,6 +656,7 @@
 	li_std_vector_enum \
 	li_std_vector_member_var\
 	li_std_vector_ptr \
+	li_std_wstring \
 	smart_pointer_inherit \
 	template_typedef_fnc \
 	template_type_namespace \
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
index b102ffe..3e4775d 100644
--- a/Examples/test-suite/constant_directive.i
+++ b/Examples/test-suite/constant_directive.i
@@ -14,6 +14,11 @@
   Type1(int val = 0) : val(val) {}
   int val;
 };
+enum EnumType
+{
+  EnumValue
+};
+EnumType enumValue = EnumValue;
 /* Typedefs for const Type and its pointer */
 typedef const Type1 Type1Const;
 typedef const Type1* Type1Cptr;
@@ -46,3 +51,4 @@
 %constant Type1Cfptr TYPE1CFPTR1DEF_CONSTANT1 = getType1Instance;
 /* Regular constant */
 %constant int TYPE_INT = 0;
+%constant enum EnumType newValue = enumValue;
diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i
index 755efb0..420db4f 100644
--- a/Examples/test-suite/cpp11_constexpr.i
+++ b/Examples/test-suite/cpp11_constexpr.i
@@ -4,6 +4,15 @@
 %module cpp11_constexpr
 
 
+%{
+#if defined(__clang__)
+#pragma clang diagnostic push
+// Suppress: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior
+// For MMM() and NNN()
+#pragma clang diagnostic ignored "-Wconstexpr-not-const"
+#endif
+%}
+
 %inline %{
 #ifdef SWIG
 #define SWIGTESTCONST const
diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i
index b5e84ed..0c20fb7 100644
--- a/Examples/test-suite/cpp11_default_delete.i
+++ b/Examples/test-suite/cpp11_default_delete.i
@@ -28,7 +28,13 @@
 
 struct A2 {
   void funk(int i) {}
+
+// Workaround clang 10.0.1 -std=c++17 linker error (oddly for Java and not Python):
+// Undefined symbols for architecture x86_64:"___cxa_deleted_virtual", referenced from: vtable for A2
+#if !(defined(__clang__) && __cplusplus >= 201703L)
   virtual void fff(int) = delete;
+#endif
+
   virtual ~A2() = default;
   template<class T> void funk(T) = delete;
 };
diff --git a/Examples/test-suite/cpp11_initializer_list.i b/Examples/test-suite/cpp11_initializer_list.i
index 58d2ecc..b309576 100644
--- a/Examples/test-suite/cpp11_initializer_list.i
+++ b/Examples/test-suite/cpp11_initializer_list.i
@@ -6,12 +6,21 @@
 %ignore A::A(std::initializer_list<int>);
 %ignore B::method;
 
-%typemap(in) std::initializer_list<const char *> {
+%typemap(in) std::initializer_list<const char *> %{
   $1 = {"Ab", "Fab"};
-}
+%}
+
+%begin %{
+#if __GNUC__ >= 9
+/* warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] */
+/* incorrect warning for C::C(std::initializer_list<const char *>) */
+#pragma GCC diagnostic ignored "-Winit-list-lifetime"
+#endif
+%}
 
 %inline %{
 #include <initializer_list>
+#include <string>
 
 class A {
 public:
@@ -26,9 +35,16 @@
   void method(std::initializer_list<int> init) {}
 };
 class C {
+  std::string joined;
 public:
-  C(std::initializer_list<const char *>) {}
+  C(std::initializer_list<const char *> init) {
+    for (auto& val : init)
+      joined += val;
+  }
   C() {}
+  const char * get_joined_string() {
+    return joined.c_str();
+  }
 };
 %}
 
diff --git a/Examples/test-suite/cpp11_noexcept.i b/Examples/test-suite/cpp11_noexcept.i
index a77eb04..8aa0baa 100644
--- a/Examples/test-suite/cpp11_noexcept.i
+++ b/Examples/test-suite/cpp11_noexcept.i
@@ -31,8 +31,13 @@
   void noo1() const noexcept {}
   static void noo2() noexcept {}
   virtual void noo3() const noexcept {}
+
+// Workaround clang 10.0.1 -std=c++17 linker error (oddly for Java and not Python):
+// Undefined symbols for architecture x86_64: "___cxa_deleted_virtual", referenced from: vtable for NoExceptClass
+#if !(defined(__clang__) && __cplusplus >= 201703L)
   virtual void noo4() const noexcept = delete;
   virtual void noo5() const throw() = delete;
+#endif
 };
 
 struct NoExceptAbstract {
diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i
index 9aaf4ac..a2a0020 100644
--- a/Examples/test-suite/cpp11_rvalue_reference2.i
+++ b/Examples/test-suite/cpp11_rvalue_reference2.i
@@ -31,7 +31,7 @@
   // test both primitive and user defined rvalue reference default arguments and compactdefaultargs
   void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u  = (const UserDef &&)PublicUserDef) {}
   void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
-  operator int &&() { return std::move(0); }
+  operator int &&() { return std::move(val); }
   Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(std::move(rhs.rvalref)) {}
   Thingy& operator=(const Thingy& rhs) {
     val = rhs.val;
diff --git a/Examples/test-suite/cpp11_rvalue_reference3.i b/Examples/test-suite/cpp11_rvalue_reference3.i
index 6dfe4c0..8ebf453 100644
--- a/Examples/test-suite/cpp11_rvalue_reference3.i
+++ b/Examples/test-suite/cpp11_rvalue_reference3.i
@@ -26,10 +26,10 @@
 
 struct Containing {
   Thing && member_rvalue_ref;
-  Thing *&& member_rvalue_ref_ptr1 = 0;
-  Thing const*&& member_rvalue_ref_ptr2 = 0;
-  Thing *const&& member_rvalue_ref_ptr3 = 0;
-  Thing const*const &&member_rvalue_ref_ptr4 = 0;
+  Thing *&& member_rvalue_ref_ptr1;
+  Thing const*&& member_rvalue_ref_ptr2;
+  Thing *const&& member_rvalue_ref_ptr3;
+  Thing const*const &&member_rvalue_ref_ptr4;
 
   Containing(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) :
     member_rvalue_ref(std::move(r)), 
@@ -63,10 +63,10 @@
 
 struct IntContaining {
   int && member_rvalue_ref;
-  int *&& member_rvalue_ref_ptr1 = 0;
-  int const*&& member_rvalue_ref_ptr2 = 0;
-  int *const&& member_rvalue_ref_ptr3 = 0;
-  int const*const &&member_rvalue_ref_ptr4 = 0;
+  int *&& member_rvalue_ref_ptr1;
+  int const*&& member_rvalue_ref_ptr2;
+  int *const&& member_rvalue_ref_ptr3;
+  int const*const &&member_rvalue_ref_ptr4;
 
   IntContaining(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) :
     member_rvalue_ref(std::move(r)),
diff --git a/Examples/test-suite/cpp11_template_typedefs.i b/Examples/test-suite/cpp11_template_typedefs.i
index 02cb8ac..5f1f2e6 100644
--- a/Examples/test-suite/cpp11_template_typedefs.i
+++ b/Examples/test-suite/cpp11_template_typedefs.i
@@ -15,7 +15,7 @@
   using type2_t = T2;
   T1 a;
   T2 b;
-  constexpr int get_n() { return N; }
+  constexpr int get_n() const { return N; }
 };
 
 // Specialization for T1=const char*, T2=bool
@@ -26,7 +26,7 @@
   using type2_t = bool;
   type1_t a;
   type2_t b;
-  constexpr int get_n() { return 3 * N; }
+  constexpr int get_n() const { return 3 * N; }
 };
 
 // alias templates
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index c9e48f8..8272864 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -19,6 +19,7 @@
 	csharp_exceptions \
 	csharp_features \
 	csharp_lib_arrays \
+	csharp_lib_arrays_bool \
 	csharp_namespace_system_collision \
 	csharp_prepost \
 	csharp_typemaps \
@@ -48,6 +49,7 @@
 intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
 complextest.cpptest: CSHARPFLAGSSPECIAL = -r:System.Numerics.dll
 csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
+csharp_lib_arrays_bool.cpptest: CSHARPFLAGSSPECIAL = -unsafe
 csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP
 
 # Rules for the different types of tests
diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs
new file mode 100644
index 0000000..3b19b57
--- /dev/null
+++ b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs
@@ -0,0 +1,90 @@
+using System;
+using csharp_lib_arrays_boolNamespace;
+
+public class runme
+{
+  static void Main() 
+  {
+    {
+      bool[] source = { true, false, false, true, false, true, true, false };
+      bool[] target = new bool[ source.Length ];
+
+      csharp_lib_arrays_bool.myArrayCopyUsingFixedArraysBool( source, target, target.Length );
+      CompareArrays(source, target, "bool[] INPUT/OUTPUT Fixed");
+    }
+    
+    {
+      bool[] source = { true, false, false, true, false, true, true, false };
+      bool[] target = { false, true, true, false, true, false, false, true };
+
+      csharp_lib_arrays_bool.myArraySwapUsingFixedArraysBool( source, target, target.Length );
+
+      for (int i=0; i<target.Length; ++i)
+        target[i] = !target[i];
+
+      CompareArrays(source, target, "bool[] INOUT");
+    }
+
+    if( runtimeIsMono() )
+    {
+//      Console.Error.WriteLine("Tests are running on mono, failing bool[] tests skipped");
+//      See Mono bug report https://github.com/mono/mono/issues/15592
+      return;
+    }
+
+    {
+      bool[] source = { true, false, false, true, false, true, true, false };
+      bool[] target = new bool[ source.Length ];
+
+      if( !csharp_lib_arrays_bool.checkBoolArrayCorrect( source, source.Length ) )
+      {
+        throw new Exception("bool[] INPUT incorrect");
+      }
+
+      csharp_lib_arrays_bool.myArrayCopyBool( source, target, target.Length );
+      CompareArrays(source, target, "bool[] INPUT/OUTPUT");
+    }
+
+    {
+      bool[] source = { true, false, false, true, false, true, true, false };
+      bool[] target = { false, true, true, false, true, false, false, true };
+
+      csharp_lib_arrays_bool.myArraySwapBool( source, target, target.Length );
+
+      for (int i=0; i<target.Length; ++i)
+        target[i] = !target[i];
+
+      CompareArrays(source, target, "bool[] INOUT");
+    }
+  }
+  
+  static void CompareArrays<T>( T[] a, T[] b, string testName ) 
+  {
+    if (a.Length != b.Length)
+      throw new Exception("size mismatch");
+
+    for(int i=0; i<a.Length; ++i) {
+      if (a[i].Equals(b[i]) == false) {
+        Console.Error.WriteLine("C# Array mismatch: " + testName);
+        Console.Error.WriteLine("a:");
+        PrintArray(a);
+        Console.Error.WriteLine("b:");
+        PrintArray(b);
+        throw new Exception("element mismatch");
+      }
+    }
+  }
+
+  static void PrintArray<T>( T[] a )
+  {
+    foreach ( T i in a )
+      Console.Error.Write( "{0} ", i );
+    Console.Error.WriteLine();
+  }
+
+  static bool runtimeIsMono()
+  {
+    return Type.GetType ("Mono.Runtime") != null;
+  }
+}
+
diff --git a/Examples/test-suite/csharp/li_std_set_runme.cs b/Examples/test-suite/csharp/li_std_set_runme.cs
index 6519e8c..e9cd2c2 100644
--- a/Examples/test-suite/csharp/li_std_set_runme.cs
+++ b/Examples/test-suite/csharp/li_std_set_runme.cs
@@ -85,5 +85,21 @@
         ss = new StringSet{"foo", "bar", "baz"};
         ss.UnionWith(new[] {"baz", "quux"});
         checkThat(ss.SetEquals(new[] {"foo", "bar", "baz", "quux"}), "UnionWith works");
+
+        // Check a set of another type.
+        FooSet fooSet = new FooSet();
+        ISet<Foo> fooISet = fooSet;
+        checkThat(fooISet.Count == 0, "is initially empty");
+        checkThat(fooISet.Add(new Foo(17)), "added successfully");
+        checkThat(fooISet.Count == 1, "is not empty any more");
+
+        // And a set of primitive type.
+        IntSet intSet = new IntSet();
+        checkThat(intSet.Count == 0, "is initially empty");
+        checkThat(intSet.Add(17), "17 added successfully");
+        checkThat(!intSet.Add(17), "17 not added again");
+        checkThat(intSet.Count == 1, "not empty any more");
+        checkThat(intSet.Add(289), "289 added successfully");
+        checkThat(intSet.Count == 2, "even less empty now");
     }
 }
diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs
index fe663a3..8b7ba1b 100644
--- a/Examples/test-suite/csharp/li_std_wstring_runme.cs
+++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs
@@ -3,74 +3,116 @@
 
 public class runme
 {
+    static private void check_equal(char a, char b)
+    {
+      if (a != b)
+        throw new Exception("char failed '" + a + "' != '" + b + "'");
+    }
+
+    static private void check_equal(string a, string b)
+    {
+      if (a != b)
+        throw new Exception("string failed '" + a + "' != '" + b + "'");
+    }
+
     static void Main() 
     {
-      char y='h';
+        char h = 'h';
+        check_equal(li_std_wstring.test_wcvalue(h), h);
 
-      if (li_std_wstring.test_wcvalue(y) != y)
-        throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue(y));
+        string x = "abc";
+        check_equal(li_std_wstring.test_ccvalue(x), x);
+        check_equal(li_std_wstring.test_cvalue(x), x);
 
-      if (li_std_wstring.test_wcvalue_w() != 'W')
-        throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue_w());
+        check_equal(li_std_wstring.test_wchar_overload(x), x);
+        check_equal(li_std_wstring.test_wchar_overload(), null);
 
-      string x="hello";
+        li_std_wstring.test_pointer(null);
+        li_std_wstring.test_const_pointer(null);
 
-      if (li_std_wstring.test_ccvalue(x) != x)
-        throw new Exception("bad string mapping");
+        try {
+            li_std_wstring.test_value(null);
+            throw new Exception("NULL check failed");
+        } catch (ArgumentNullException) {
+        }
 
-      if (li_std_wstring.test_cvalue(x) != x)
-        throw new Exception("bad string mapping");
+        try {
+              li_std_wstring.test_reference(null);
+              throw new Exception("NULL check failed");
+        } catch (ArgumentNullException e) {
+            if (!e.Message.Contains("type is null"))
+                throw new Exception("Missing text " + e);
+        }
+        try {
+            li_std_wstring.test_const_reference(null);
+            throw new Exception("NULL check failed");
+        } catch (ArgumentNullException e) {
+            if (!e.Message.Contains("null wstring"))
+                throw new Exception("Missing text " + e);
+        }
 
+        x = "hello";
+        check_equal(li_std_wstring.test_const_reference(x), x);
 
-      if (li_std_wstring.test_value(x) != x)
-        throw new Exception("bad string mapping: " + x + li_std_wstring.test_value(x));
+        /* Postpone, tricky, std::wstring portability problem.
+         * std::wstring is 2 bytes on Windows, 4 bytes on Linux, LPWSTR is 2 bytes.
+         * .NET marshalling should work on Windows but not Linux.
+        string s = "abc";
+        if (!li_std_wstring.test_equal_abc(s))
+            throw new Exception("Not equal " + s);
+        */
 
-      if (li_std_wstring.test_const_reference(x) != x)
-        throw new Exception("bad string mapping");
+        try {
+            li_std_wstring.test_throw();
+        } catch (Exception e) {
+            check_equal(e.Message, "throwing test_throw");
+        }
 
+        x = "abc\0def";
+        // Unlike other languages, embedded NULL in std::string not supported
+        // check_equal(li_std_wstring.test_value(x), x);
+        check_equal(li_std_wstring.test_value(x), "abc");
+        check_equal(li_std_wstring.test_ccvalue(x), "abc");
+        check_equal(li_std_wstring.test_wchar_overload(x), "abc");
 
-      string s = "he";
-      s = s + "llo";
+        {
+            // Unicode strings
+            string[] test_strings = {
+                "JP: 日本語", "DE: Kröpeliner Straße" , "RU: Война и мир", "EN: War and Peace"
+            };
 
-      if (s != x)
-        throw new Exception("bad string mapping: " + s + x);
+            foreach (string expected in test_strings)
+            {
+                string received = li_std_wstring.test_value(expected);
+                check_equal(received, expected);
+            }
 
-      if (li_std_wstring.test_value(s) != x)
-        throw new Exception("bad string mapping");
+            foreach (string expected in test_strings)
+            {
+                string received = li_std_wstring.test_const_reference(expected);
+                check_equal(received, expected);
+            }
 
-      if (li_std_wstring.test_const_reference(s) != x)
-        throw new Exception("bad string mapping");
+            foreach (string expected in test_strings)
+            {
+                string received = li_std_wstring.test_ccvalue(expected);
+                check_equal(received, expected);
+            }
 
-      string a = s;
-
-      if (li_std_wstring.test_value(a) != x)
-        throw new Exception("bad string mapping");
-
-      if (li_std_wstring.test_const_reference(a) != x)
-        throw new Exception("bad string mapping");
-
-      string b = " world";
-
-      if (a + b != "hello world")
-        throw new Exception("bad string mapping");
-
-      if (a + " world" != "hello world")
-        throw new Exception("bad string mapping");
-
-      if ("hello" + b != "hello world")
-        throw new Exception("bad string mapping");
-
-      s = "hello world";
-
-      B myB = new B("hi");
-
-      myB.name = "hello";
-      if (myB.name != "hello")
-        throw new Exception("bad string mapping");
-
-      myB.a = "hello";
-      if (myB.a != "hello")
-        throw new Exception("bad string mapping");
+            /* Not working for Japanese and Russian characters on Windows, okay on Linux
+             * Is fixed by adding CharSet=CharSet.Unicode to the DllImport, so change to:
+             * [global::System.Runtime.InteropServices.DllImport("li_std_wstring", CharSet=global::System.Runtime.InteropServices.CharSet.Unicode, EntryPoint="CSharp_li_std_wstringNamespace_test_wcvalue")]
+             * Needs a SWIG code change to support this
+            foreach (string test_string in test_strings)
+            {
+                foreach (char expected in test_string)
+                {
+                    char received = li_std_wstring.test_wcvalue(expected);
+                    check_equal(received, expected);
+                }
+            }
+            */
+        }
     }
 }
 
diff --git a/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs
new file mode 100644
index 0000000..810b7db
--- /dev/null
+++ b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using nested_inheritance_interfaceNamespace;
+
+public class nested_inheritance_interface_runme {
+
+  static string SortArrayToString(string[] types) {
+    Array.Sort<string>(types);
+    return string.Join(" ", types);
+  }
+
+  static string SortArrayToString(Type[] types) {
+    List<string> stypes = new List<string>();
+    foreach (Type t in types)
+      stypes.Add(t.Name);
+    return SortArrayToString(stypes.ToArray());
+  }
+
+  private static void takeIA(IASwigInterface ia) {
+  }
+
+  public static void Main() {
+    Type[] BNInterfaces = typeof(B.N).GetInterfaces();
+    string expectedInterfacesString = "IASwigInterface IDisposable";
+    string actualInterfacesString = SortArrayToString(BNInterfaces);
+    if (expectedInterfacesString != actualInterfacesString)
+      throw new Exception("Expected interfaces for " + typeof(B.N).Name + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
+
+    if (!typeof(IASwigInterface).IsInterface)
+      throw new Exception(typeof(IASwigInterface).Name + " should be an interface but is not");
+
+    // overloaded methods check
+    B.N d = new B.N();
+    takeIA(d);
+  }
+}
diff --git a/Examples/test-suite/csharp_lib_arrays_bool.i b/Examples/test-suite/csharp_lib_arrays_bool.i
new file mode 100644
index 0000000..58cee9d
--- /dev/null
+++ b/Examples/test-suite/csharp_lib_arrays_bool.i
@@ -0,0 +1,78 @@
+%module csharp_lib_arrays_bool
+
+%include "arrays_csharp.i"
+
+%apply bool INPUT[] { bool* sourceArray }
+%apply bool OUTPUT[] { bool* targetArray }
+
+%apply bool INOUT[] { bool* array1 }
+%apply bool INOUT[] { bool* array2 }
+
+%inline %{
+#include <iostream>
+
+/* copy the contents of the first array to the second */
+void myArrayCopyBool( bool* sourceArray, bool* targetArray, int nitems ) {
+  int i;
+  for ( i = 0; i < nitems; i++ ) {
+    targetArray[ i ] = sourceArray[ i ];
+  }
+}
+
+/* swap the contents of the two arrays */
+void myArraySwapBool( bool* array1, bool* array2, int nitems ) {
+  int i;
+  bool temp;
+  for ( i = 0; i < nitems; i++ ) {
+    temp = array1[ i ];
+    array1[ i ] = array2[ i ];
+    array2[ i ] = temp;
+  }
+}
+
+bool checkBoolArrayCorrect( bool* sourceArray, int sourceArraySize ) {
+  if( sourceArraySize != 8 ) {
+    std::cout << "checkBoolArrayCorrect: Expected array with 8 elements" << std::endl;
+    return false;
+  }
+  return sourceArray[0] == true &&
+         sourceArray[1] == false &&
+         sourceArray[2] == false &&
+         sourceArray[3] == true &&
+         sourceArray[4] == false &&
+         sourceArray[5] == true &&
+         sourceArray[6] == true &&
+         sourceArray[7] == false;
+}
+%}
+
+%clear bool* sourceArray;
+%clear bool* targetArray;
+
+%clear bool* array1;
+%clear bool* array2;
+
+// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
+%csmethodmodifiers myArrayCopyUsingFixedArraysBool "public unsafe";
+%csmethodmodifiers myArraySwapUsingFixedArraysBool "public unsafe";
+
+%apply bool FIXED[] { bool* sourceArray }
+%apply bool FIXED[] { bool* targetArray }
+
+%inline %{
+void myArrayCopyUsingFixedArraysBool( bool *sourceArray, bool* targetArray, int nitems ) {
+  myArrayCopyBool(sourceArray, targetArray, nitems);
+}
+%}
+
+%apply bool FIXED[] { bool* array1 }
+%apply bool FIXED[] { bool* array2 }
+
+%inline %{
+void myArraySwapUsingFixedArraysBool( bool* array1, bool* array2, int nitems ) {
+  myArraySwapBool(array1, array2, nitems);
+}
+%}
+
+
+
diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i
index 0a8b047..da4d809 100644
--- a/Examples/test-suite/doxygen_basic_translate.i
+++ b/Examples/test-suite/doxygen_basic_translate.i
@@ -57,6 +57,8 @@
  * \warning This may not work as expected
  * \code
  * int main() { while(true); }
+ *
+ * // Test blank line in code block
  * \endcode
  * \endif
  */
diff --git a/Examples/test-suite/doxygen_basic_translate_style2.i b/Examples/test-suite/doxygen_basic_translate_style2.i
new file mode 100644
index 0000000..32e3cfc
--- /dev/null
+++ b/Examples/test-suite/doxygen_basic_translate_style2.i
@@ -0,0 +1,107 @@
+%module doxygen_basic_translate_style2
+
+%include "doxygen_basic_translate.h"
+
+// This test demonstrates a doxygen comment style that starts on the
+// first line and so uses extra spacing in subsequent lines.
+
+%inline %{
+
+/** \brief
+ *  Brief description.
+ * 
+ *  The comment text.
+ *
+ *  \author Some author
+ *
+ *  \return Some number
+ *
+ *  \sa function2
+ */
+int function()
+{
+    return 0;
+}
+
+/** A test of a very very very very very very very very very very very very very very very very
+ *  very very very very very long comment string.
+ */
+void function2()
+{
+}
+
+/** A test for overloaded functions
+ *  This is function \b one
+ */
+void function3(int a)
+{
+}
+
+/** A test for overloaded functions
+ *  This is function \b two
+ */
+void function3(int a, int b)
+{
+}
+
+/** A test of some mixed tag usage
+ *  \if CONDITION
+ *  This \a code fragment shows us something \.
+ *  \par Minuses:
+ *  \arg it's senseless
+ *  \arg it's stupid
+ *  \arg it's null
+ *
+ *  \warning This may not work as expected
+ *  \code
+ *  int main() { while(true); }
+ *
+ *  // Test blank line in code block
+ *  \endcode
+ *  \endif
+ */
+void function4()
+{
+}
+
+
+void function5(int a)
+{
+}
+/**< This is a post comment. */
+
+/** Test for default args
+ *  @param a Some parameter, default is 42
+ */
+void function6(int a=42)
+{
+}
+
+class Shape
+{
+public:
+  typedef Shape* superType;
+};
+
+/** Test for a parameter with difficult type
+ *  (mostly for python)
+ *  @param a Very strange param
+ */
+void function7(Shape::superType *a[10])
+{
+}
+
+/** Multiple parameters test.
+ *
+ *  @param y Vertical coordinate.
+ *  @param x Horizontal coordinate.
+ *  @return Arc tangent of @c y/x.
+ */
+double Atan2(double y, double x)
+{
+    return 0;
+}
+
+/** Comment at the end of file should be ignored.
+ */
+%}
diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i
index 6e96a57..8da683d 100644
--- a/Examples/test-suite/doxygen_translate_all_tags.i
+++ b/Examples/test-suite/doxygen_translate_all_tags.i
@@ -38,6 +38,10 @@
  * \cite citationword
  * \class someClass headerFile.h headerName
  * \code some test code \endcode
+ *
+ * Code immediately following text.  Pydoc translation must add an
+ * empty line before:
+ * \code more test code \endcode
  */
 void func01(int a)
 {
@@ -121,6 +125,12 @@
  *     \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
  * \f}
  *
+ * Math immediately following text.  Pydoc translation must add an
+ * empty line before:
+ * \f[
+ *     \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
+ * \f]
+ *
  * \file file.h
  *
  * \fn someFn
diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in
index 10e5bdd..7137a68 100644
--- a/Examples/test-suite/errors/Makefile.in
+++ b/Examples/test-suite/errors/Makefile.in
@@ -45,6 +45,11 @@
 # whatever we do here.
 $(DOXYGEN_ERROR_TEST_CASES): SWIGOPT += -doxygen
 
+# Unique module names are obtained from the .i file name (required for parallel make).
+# Note: -module overrides %module in the .i file.
+MODULE_OPTION=-module $*
+nomodule.ctest: MODULE_OPTION =
+
 # Portable dos2unix / todos for stripping CR
 TODOS        = tr -d '\r'
 #TODOS        = sed -e 's/\r$$//' # On Mac OS X behaves as if written 's/r$$//'
@@ -55,12 +60,12 @@
 # Rules for the different types of tests
 %.cpptest:
 	echo "$(ACTION)ing errors testcase $*"
-	-$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+	-$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
 	$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
 
 %.ctest:
 	echo "$(ACTION)ing errors testcase $*"
-	-$(SWIGINVOKE) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+	-$(SWIGINVOKE) -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
 	$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
 
 %.clean:
diff --git a/Examples/test-suite/errors/cpp_extra_brackets.i b/Examples/test-suite/errors/cpp_extra_brackets.i
index 32cf7f7..81fdb29 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets.i
+++ b/Examples/test-suite/errors/cpp_extra_brackets.i
@@ -1,4 +1,4 @@
-%module cpp_extra_brackets
+%module xxx
 
 // Extra brackets was segfaulting in SWIG-3.0.0
 struct ABC {
diff --git a/Examples/test-suite/errors/cpp_extra_brackets2.i b/Examples/test-suite/errors/cpp_extra_brackets2.i
index 17a5d59..194dea4 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets2.i
+++ b/Examples/test-suite/errors/cpp_extra_brackets2.i
@@ -1,4 +1,4 @@
-%module cpp_extra_brackets
+%module xxx
 
 // Extra brackets was segfaulting in SWIG-3.0.0
 struct ABC {
diff --git a/Examples/test-suite/errors/cpp_invalid_qualifiers.i b/Examples/test-suite/errors/cpp_invalid_qualifiers.i
index fd3b363..d0723df 100644
--- a/Examples/test-suite/errors/cpp_invalid_qualifiers.i
+++ b/Examples/test-suite/errors/cpp_invalid_qualifiers.i
@@ -1,4 +1,4 @@
-%module cpp_invalid_qualifiers
+%module xxx
 
 // Constructors, destructors and static methods cannot have qualifiers
 struct A {
diff --git a/Examples/test-suite/errors/cpp_invalid_template.i b/Examples/test-suite/errors/cpp_invalid_template.i
index ea0d7be..45ad739 100644
--- a/Examples/test-suite/errors/cpp_invalid_template.i
+++ b/Examples/test-suite/errors/cpp_invalid_template.i
@@ -1,4 +1,4 @@
-%module cpp_invalid_scope
+%module xxx
 
 %template(abc) SSS::AAA<int>;
 
diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.i b/Examples/test-suite/errors/cpp_namespace_template_bad.i
index 5c42d6d..f41918f 100644
--- a/Examples/test-suite/errors/cpp_namespace_template_bad.i
+++ b/Examples/test-suite/errors/cpp_namespace_template_bad.i
@@ -1,4 +1,4 @@
-%module namespace_template
+%module xxx
 
 namespace test {
   template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
diff --git a/Examples/test-suite/errors/cpp_nested_namespace_alias.i b/Examples/test-suite/errors/cpp_nested_namespace_alias.i
index b7cbceb..058d344 100644
--- a/Examples/test-suite/errors/cpp_nested_namespace_alias.i
+++ b/Examples/test-suite/errors/cpp_nested_namespace_alias.i
@@ -1,4 +1,4 @@
-%module cpp_nested_namespace_alias
+%module xxx
 
 // C++17 nested namespaces
 
diff --git a/Examples/test-suite/errors/cpp_recursive_typedef.i b/Examples/test-suite/errors/cpp_recursive_typedef.i
index 3d65a88..82d9f7a 100644
--- a/Examples/test-suite/errors/cpp_recursive_typedef.i
+++ b/Examples/test-suite/errors/cpp_recursive_typedef.i
@@ -1,4 +1,4 @@
-%module cpp_recursive_typedef
+%module xxx
 
 typedef std::set<pds> pds;
 
diff --git a/Examples/test-suite/errors/cpp_refqualifier.i b/Examples/test-suite/errors/cpp_refqualifier.i
index afd6632..3980a81 100644
--- a/Examples/test-suite/errors/cpp_refqualifier.i
+++ b/Examples/test-suite/errors/cpp_refqualifier.i
@@ -1,4 +1,4 @@
-%module cpp_refqualifier
+%module xxx
 
 %ignore Host::h_ignored;
 %ignore Host::i_ignored() &&;
diff --git a/Examples/test-suite/errors/cpp_shared_ptr.i b/Examples/test-suite/errors/cpp_shared_ptr.i
index edbd0cf..bdcd30f 100644
--- a/Examples/test-suite/errors/cpp_shared_ptr.i
+++ b/Examples/test-suite/errors/cpp_shared_ptr.i
@@ -1,4 +1,4 @@
-%module cpp_shared_ptr
+%module xxx
 
 %include <boost_shared_ptr.i>
 
diff --git a/Examples/test-suite/errors/cpp_template_duplicate_names.i b/Examples/test-suite/errors/cpp_template_duplicate_names.i
index 67f21d7..9607696 100644
--- a/Examples/test-suite/errors/cpp_template_duplicate_names.i
+++ b/Examples/test-suite/errors/cpp_template_duplicate_names.i
@@ -1,4 +1,4 @@
-%module cpp_template_duplicate_names
+%module xxx
 
 // From test-suite/template_class_reuse.i test
 
diff --git a/Examples/test-suite/errors/cpp_template_friend.i b/Examples/test-suite/errors/cpp_template_friend.i
index c9d1c9d..3b8d85e 100644
--- a/Examples/test-suite/errors/cpp_template_friend.i
+++ b/Examples/test-suite/errors/cpp_template_friend.i
@@ -1,4 +1,4 @@
-%module cpp_template_friend
+%module xxx
 
 template<typename T> T template_friend1(T);
 template<typename T> T template_friend1(T);
diff --git a/Examples/test-suite/errors/pp_missing_file.i b/Examples/test-suite/errors/pp_missing_file.i
index 5e3f0ea..366f159 100644
--- a/Examples/test-suite/errors/pp_missing_file.i
+++ b/Examples/test-suite/errors/pp_missing_file.i
@@ -1,3 +1,3 @@
-%module test
+%module xxx
 
 %include "missing_filename.i"
diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in
index d07a56b..8283327 100644
--- a/Examples/test-suite/go/Makefile.in
+++ b/Examples/test-suite/go/Makefile.in
@@ -6,24 +6,10 @@
 GO		= @GO@
 GOGCC		= @GOGCC@
 GCCGO		= @GCCGO@
-GO1		= @GO1@
-GO12		= @GO12@
-GO13		= @GO13@
-GO15		= @GO15@
-GOC		= @GOC@
 GOVERSIONOPTION	= @GOVERSIONOPTION@
 host		= @host@
 SCRIPTSUFFIX	= _runme.go
 
-GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1); then echo tool $(GOC:c=g); fi`
-GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi`
-GOTOOL = `if $(GO1) ; then echo go tool; fi`
-GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
-
-GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
-
-OSXOLDGOLINKFLAGS	= `if [ -n "\`$(GO) $(GOVERSIONOPTION) | grep -E 'go1($|.0|.1|.2|.3)'\`" ] && [ -n "\`echo $(host) | grep darwin\`" ]; then echo "-Wl,-U,__cgo_topofstack"; fi`
-
 SO = @SO@
 
 srcdir         = @srcdir@
@@ -49,27 +35,11 @@
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase_cpp)
-	if ! $(GO15); then \
-	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
-	  SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
-	  INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
-	  TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
-	  $(LANGUAGE)$(VARIANT)_cpp_nocgo && \
-	  $(run_testcase_cpp); \
-	fi
 
 %.ctest:
 	$(setup)
 	+$(swig_and_compile_c)
 	$(run_testcase)
-	if ! $(GO15); then \
-	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CSRCS='$(CSRCS)' \
-	  SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
-	  INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
-	  TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
-	  $(LANGUAGE)$(VARIANT)_nocgo && \
-	  $(run_testcase); \
-	fi
 
 %.multicpptest:
 	$(setup)
@@ -136,54 +106,66 @@
 # Runs the testcase.
 run_testcase = \
 	if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
-	  if $(GOGCC) ; then \
-	    $(COMPILETOOL) $(GCCGO) -c -g -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
-	    $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ gopath/src/$*/$*.a; \
-	  elif $(GO12) || $(GO13) || $(GO15); then \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -L gopath/src/$* -linkmode external -extld $(CC) -extldflags "$(CFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
-	  else \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
-	  fi && \
+	  GOPATH=`pwd`/gopath/; \
+	  export GOPATH; \
+	  CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
+	  export CGO_CPPFLAGS; \
+	  CGO_CFLAGS="$(CFLAGS)"; \
+	  export CGO_CFLAGS; \
+	  CGO_CXXFLAGS="$(CXXFLAGS)"; \
+	  export CGO_CXXFLAGS; \
+	  CGO_LDFLAGS="$(LDFLAGS) -lm"; \
+	  export CGO_LDFLAGS; \
+	  mkdir gopath/src/swigtests 2>/dev/null || true; \
+	  mkdir gopath/src/swigtests/$* 2>/dev/null || true; \
+	  cp gopath/src/$*/* gopath/src/swigtests/$*/; \
+	  mkdir gopath/src/$*/runme 2>/dev/null || true; \
+	  cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/src/$*/runme/runme.go; \
+	  (cd gopath/src/$*/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme runme.go); \
+	  cp gopath/src/$*/runme/runme $*_runme; \
 	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
 	fi
 
 run_testcase_cpp = \
 	if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
-	  if $(GOGCC) ; then \
-	    $(COMPILETOOL) $(GCCGO) -c -g -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
-	    $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ gopath/src/$*/$*.a -lstdc++; \
-	  elif $(GO12) || $(GO13) || $(GO15); then \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -L gopath/src/$* -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
-	  else \
-	    $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
-	  fi && \
+	  GOPATH=`pwd`/gopath/; \
+	  export GOPATH; \
+	  CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
+	  export CGO_CPPFLAGS; \
+	  CGO_CFLAGS="$(CFLAGS)"; \
+	  export CGO_CFLAGS; \
+	  CGO_CXXFLAGS="$(CXXFLAGS)"; \
+	  export CGO_CXXFLAGS; \
+	  CGO_LDFLAGS="$(LDFLAGS) -lm"; \
+	  export CGO_LDFLAGS; \
+	  mkdir gopath/src/swigtests 2>/dev/null || true; \
+	  mkdir gopath/src/swigtests/$* 2>/dev/null || true; \
+	  cp gopath/src/$*/* gopath/src/swigtests/$*/; \
+	  mkdir gopath/src/$*/runme 2>/dev/null || true; \
+	  cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/src/$*/runme/runme.go; \
+	  (cd gopath/src/$*/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme runme.go); \
+	  cp gopath/src/$*/runme/runme $*_runme; \
 	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
 	fi
 
 run_multi_testcase = \
 	if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
-	  if $(GO15) || $(GOGCC); then \
-	    files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
-	    mkdir gopath/$*/src/$* 2>/dev/null || true; \
-	    cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/$*/src/$*; \
-	    GOPATH="`pwd`/gopath/$*"; \
-	    export GOPATH; \
-	    CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) `for f in $$files; do echo -I ../$$f; done`"; \
-	    export CGO_CPPFLAGS; \
-	    CGO_CFLAGS="$(CFLAGS)"; \
-	    export CGO_CFLAGS; \
-	    CGO_CXXFLAGS="$(CXXFLAGS)"; \
-	    export CGO_CXXFLAGS; \
-	    CGO_LDFLAGS="$(LDFLAGS) -lm"; \
-	    export CGO_LDFLAGS; \
-	    (cd gopath/$*/src/$* && \
-	      $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o ../../../../$*_runme) && \
-	    env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
-	  fi; \
+	  files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
+	  mkdir gopath/$*/src/$* 2>/dev/null || true; \
+	  cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/$*/src/$*; \
+	  GOPATH="`pwd`/gopath/$*"; \
+	  export GOPATH; \
+	  CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) `for f in $$files; do echo -I ../$$f; done`"; \
+	  export CGO_CPPFLAGS; \
+	  CGO_CFLAGS="$(CFLAGS)"; \
+	  export CGO_CFLAGS; \
+	  CGO_CXXFLAGS="$(CXXFLAGS)"; \
+	  export CGO_CXXFLAGS; \
+	  CGO_LDFLAGS="$(LDFLAGS) -lm"; \
+	  export CGO_LDFLAGS; \
+	  (cd gopath/$*/src/$* && \
+	    $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o ../../../../$*_runme) && \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
 	fi
 
 %.clean:
diff --git a/Examples/test-suite/go/abstract_access_runme.go b/Examples/test-suite/go/abstract_access_runme.go
index 5102236..0a0e56f 100644
--- a/Examples/test-suite/go/abstract_access_runme.go
+++ b/Examples/test-suite/go/abstract_access_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "abstract_access"
+import "swigtests/abstract_access"
 
 func main() {
 	d := abstract_access.NewD()
diff --git a/Examples/test-suite/go/abstract_typedef2_runme.go b/Examples/test-suite/go/abstract_typedef2_runme.go
index 76a5fc8..5e2ed1e 100644
--- a/Examples/test-suite/go/abstract_typedef2_runme.go
+++ b/Examples/test-suite/go/abstract_typedef2_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "abstract_typedef2"
+import "swigtests/abstract_typedef2"
 
 func main() {
 	abstract_typedef2.NewA_UF()
diff --git a/Examples/test-suite/go/abstract_typedef_runme.go b/Examples/test-suite/go/abstract_typedef_runme.go
index 56aaa61..1ad49f5 100644
--- a/Examples/test-suite/go/abstract_typedef_runme.go
+++ b/Examples/test-suite/go/abstract_typedef_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "abstract_typedef"
+import "swigtests/abstract_typedef"
 
 func main() {
 	e := abstract_typedef.NewEngine()
diff --git a/Examples/test-suite/go/abstract_virtual_runme.go b/Examples/test-suite/go/abstract_virtual_runme.go
index e19eac2..d333d50 100644
--- a/Examples/test-suite/go/abstract_virtual_runme.go
+++ b/Examples/test-suite/go/abstract_virtual_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "abstract_virtual"
+import "swigtests/abstract_virtual"
 
 func main() {
 	abstract_virtual.NewD()
diff --git a/Examples/test-suite/go/argout_runme.go b/Examples/test-suite/go/argout_runme.go
index bb8ab9e..b2edf54 100644
--- a/Examples/test-suite/go/argout_runme.go
+++ b/Examples/test-suite/go/argout_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import wrap "argout"
+import wrap "swigtests/argout"
 
 func main() {
 	ip := wrap.New_intp()
diff --git a/Examples/test-suite/go/array_member_runme.go b/Examples/test-suite/go/array_member_runme.go
index 4f029db..d8c3896 100644
--- a/Examples/test-suite/go/array_member_runme.go
+++ b/Examples/test-suite/go/array_member_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "array_member"
+import . "swigtests/array_member"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/arrays_global_runme.go b/Examples/test-suite/go/arrays_global_runme.go
index 35b049d..9c4a9e5 100644
--- a/Examples/test-suite/go/arrays_global_runme.go
+++ b/Examples/test-suite/go/arrays_global_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "arrays_global"
+import . "swigtests/arrays_global"
 
 func main() {
 	SetArray_i(GetArray_const_i())
diff --git a/Examples/test-suite/go/char_binary_runme.go b/Examples/test-suite/go/char_binary_runme.go
index d47d616..3c8c2d7 100644
--- a/Examples/test-suite/go/char_binary_runme.go
+++ b/Examples/test-suite/go/char_binary_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "char_binary"
+import . "swigtests/char_binary"
 
 func main() {
 	t := NewTest()
diff --git a/Examples/test-suite/go/class_ignore_runme.go b/Examples/test-suite/go/class_ignore_runme.go
index 24261c6..11cf81d 100644
--- a/Examples/test-suite/go/class_ignore_runme.go
+++ b/Examples/test-suite/go/class_ignore_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "class_ignore"
+import "swigtests/class_ignore"
 
 func main() {
 	a := class_ignore.NewBar()
diff --git a/Examples/test-suite/go/class_scope_weird_runme.go b/Examples/test-suite/go/class_scope_weird_runme.go
index a42bdad..4776990 100644
--- a/Examples/test-suite/go/class_scope_weird_runme.go
+++ b/Examples/test-suite/go/class_scope_weird_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "class_scope_weird"
+import "swigtests/class_scope_weird"
 
 func main() {
 	f := class_scope_weird.NewFoo()
diff --git a/Examples/test-suite/go/compactdefaultargs_runme.go b/Examples/test-suite/go/compactdefaultargs_runme.go
index fe6224c..c9e9008 100644
--- a/Examples/test-suite/go/compactdefaultargs_runme.go
+++ b/Examples/test-suite/go/compactdefaultargs_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "compactdefaultargs"
+import . "swigtests/compactdefaultargs"
 
 func main() {
 	defaults1 := NewDefaults1(1000)
diff --git a/Examples/test-suite/go/constover_runme.go b/Examples/test-suite/go/constover_runme.go
index 6c83709..51d965e 100644
--- a/Examples/test-suite/go/constover_runme.go
+++ b/Examples/test-suite/go/constover_runme.go
@@ -4,7 +4,7 @@
 	"fmt"
 	"os"
 
-	"constover"
+	"swigtests/constover"
 )
 
 func main() {
diff --git a/Examples/test-suite/go/constructor_copy_runme.go b/Examples/test-suite/go/constructor_copy_runme.go
index 68c4288..ca47255 100644
--- a/Examples/test-suite/go/constructor_copy_runme.go
+++ b/Examples/test-suite/go/constructor_copy_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "constructor_copy"
+import . "swigtests/constructor_copy"
 
 func main() {
 	f1 := NewFoo1(3)
diff --git a/Examples/test-suite/go/contract_runme.go b/Examples/test-suite/go/contract_runme.go
index b028855..7c9d097 100644
--- a/Examples/test-suite/go/contract_runme.go
+++ b/Examples/test-suite/go/contract_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "contract"
+import "swigtests/contract"
 
 func main() {
 	contract.Test_preassert(1, 2)
diff --git a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
index f9ca74a..926b6f7 100644
--- a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
+++ b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "fmt"
-import . "cpp11_strongly_typed_enumerations"
+import . "swigtests/cpp11_strongly_typed_enumerations"
 
 func enumCheck(actual int, expected int) int {
 	if actual != expected {
diff --git a/Examples/test-suite/go/cpp_enum_runme.go b/Examples/test-suite/go/cpp_enum_runme.go
index 8906dd4..9b8930a 100644
--- a/Examples/test-suite/go/cpp_enum_runme.go
+++ b/Examples/test-suite/go/cpp_enum_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "cpp_enum"
+import "swigtests/cpp_enum"
 
 func main() {
 	f := cpp_enum.NewFoo()
diff --git a/Examples/test-suite/go/cpp_namespace_runme.go b/Examples/test-suite/go/cpp_namespace_runme.go
index aecdd95..71affc5 100644
--- a/Examples/test-suite/go/cpp_namespace_runme.go
+++ b/Examples/test-suite/go/cpp_namespace_runme.go
@@ -1,7 +1,7 @@
 // Note: This example assumes that namespaces are flattened
 package main
 
-import "cpp_namespace"
+import "swigtests/cpp_namespace"
 
 func main() {
 	n := cpp_namespace.Fact(4)
diff --git a/Examples/test-suite/go/cpp_static_runme.go b/Examples/test-suite/go/cpp_static_runme.go
index 1ad981a6..d482298 100644
--- a/Examples/test-suite/go/cpp_static_runme.go
+++ b/Examples/test-suite/go/cpp_static_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "cpp_static"
+import . "swigtests/cpp_static"
 
 func main() {
 	StaticFunctionTestStatic_func()
diff --git a/Examples/test-suite/go/default_args_runme.go b/Examples/test-suite/go/default_args_runme.go
index a39f957..5b6f404 100644
--- a/Examples/test-suite/go/default_args_runme.go
+++ b/Examples/test-suite/go/default_args_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "default_args"
+import "swigtests/default_args"
 
 func main() {
 	if default_args.StaticsStaticmethod() != 60 {
diff --git a/Examples/test-suite/go/default_constructor_runme.go b/Examples/test-suite/go/default_constructor_runme.go
index eeac7ea..90d9601 100644
--- a/Examples/test-suite/go/default_constructor_runme.go
+++ b/Examples/test-suite/go/default_constructor_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import dc "default_constructor"
+import dc "swigtests/default_constructor"
 
 func main() {
 	a := dc.NewA()
diff --git a/Examples/test-suite/go/director_alternating_runme.go b/Examples/test-suite/go/director_alternating_runme.go
index b4793aa..2df31db 100644
--- a/Examples/test-suite/go/director_alternating_runme.go
+++ b/Examples/test-suite/go/director_alternating_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_alternating"
+import . "swigtests/director_alternating"
 
 func main() {
 	id := GetBar().Id()
diff --git a/Examples/test-suite/go/director_basic_runme.go b/Examples/test-suite/go/director_basic_runme.go
index 360424d..c308f25 100644
--- a/Examples/test-suite/go/director_basic_runme.go
+++ b/Examples/test-suite/go/director_basic_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "director_basic"
+import "swigtests/director_basic"
 
 type GoFoo struct{}
 
diff --git a/Examples/test-suite/go/director_classic_runme.go b/Examples/test-suite/go/director_classic_runme.go
index 230c963..d8acc13 100644
--- a/Examples/test-suite/go/director_classic_runme.go
+++ b/Examples/test-suite/go/director_classic_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "fmt"
-import . "director_classic"
+import . "swigtests/director_classic"
 
 type TargetLangPerson struct{} // From Person
 func (p *TargetLangPerson) Id() string {
diff --git a/Examples/test-suite/go/director_default_runme.go b/Examples/test-suite/go/director_default_runme.go
index ac2aace..557d5c5 100644
--- a/Examples/test-suite/go/director_default_runme.go
+++ b/Examples/test-suite/go/director_default_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_default"
+import . "swigtests/director_default"
 
 func main() {
 	NewFoo()
diff --git a/Examples/test-suite/go/director_detect_runme.go b/Examples/test-suite/go/director_detect_runme.go
index 0c3c95f..f82a0c0 100644
--- a/Examples/test-suite/go/director_detect_runme.go
+++ b/Examples/test-suite/go/director_detect_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "director_detect"
+import "swigtests/director_detect"
 
 type MyBar struct {
 	val int
diff --git a/Examples/test-suite/go/director_enum_runme.go b/Examples/test-suite/go/director_enum_runme.go
index 002d425..3e67417 100644
--- a/Examples/test-suite/go/director_enum_runme.go
+++ b/Examples/test-suite/go/director_enum_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "director_enum"
+import "swigtests/director_enum"
 
 type MyFoo struct{} // From director_enum.Foo
 func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello {
diff --git a/Examples/test-suite/go/director_exception_runme.go b/Examples/test-suite/go/director_exception_runme.go
index 55231ff..167d751 100644
--- a/Examples/test-suite/go/director_exception_runme.go
+++ b/Examples/test-suite/go/director_exception_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_exception"
+import . "swigtests/director_exception"
 
 type Exception struct {
 	msg string
diff --git a/Examples/test-suite/go/director_extend_runme.go b/Examples/test-suite/go/director_extend_runme.go
index 27e55b9..adfb6dd 100644
--- a/Examples/test-suite/go/director_extend_runme.go
+++ b/Examples/test-suite/go/director_extend_runme.go
@@ -5,7 +5,7 @@
 
 package main
 
-import . "director_extend"
+import . "swigtests/director_extend"
 
 func main() {
 	m := NewSpObject()
diff --git a/Examples/test-suite/go/director_finalizer_runme.go b/Examples/test-suite/go/director_finalizer_runme.go
index d36a4ba..5cd9d95 100644
--- a/Examples/test-suite/go/director_finalizer_runme.go
+++ b/Examples/test-suite/go/director_finalizer_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_finalizer"
+import . "swigtests/director_finalizer"
 
 type MyFoo struct{} // From Foo
 func DeleteMyFoo(p Foo) {
diff --git a/Examples/test-suite/go/director_frob_runme.go b/Examples/test-suite/go/director_frob_runme.go
index 3985eb1..7354fa7 100644
--- a/Examples/test-suite/go/director_frob_runme.go
+++ b/Examples/test-suite/go/director_frob_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_frob"
+import . "swigtests/director_frob"
 
 func main() {
 	foo := NewBravo()
diff --git a/Examples/test-suite/go/director_nested_runme.go b/Examples/test-suite/go/director_nested_runme.go
index a1193ad..b048935 100644
--- a/Examples/test-suite/go/director_nested_runme.go
+++ b/Examples/test-suite/go/director_nested_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_nested"
+import . "swigtests/director_nested"
 
 type A struct{} // From FooBar_int
 func (p *A) Do_step() string {
diff --git a/Examples/test-suite/go/director_profile_runme.go b/Examples/test-suite/go/director_profile_runme.go
index a9bc793..da0ea21 100644
--- a/Examples/test-suite/go/director_profile_runme.go
+++ b/Examples/test-suite/go/director_profile_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "fmt"
-import "director_profile"
+import "swigtests/director_profile"
 
 type MyB struct{} // From director_profile.B
 func (p *MyB) Vfi(a int) int {
diff --git a/Examples/test-suite/go/director_protected_runme.go b/Examples/test-suite/go/director_protected_runme.go
index bfd50c6..0012ccd 100644
--- a/Examples/test-suite/go/director_protected_runme.go
+++ b/Examples/test-suite/go/director_protected_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_protected"
+import . "swigtests/director_protected"
 
 type FooBar struct{} // From Bar
 func (p *FooBar) Ping() string {
diff --git a/Examples/test-suite/go/director_string_runme.go b/Examples/test-suite/go/director_string_runme.go
index f4f9cc1..0c73b6a 100644
--- a/Examples/test-suite/go/director_string_runme.go
+++ b/Examples/test-suite/go/director_string_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "director_string"
+import . "swigtests/director_string"
 
 type B struct { // From A
 	abi  A
diff --git a/Examples/test-suite/go/director_unroll_runme.go b/Examples/test-suite/go/director_unroll_runme.go
index 6a919f6..560034c 100644
--- a/Examples/test-suite/go/director_unroll_runme.go
+++ b/Examples/test-suite/go/director_unroll_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "director_unroll"
+import "swigtests/director_unroll"
 
 type MyFoo struct{} // From director_unroll.Foo
 func (p *MyFoo) Ping() string {
diff --git a/Examples/test-suite/go/disown_runme.go b/Examples/test-suite/go/disown_runme.go
index 4484515..ba072a8 100644
--- a/Examples/test-suite/go/disown_runme.go
+++ b/Examples/test-suite/go/disown_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "disown"
+import . "swigtests/disown"
 
 func main() {
 	a := NewA()
diff --git a/Examples/test-suite/go/dynamic_cast_runme.go b/Examples/test-suite/go/dynamic_cast_runme.go
index 46ba236..213bc0c 100644
--- a/Examples/test-suite/go/dynamic_cast_runme.go
+++ b/Examples/test-suite/go/dynamic_cast_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "dynamic_cast"
+import "swigtests/dynamic_cast"
 
 func main() {
 	f := dynamic_cast.NewFoo()
diff --git a/Examples/test-suite/go/empty_c_runme.go b/Examples/test-suite/go/empty_c_runme.go
index 1a1bd9c..f093103 100644
--- a/Examples/test-suite/go/empty_c_runme.go
+++ b/Examples/test-suite/go/empty_c_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import _ "empty_c"
+import _ "swigtests/empty_c"
 
 func main() {
 }
diff --git a/Examples/test-suite/go/empty_runme.go b/Examples/test-suite/go/empty_runme.go
index 681a6f3..03f423b 100644
--- a/Examples/test-suite/go/empty_runme.go
+++ b/Examples/test-suite/go/empty_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import _ "empty"
+import _ "swigtests/empty"
 
 func main() {
 }
diff --git a/Examples/test-suite/go/enum_template_runme.go b/Examples/test-suite/go/enum_template_runme.go
index c60a452..7f43eab 100644
--- a/Examples/test-suite/go/enum_template_runme.go
+++ b/Examples/test-suite/go/enum_template_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "enum_template"
+import "swigtests/enum_template"
 
 func main() {
 	if enum_template.MakeETest() != 1 {
diff --git a/Examples/test-suite/go/enums_runme.go b/Examples/test-suite/go/enums_runme.go
index 7a528b3..4a879a0 100644
--- a/Examples/test-suite/go/enums_runme.go
+++ b/Examples/test-suite/go/enums_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "enums"
+import "swigtests/enums"
 
 func main() {
 	enums.Bar2(1)
diff --git a/Examples/test-suite/go/exception_order_runme.go b/Examples/test-suite/go/exception_order_runme.go
index 21dcff3..ee67712 100644
--- a/Examples/test-suite/go/exception_order_runme.go
+++ b/Examples/test-suite/go/exception_order_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "strings"
-import . "exception_order"
+import . "swigtests/exception_order"
 
 func main() {
 	a := NewA()
diff --git a/Examples/test-suite/go/extend_placement_runme.go b/Examples/test-suite/go/extend_placement_runme.go
index 253ec66..8795896 100644
--- a/Examples/test-suite/go/extend_placement_runme.go
+++ b/Examples/test-suite/go/extend_placement_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "extend_placement"
+import "swigtests/extend_placement"
 
 func main() {
 	foo := extend_placement.NewFoo()
diff --git a/Examples/test-suite/go/extend_template_ns_runme.go b/Examples/test-suite/go/extend_template_ns_runme.go
index d005172..b1dd43a 100644
--- a/Examples/test-suite/go/extend_template_ns_runme.go
+++ b/Examples/test-suite/go/extend_template_ns_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "extend_template_ns"
+import . "swigtests/extend_template_ns"
 
 func main() {
 	f := NewFoo_One()
diff --git a/Examples/test-suite/go/extend_template_runme.go b/Examples/test-suite/go/extend_template_runme.go
index a5c4da4..4a6b709 100644
--- a/Examples/test-suite/go/extend_template_runme.go
+++ b/Examples/test-suite/go/extend_template_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "extend_template"
+import "swigtests/extend_template"
 
 func main() {
 	f := extend_template.NewFoo_0()
diff --git a/Examples/test-suite/go/extend_variable_runme.go b/Examples/test-suite/go/extend_variable_runme.go
index 9425aee..278bffe 100644
--- a/Examples/test-suite/go/extend_variable_runme.go
+++ b/Examples/test-suite/go/extend_variable_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "extend_variable"
+import . "swigtests/extend_variable"
 
 func main() {
 	if FooBar != 42 {
diff --git a/Examples/test-suite/go/extern_c_runme.go b/Examples/test-suite/go/extern_c_runme.go
index 9bc2cd0..1cbfd9d 100644
--- a/Examples/test-suite/go/extern_c_runme.go
+++ b/Examples/test-suite/go/extern_c_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "extern_c"
+import "swigtests/extern_c"
 
 func main() {
 	extern_c.RealFunction(2)
diff --git a/Examples/test-suite/go/friends_runme.go b/Examples/test-suite/go/friends_runme.go
index 2e34a4d..b6b9e93 100644
--- a/Examples/test-suite/go/friends_runme.go
+++ b/Examples/test-suite/go/friends_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "friends"
+import "swigtests/friends"
 
 func main() {
 	a := friends.NewA(2)
diff --git a/Examples/test-suite/go/fvirtual_runme.go b/Examples/test-suite/go/fvirtual_runme.go
index 86ef90f..01b94f4 100644
--- a/Examples/test-suite/go/fvirtual_runme.go
+++ b/Examples/test-suite/go/fvirtual_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "fvirtual"
+import . "swigtests/fvirtual"
 
 func main() {
 	sw := NewNodeSwitch()
diff --git a/Examples/test-suite/go/global_ns_arg_runme.go b/Examples/test-suite/go/global_ns_arg_runme.go
index e86aa67..aeacd91 100644
--- a/Examples/test-suite/go/global_ns_arg_runme.go
+++ b/Examples/test-suite/go/global_ns_arg_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "global_ns_arg"
+import . "swigtests/global_ns_arg"
 
 func main() {
 	Foo(1)
diff --git a/Examples/test-suite/go/go_director_inout_runme.go b/Examples/test-suite/go/go_director_inout_runme.go
index e6768a4..171b3c2 100644
--- a/Examples/test-suite/go/go_director_inout_runme.go
+++ b/Examples/test-suite/go/go_director_inout_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import (
-	wrap "go_director_inout"
+	wrap "swigtests/go_director_inout"
 )
 
 type GoMyClass struct {}
diff --git a/Examples/test-suite/go/go_inout_runme.go b/Examples/test-suite/go/go_inout_runme.go
index 4599aa1..2dc5b99 100644
--- a/Examples/test-suite/go/go_inout_runme.go
+++ b/Examples/test-suite/go/go_inout_runme.go
@@ -5,7 +5,7 @@
 	"fmt"
 	"reflect"
 
-	"go_inout"
+	"swigtests/go_inout"
 )
 
 type S struct {
diff --git a/Examples/test-suite/go/grouping_runme.go b/Examples/test-suite/go/grouping_runme.go
index f808e12..d5f3475 100644
--- a/Examples/test-suite/go/grouping_runme.go
+++ b/Examples/test-suite/go/grouping_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "grouping"
+import "swigtests/grouping"
 
 func main() {
 	x := grouping.Test1(42)
diff --git a/Examples/test-suite/go/import_nomodule_runme.go b/Examples/test-suite/go/import_nomodule_runme.go
index 48592df..2368015 100644
--- a/Examples/test-suite/go/import_nomodule_runme.go
+++ b/Examples/test-suite/go/import_nomodule_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "import_nomodule"
+import . "swigtests/import_nomodule"
 
 func main() {
 	f := Create_Foo()
diff --git a/Examples/test-suite/go/inctest_runme.go b/Examples/test-suite/go/inctest_runme.go
index 3148abc..490721e 100644
--- a/Examples/test-suite/go/inctest_runme.go
+++ b/Examples/test-suite/go/inctest_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "inctest"
+import "swigtests/inctest"
 
 func main() {
 	inctest.NewA()
diff --git a/Examples/test-suite/go/inherit_member_runme.go b/Examples/test-suite/go/inherit_member_runme.go
index 6fd70cf..10dabad 100644
--- a/Examples/test-suite/go/inherit_member_runme.go
+++ b/Examples/test-suite/go/inherit_member_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import wrap "inherit_member"
+import wrap "swigtests/inherit_member"
 
 func main() {
 	s := wrap.NewChild()
diff --git a/Examples/test-suite/go/inherit_missing_runme.go b/Examples/test-suite/go/inherit_missing_runme.go
index c70c483..b4706e9 100644
--- a/Examples/test-suite/go/inherit_missing_runme.go
+++ b/Examples/test-suite/go/inherit_missing_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "inherit_missing"
+import "swigtests/inherit_missing"
 
 func main() {
 	a := inherit_missing.New_Foo()
diff --git a/Examples/test-suite/go/input_runme.go b/Examples/test-suite/go/input_runme.go
index ddc2992..c5eb9e4 100644
--- a/Examples/test-suite/go/input_runme.go
+++ b/Examples/test-suite/go/input_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "input"
+import . "swigtests/input"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/keyword_rename_c_runme.go b/Examples/test-suite/go/keyword_rename_c_runme.go
index 26f2ea4..28f6ddd 100644
--- a/Examples/test-suite/go/keyword_rename_c_runme.go
+++ b/Examples/test-suite/go/keyword_rename_c_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "keyword_rename_c"
+import "swigtests/keyword_rename_c"
 
 func main() {
 	keyword_rename_c.Xgo(1)
diff --git a/Examples/test-suite/go/keyword_rename_runme.go b/Examples/test-suite/go/keyword_rename_runme.go
index 7a40ff8..f93c7ab 100644
--- a/Examples/test-suite/go/keyword_rename_runme.go
+++ b/Examples/test-suite/go/keyword_rename_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "keyword_rename"
+import "swigtests/keyword_rename"
 
 func main() {
 	keyword_rename.Xgo(1)
diff --git a/Examples/test-suite/go/li_attribute_runme.go b/Examples/test-suite/go/li_attribute_runme.go
index b502b8c..0702b89 100644
--- a/Examples/test-suite/go/li_attribute_runme.go
+++ b/Examples/test-suite/go/li_attribute_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "li_attribute"
+import "swigtests/li_attribute"
 
 func main() {
 	aa := li_attribute.NewA(1, 2, 3)
diff --git a/Examples/test-suite/go/li_carrays_cpp_runme.go b/Examples/test-suite/go/li_carrays_cpp_runme.go
index cfc1712..a96291c 100644
--- a/Examples/test-suite/go/li_carrays_cpp_runme.go
+++ b/Examples/test-suite/go/li_carrays_cpp_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_carrays_cpp"
+import . "swigtests/li_carrays_cpp"
 
 func main() {
 	d := NewDoubleArray(10)
diff --git a/Examples/test-suite/go/li_carrays_runme.go b/Examples/test-suite/go/li_carrays_runme.go
index 9128bbf..eefc6ad 100644
--- a/Examples/test-suite/go/li_carrays_runme.go
+++ b/Examples/test-suite/go/li_carrays_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_carrays"
+import . "swigtests/li_carrays"
 
 func main() {
 	d := NewDoubleArray(10)
diff --git a/Examples/test-suite/go/li_cdata_cpp_runme.go b/Examples/test-suite/go/li_cdata_cpp_runme.go
index daa5384..5849c50 100644
--- a/Examples/test-suite/go/li_cdata_cpp_runme.go
+++ b/Examples/test-suite/go/li_cdata_cpp_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_cdata_cpp"
+import . "swigtests/li_cdata_cpp"
 
 func main() {
 	s := "ABC abc"
diff --git a/Examples/test-suite/go/li_cdata_runme.go b/Examples/test-suite/go/li_cdata_runme.go
index 9458dab..0c3e591 100644
--- a/Examples/test-suite/go/li_cdata_runme.go
+++ b/Examples/test-suite/go/li_cdata_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_cdata"
+import . "swigtests/li_cdata"
 
 func main() {
 	s := "ABC abc"
diff --git a/Examples/test-suite/go/li_cmalloc_runme.go b/Examples/test-suite/go/li_cmalloc_runme.go
index 5b9f970..fb1b009 100644
--- a/Examples/test-suite/go/li_cmalloc_runme.go
+++ b/Examples/test-suite/go/li_cmalloc_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_cmalloc"
+import . "swigtests/li_cmalloc"
 
 func main() {
 	p := Malloc_int()
diff --git a/Examples/test-suite/go/li_cpointer_cpp_runme.go b/Examples/test-suite/go/li_cpointer_cpp_runme.go
index 0de57c6..f422b23 100644
--- a/Examples/test-suite/go/li_cpointer_cpp_runme.go
+++ b/Examples/test-suite/go/li_cpointer_cpp_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_cpointer_cpp"
+import . "swigtests/li_cpointer_cpp"
 
 func main() {
 	p := New_intp()
diff --git a/Examples/test-suite/go/li_cpointer_runme.go b/Examples/test-suite/go/li_cpointer_runme.go
index 0fe29e7..1a83bc6 100644
--- a/Examples/test-suite/go/li_cpointer_runme.go
+++ b/Examples/test-suite/go/li_cpointer_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_cpointer"
+import . "swigtests/li_cpointer"
 
 func main() {
 	p := New_intp()
diff --git a/Examples/test-suite/go/li_std_map_runme.go b/Examples/test-suite/go/li_std_map_runme.go
index 5c5cc2e..019ac6e 100644
--- a/Examples/test-suite/go/li_std_map_runme.go
+++ b/Examples/test-suite/go/li_std_map_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "li_std_map"
+import "swigtests/li_std_map"
 
 func main() {
 	a1 := li_std_map.NewA(3)
diff --git a/Examples/test-suite/go/li_std_vector_ptr_runme.go b/Examples/test-suite/go/li_std_vector_ptr_runme.go
index d66ff19..9a62d37 100644
--- a/Examples/test-suite/go/li_std_vector_ptr_runme.go
+++ b/Examples/test-suite/go/li_std_vector_ptr_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "li_std_vector_ptr"
+import . "swigtests/li_std_vector_ptr"
 import "fmt"
 
 func check(val1 int, val2 int) {
diff --git a/Examples/test-suite/go/member_pointer_runme.go b/Examples/test-suite/go/member_pointer_runme.go
index 731526b..0278938 100644
--- a/Examples/test-suite/go/member_pointer_runme.go
+++ b/Examples/test-suite/go/member_pointer_runme.go
@@ -3,7 +3,7 @@
 package main
 
 import "fmt"
-import . "member_pointer"
+import . "swigtests/member_pointer"
 
 func check(what string, expected float64, actual float64) {
 	if expected != actual {
diff --git a/Examples/test-suite/go/memberin_extend_c_runme.go b/Examples/test-suite/go/memberin_extend_c_runme.go
index 0551acc..696f08a 100644
--- a/Examples/test-suite/go/memberin_extend_c_runme.go
+++ b/Examples/test-suite/go/memberin_extend_c_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "memberin_extend_c"
+import "swigtests/memberin_extend_c"
 
 func main() {
 	t := memberin_extend_c.NewPerson()
diff --git a/Examples/test-suite/go/minherit_runme.go b/Examples/test-suite/go/minherit_runme.go
index 9b7873c..f1504af 100644
--- a/Examples/test-suite/go/minherit_runme.go
+++ b/Examples/test-suite/go/minherit_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "fmt"
-import "minherit"
+import "swigtests/minherit"
 
 func main() {
 	a := minherit.NewFoo()
diff --git a/Examples/test-suite/go/namespace_class_runme.go b/Examples/test-suite/go/namespace_class_runme.go
index 4c240b6..435ee86 100644
--- a/Examples/test-suite/go/namespace_class_runme.go
+++ b/Examples/test-suite/go/namespace_class_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "namespace_class"
+import . "swigtests/namespace_class"
 
 func main() {
 	EulerT3DToFrame(1, 1, 1)
diff --git a/Examples/test-suite/go/namespace_typemap_runme.go b/Examples/test-suite/go/namespace_typemap_runme.go
index 47e2b64..6da4333 100644
--- a/Examples/test-suite/go/namespace_typemap_runme.go
+++ b/Examples/test-suite/go/namespace_typemap_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "namespace_typemap"
+import . "swigtests/namespace_typemap"
 
 func main() {
 	if Stest1("hello") != "hello" {
diff --git a/Examples/test-suite/go/namespace_virtual_method_runme.go b/Examples/test-suite/go/namespace_virtual_method_runme.go
index a8cb38b..7ac4d33 100644
--- a/Examples/test-suite/go/namespace_virtual_method_runme.go
+++ b/Examples/test-suite/go/namespace_virtual_method_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "namespace_virtual_method"
+import "swigtests/namespace_virtual_method"
 
 func main() {
 	_ = namespace_virtual_method.NewSpam()
diff --git a/Examples/test-suite/go/naturalvar_runme.go b/Examples/test-suite/go/naturalvar_runme.go
index ed47e9d..458745e 100644
--- a/Examples/test-suite/go/naturalvar_runme.go
+++ b/Examples/test-suite/go/naturalvar_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "naturalvar"
+import . "swigtests/naturalvar"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/nested_workaround_runme.go b/Examples/test-suite/go/nested_workaround_runme.go
index 8b31a7f..f42b487 100644
--- a/Examples/test-suite/go/nested_workaround_runme.go
+++ b/Examples/test-suite/go/nested_workaround_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "nested_workaround"
+import . "swigtests/nested_workaround"
 
 func main() {
 	inner := NewInner(5)
diff --git a/Examples/test-suite/go/overload_complicated_runme.go b/Examples/test-suite/go/overload_complicated_runme.go
index ce9d124..c238d97 100644
--- a/Examples/test-suite/go/overload_complicated_runme.go
+++ b/Examples/test-suite/go/overload_complicated_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "overload_complicated"
+import . "swigtests/overload_complicated"
 
 func main() {
 	var pInt *int
diff --git a/Examples/test-suite/go/overload_copy_runme.go b/Examples/test-suite/go/overload_copy_runme.go
index 55ec4a3..9815d76 100644
--- a/Examples/test-suite/go/overload_copy_runme.go
+++ b/Examples/test-suite/go/overload_copy_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "overload_copy"
+import . "swigtests/overload_copy"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/overload_extend2_runme.go b/Examples/test-suite/go/overload_extend2_runme.go
index db79098..d549098 100644
--- a/Examples/test-suite/go/overload_extend2_runme.go
+++ b/Examples/test-suite/go/overload_extend2_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "overload_extend2"
+import "swigtests/overload_extend2"
 
 func main() {
 	f := overload_extend2.NewFoo()
diff --git a/Examples/test-suite/go/overload_extend_c_runme.go b/Examples/test-suite/go/overload_extend_c_runme.go
index 4d3b2b6..93b91d9 100644
--- a/Examples/test-suite/go/overload_extend_c_runme.go
+++ b/Examples/test-suite/go/overload_extend_c_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "overload_extend_c"
+import "swigtests/overload_extend_c"
 
 func main() {
 	f := overload_extend_c.NewFoo()
diff --git a/Examples/test-suite/go/overload_extend_runme.go b/Examples/test-suite/go/overload_extend_runme.go
index d73d6cf..c1435f3 100644
--- a/Examples/test-suite/go/overload_extend_runme.go
+++ b/Examples/test-suite/go/overload_extend_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "overload_extend"
+import "swigtests/overload_extend"
 
 func main() {
 	f := overload_extend.NewFoo()
diff --git a/Examples/test-suite/go/overload_polymorphic_runme.go b/Examples/test-suite/go/overload_polymorphic_runme.go
index 12b9777..6a4301f 100644
--- a/Examples/test-suite/go/overload_polymorphic_runme.go
+++ b/Examples/test-suite/go/overload_polymorphic_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "overload_polymorphic"
+import "swigtests/overload_polymorphic"
 
 func main(){
 	t := overload_polymorphic.NewDerived()
diff --git a/Examples/test-suite/go/overload_rename_runme.go b/Examples/test-suite/go/overload_rename_runme.go
index 3bd4a69..982b178 100644
--- a/Examples/test-suite/go/overload_rename_runme.go
+++ b/Examples/test-suite/go/overload_rename_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "overload_rename"
+import "swigtests/overload_rename"
 
 func main() {
 	_ = overload_rename.NewFoo(float32(1))
diff --git a/Examples/test-suite/go/overload_simple_runme.go b/Examples/test-suite/go/overload_simple_runme.go
index 3eb859b..23a80bf 100644
--- a/Examples/test-suite/go/overload_simple_runme.go
+++ b/Examples/test-suite/go/overload_simple_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "overload_simple"
+import . "swigtests/overload_simple"
 
 func main() {
 	if Foo(3) != "foo:int" {
diff --git a/Examples/test-suite/go/overload_subtype_runme.go b/Examples/test-suite/go/overload_subtype_runme.go
index 45d5a02..09f7a83 100644
--- a/Examples/test-suite/go/overload_subtype_runme.go
+++ b/Examples/test-suite/go/overload_subtype_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "overload_subtype"
+import . "swigtests/overload_subtype"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go
index 63809c0..3b348f3 100644
--- a/Examples/test-suite/go/overload_template_fast_runme.go
+++ b/Examples/test-suite/go/overload_template_fast_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "overload_template_fast"
+import . "swigtests/overload_template_fast"
 
 func main() {
 	_ = Foo()
diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go
index f3a08ec..b85afb4 100644
--- a/Examples/test-suite/go/overload_template_runme.go
+++ b/Examples/test-suite/go/overload_template_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "overload_template"
+import . "swigtests/overload_template"
 
 func main() {
 	_ = Foo()
diff --git a/Examples/test-suite/go/preproc_runme.go b/Examples/test-suite/go/preproc_runme.go
index 3c55aae..8783054 100644
--- a/Examples/test-suite/go/preproc_runme.go
+++ b/Examples/test-suite/go/preproc_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "preproc"
+import "swigtests/preproc"
 
 func main() {
 	if preproc.GetEndif() != 1 {
diff --git a/Examples/test-suite/go/primitive_ref_runme.go b/Examples/test-suite/go/primitive_ref_runme.go
index a1de2f8..8dcf9f5 100644
--- a/Examples/test-suite/go/primitive_ref_runme.go
+++ b/Examples/test-suite/go/primitive_ref_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "primitive_ref"
+import . "swigtests/primitive_ref"
 
 func main() {
 	if Ref_int(3) != 3 {
diff --git a/Examples/test-suite/go/profiletest_runme.go b/Examples/test-suite/go/profiletest_runme.go
index c2b922b..68509f5 100644
--- a/Examples/test-suite/go/profiletest_runme.go
+++ b/Examples/test-suite/go/profiletest_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "fmt"
-import "profiletest"
+import "swigtests/profiletest"
 
 func main() {
 	a := profiletest.NewA()
diff --git a/Examples/test-suite/go/refcount_runme.go b/Examples/test-suite/go/refcount_runme.go
index 07d4072..76e30dd 100644
--- a/Examples/test-suite/go/refcount_runme.go
+++ b/Examples/test-suite/go/refcount_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "refcount"
+import . "swigtests/refcount"
 
 // very innocent example
 
diff --git a/Examples/test-suite/go/reference_global_vars_runme.go b/Examples/test-suite/go/reference_global_vars_runme.go
index 908358f..f8c1258 100644
--- a/Examples/test-suite/go/reference_global_vars_runme.go
+++ b/Examples/test-suite/go/reference_global_vars_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "reference_global_vars"
+import . "swigtests/reference_global_vars"
 
 func main() {
 	// const class reference variable
diff --git a/Examples/test-suite/go/rename_scope_runme.go b/Examples/test-suite/go/rename_scope_runme.go
index 13bd3f1..4ad7549 100644
--- a/Examples/test-suite/go/rename_scope_runme.go
+++ b/Examples/test-suite/go/rename_scope_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "rename_scope"
+import . "swigtests/rename_scope"
 
 func main() {
 	a := NewNatural_UP()
diff --git a/Examples/test-suite/go/rename_simple_runme.go b/Examples/test-suite/go/rename_simple_runme.go
index bd559ef..efe1edc 100644
--- a/Examples/test-suite/go/rename_simple_runme.go
+++ b/Examples/test-suite/go/rename_simple_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "fmt"
-import . "rename_simple"
+import . "swigtests/rename_simple"
 
 func main() {
 	s := NewNewStruct()
diff --git a/Examples/test-suite/go/rename_strip_encoder_runme.go b/Examples/test-suite/go/rename_strip_encoder_runme.go
index ae67060..74a0dba 100644
--- a/Examples/test-suite/go/rename_strip_encoder_runme.go
+++ b/Examples/test-suite/go/rename_strip_encoder_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "rename_strip_encoder"
+import . "swigtests/rename_strip_encoder"
 
 func main() {
 	_ = NewSomeWidget()
diff --git a/Examples/test-suite/go/ret_by_value_runme.go b/Examples/test-suite/go/ret_by_value_runme.go
index 9659d21..345868d 100644
--- a/Examples/test-suite/go/ret_by_value_runme.go
+++ b/Examples/test-suite/go/ret_by_value_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "ret_by_value"
+import "swigtests/ret_by_value"
 
 func main() {
 	a := ret_by_value.Get_test()
diff --git a/Examples/test-suite/go/return_const_value_runme.go b/Examples/test-suite/go/return_const_value_runme.go
index aadb126..fc6baa2 100644
--- a/Examples/test-suite/go/return_const_value_runme.go
+++ b/Examples/test-suite/go/return_const_value_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "return_const_value"
+import "swigtests/return_const_value"
 
 func main() {
 	p := return_const_value.Foo_ptrGetPtr()
diff --git a/Examples/test-suite/go/smart_pointer_extend_runme.go b/Examples/test-suite/go/smart_pointer_extend_runme.go
index a851e26..f91c9ac 100644
--- a/Examples/test-suite/go/smart_pointer_extend_runme.go
+++ b/Examples/test-suite/go/smart_pointer_extend_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_extend"
+import . "swigtests/smart_pointer_extend"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_member_runme.go b/Examples/test-suite/go/smart_pointer_member_runme.go
index e7fe7c4..ca2ac2c 100644
--- a/Examples/test-suite/go/smart_pointer_member_runme.go
+++ b/Examples/test-suite/go/smart_pointer_member_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "fmt"
-import . "smart_pointer_member"
+import . "swigtests/smart_pointer_member"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_multi_runme.go b/Examples/test-suite/go/smart_pointer_multi_runme.go
index 7c76061..a8ec39f 100644
--- a/Examples/test-suite/go/smart_pointer_multi_runme.go
+++ b/Examples/test-suite/go/smart_pointer_multi_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_multi"
+import . "swigtests/smart_pointer_multi"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go
index e584cf7..6bfd21e 100644
--- a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go
+++ b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_multi_typedef"
+import . "swigtests/smart_pointer_multi_typedef"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_overload_runme.go b/Examples/test-suite/go/smart_pointer_overload_runme.go
index 9481554..c28ce61 100644
--- a/Examples/test-suite/go/smart_pointer_overload_runme.go
+++ b/Examples/test-suite/go/smart_pointer_overload_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_overload"
+import . "swigtests/smart_pointer_overload"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_rename_runme.go b/Examples/test-suite/go/smart_pointer_rename_runme.go
index 44841f5..22c0eb1 100644
--- a/Examples/test-suite/go/smart_pointer_rename_runme.go
+++ b/Examples/test-suite/go/smart_pointer_rename_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_rename"
+import . "swigtests/smart_pointer_rename"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_simple_runme.go b/Examples/test-suite/go/smart_pointer_simple_runme.go
index b468bd2..8a14dcf 100644
--- a/Examples/test-suite/go/smart_pointer_simple_runme.go
+++ b/Examples/test-suite/go/smart_pointer_simple_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_simple"
+import . "swigtests/smart_pointer_simple"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go
index 6d4ea91..8f7102d 100644
--- a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go
+++ b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_templatevariables"
+import . "swigtests/smart_pointer_templatevariables"
 
 func main() {
 	d := NewDiffImContainerPtr_D(Create(1234, 5678))
diff --git a/Examples/test-suite/go/smart_pointer_typedef_runme.go b/Examples/test-suite/go/smart_pointer_typedef_runme.go
index e89a8b1..5468a29 100644
--- a/Examples/test-suite/go/smart_pointer_typedef_runme.go
+++ b/Examples/test-suite/go/smart_pointer_typedef_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "smart_pointer_typedef"
+import . "swigtests/smart_pointer_typedef"
 
 func main() {
 	f := NewFoo()
diff --git a/Examples/test-suite/go/sneaky1_runme.go b/Examples/test-suite/go/sneaky1_runme.go
index 57c7797..c17f0ff 100644
--- a/Examples/test-suite/go/sneaky1_runme.go
+++ b/Examples/test-suite/go/sneaky1_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "sneaky1"
+import "swigtests/sneaky1"
 
 func main() {
 	_ = sneaky1.Add(3, 4)
diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go
index 9338e65..597c487 100644
--- a/Examples/test-suite/go/special_variable_macros_runme.go
+++ b/Examples/test-suite/go/special_variable_macros_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "special_variable_macros"
+import "swigtests/special_variable_macros"
 
 func main() {
 	name := special_variable_macros.NewName()
diff --git a/Examples/test-suite/go/static_const_member_2_runme.go b/Examples/test-suite/go/static_const_member_2_runme.go
index ff8cbbb..7586eb4 100644
--- a/Examples/test-suite/go/static_const_member_2_runme.go
+++ b/Examples/test-suite/go/static_const_member_2_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "static_const_member_2"
+import . "swigtests/static_const_member_2"
 
 func main() {
 	_ = NewTest_int()
diff --git a/Examples/test-suite/go/struct_initialization_runme.go b/Examples/test-suite/go/struct_initialization_runme.go
index a815bd3..d5eb4e9 100644
--- a/Examples/test-suite/go/struct_initialization_runme.go
+++ b/Examples/test-suite/go/struct_initialization_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "struct_initialization"
+import . "swigtests/struct_initialization"
 
 func main() {
 	if GetInstanceC1().GetX() != 10 {
diff --git a/Examples/test-suite/go/struct_rename_runme.go b/Examples/test-suite/go/struct_rename_runme.go
index de99fc3..6d619e0 100644
--- a/Examples/test-suite/go/struct_rename_runme.go
+++ b/Examples/test-suite/go/struct_rename_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "struct_rename"
+import "swigtests/struct_rename"
 
 func main() {
 	_ = struct_rename.NewBar()
diff --git a/Examples/test-suite/go/struct_value_runme.go b/Examples/test-suite/go/struct_value_runme.go
index 3b5e5c1..c43a67a 100644
--- a/Examples/test-suite/go/struct_value_runme.go
+++ b/Examples/test-suite/go/struct_value_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "struct_value"
+import "swigtests/struct_value"
 
 func main() {
 	b := struct_value.NewBar()
diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go
index d67e63f..9558c74 100644
--- a/Examples/test-suite/go/template_default_arg_runme.go
+++ b/Examples/test-suite/go/template_default_arg_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "template_default_arg"
+import "swigtests/template_default_arg"
 
 func main() {
 	helloInt := template_default_arg.NewHello_int()
diff --git a/Examples/test-suite/go/template_extend1_runme.go b/Examples/test-suite/go/template_extend1_runme.go
index 0912fa6..f2469ab 100644
--- a/Examples/test-suite/go/template_extend1_runme.go
+++ b/Examples/test-suite/go/template_extend1_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "template_extend1"
+import "swigtests/template_extend1"
 
 func main() {
 	a := template_extend1.NewLBaz()
diff --git a/Examples/test-suite/go/template_extend2_runme.go b/Examples/test-suite/go/template_extend2_runme.go
index ced3d93..c3669bc 100644
--- a/Examples/test-suite/go/template_extend2_runme.go
+++ b/Examples/test-suite/go/template_extend2_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "template_extend2"
+import "swigtests/template_extend2"
 
 func main() {
 	a := template_extend2.NewLBaz()
diff --git a/Examples/test-suite/go/template_inherit_runme.go b/Examples/test-suite/go/template_inherit_runme.go
index a8d5126..10071b1 100644
--- a/Examples/test-suite/go/template_inherit_runme.go
+++ b/Examples/test-suite/go/template_inherit_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_inherit"
+import . "swigtests/template_inherit"
 
 func main() {
 	a := NewFooInt()
diff --git a/Examples/test-suite/go/template_ns4_runme.go b/Examples/test-suite/go/template_ns4_runme.go
index 6c658ec..c1b356b 100644
--- a/Examples/test-suite/go/template_ns4_runme.go
+++ b/Examples/test-suite/go/template_ns4_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_ns4"
+import . "swigtests/template_ns4"
 
 func main() {
 	d := Make_Class_DD()
diff --git a/Examples/test-suite/go/template_ns_runme.go b/Examples/test-suite/go/template_ns_runme.go
index cfc56fa..e77c17b 100644
--- a/Examples/test-suite/go/template_ns_runme.go
+++ b/Examples/test-suite/go/template_ns_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_ns"
+import . "swigtests/template_ns"
 
 func main() {
 	p1 := NewPairii(2, 3)
diff --git a/Examples/test-suite/go/template_opaque_runme.go b/Examples/test-suite/go/template_opaque_runme.go
index 71701df..b3bf610 100644
--- a/Examples/test-suite/go/template_opaque_runme.go
+++ b/Examples/test-suite/go/template_opaque_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "template_opaque"
+import "swigtests/template_opaque"
 
 func main() {
 	v := template_opaque.NewOpaqueVectorType(int64(10))
diff --git a/Examples/test-suite/go/template_ref_type_runme.go b/Examples/test-suite/go/template_ref_type_runme.go
index a01ce3d..516b6c7 100644
--- a/Examples/test-suite/go/template_ref_type_runme.go
+++ b/Examples/test-suite/go/template_ref_type_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "template_ref_type"
+import "swigtests/template_ref_type"
 
 func main() {
 	xr := template_ref_type.NewXC()
diff --git a/Examples/test-suite/go/template_rename_runme.go b/Examples/test-suite/go/template_rename_runme.go
index 6e04f88..08cf3fb 100644
--- a/Examples/test-suite/go/template_rename_runme.go
+++ b/Examples/test-suite/go/template_rename_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "template_rename"
+import "swigtests/template_rename"
 
 func main() {
 	i := template_rename.NewIFoo()
diff --git a/Examples/test-suite/go/template_static_runme.go b/Examples/test-suite/go/template_static_runme.go
index f10ea78..205813d 100644
--- a/Examples/test-suite/go/template_static_runme.go
+++ b/Examples/test-suite/go/template_static_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_static"
+import . "swigtests/template_static"
 
 func main() {
 	FooBar_double(1)
diff --git a/Examples/test-suite/go/template_tbase_template_runme.go b/Examples/test-suite/go/template_tbase_template_runme.go
index e1c46aa..a483243 100644
--- a/Examples/test-suite/go/template_tbase_template_runme.go
+++ b/Examples/test-suite/go/template_tbase_template_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_tbase_template"
+import . "swigtests/template_tbase_template"
 
 func main() {
 	a := Make_Class_dd()
diff --git a/Examples/test-suite/go/template_type_namespace_runme.go b/Examples/test-suite/go/template_type_namespace_runme.go
index 1356f9b..562fae7 100644
--- a/Examples/test-suite/go/template_type_namespace_runme.go
+++ b/Examples/test-suite/go/template_type_namespace_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_type_namespace"
+import . "swigtests/template_type_namespace"
 
 func main() {
 	if Foo().Get(0) == "" {
diff --git a/Examples/test-suite/go/template_typedef_cplx3_runme.go b/Examples/test-suite/go/template_typedef_cplx3_runme.go
index 0a2b313..52a9bc7 100644
--- a/Examples/test-suite/go/template_typedef_cplx3_runme.go
+++ b/Examples/test-suite/go/template_typedef_cplx3_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_typedef_cplx3"
+import . "swigtests/template_typedef_cplx3"
 
 func main() {
 	// this is OK
diff --git a/Examples/test-suite/go/template_typedef_cplx4_runme.go b/Examples/test-suite/go/template_typedef_cplx4_runme.go
index d8952cf..84347e4 100644
--- a/Examples/test-suite/go/template_typedef_cplx4_runme.go
+++ b/Examples/test-suite/go/template_typedef_cplx4_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "template_typedef_cplx4"
+import . "swigtests/template_typedef_cplx4"
 
 func main() {
 	// this is OK
diff --git a/Examples/test-suite/go/threads_exception_runme.go b/Examples/test-suite/go/threads_exception_runme.go
index e3da1dc..b554f0e 100644
--- a/Examples/test-suite/go/threads_exception_runme.go
+++ b/Examples/test-suite/go/threads_exception_runme.go
@@ -1,7 +1,7 @@
 package main
 
 import "strings"
-import "threads_exception"
+import "swigtests/threads_exception"
 
 func main() {
 	t := threads_exception.NewTest()
diff --git a/Examples/test-suite/go/typedef_class_runme.go b/Examples/test-suite/go/typedef_class_runme.go
index d94126d..157a917 100644
--- a/Examples/test-suite/go/typedef_class_runme.go
+++ b/Examples/test-suite/go/typedef_class_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "typedef_class"
+import "swigtests/typedef_class"
 
 func main() {
 	a := typedef_class.NewRealA()
diff --git a/Examples/test-suite/go/typedef_funcptr_runme.go b/Examples/test-suite/go/typedef_funcptr_runme.go
index 9d55f3f..f76f088 100644
--- a/Examples/test-suite/go/typedef_funcptr_runme.go
+++ b/Examples/test-suite/go/typedef_funcptr_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "typedef_funcptr"
+import . "swigtests/typedef_funcptr"
 
 func main() {
 	a := 100
diff --git a/Examples/test-suite/go/typedef_inherit_runme.go b/Examples/test-suite/go/typedef_inherit_runme.go
index 7a65569..f2dbb32 100644
--- a/Examples/test-suite/go/typedef_inherit_runme.go
+++ b/Examples/test-suite/go/typedef_inherit_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "typedef_inherit"
+import "swigtests/typedef_inherit"
 
 func main() {
 	a := typedef_inherit.NewFoo()
diff --git a/Examples/test-suite/go/typedef_scope_runme.go b/Examples/test-suite/go/typedef_scope_runme.go
index af282b1..9c845bb 100644
--- a/Examples/test-suite/go/typedef_scope_runme.go
+++ b/Examples/test-suite/go/typedef_scope_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "typedef_scope"
+import "swigtests/typedef_scope"
 
 func main() {
 	b := typedef_scope.NewBar()
diff --git a/Examples/test-suite/go/typemap_namespace_runme.go b/Examples/test-suite/go/typemap_namespace_runme.go
index a2880d4..f086080 100644
--- a/Examples/test-suite/go/typemap_namespace_runme.go
+++ b/Examples/test-suite/go/typemap_namespace_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "typemap_namespace"
+import . "swigtests/typemap_namespace"
 
 func main() {
 	if Test1("hello") != "hello" {
diff --git a/Examples/test-suite/go/typemap_ns_using_runme.go b/Examples/test-suite/go/typemap_ns_using_runme.go
index c4c21cf..00e1131 100644
--- a/Examples/test-suite/go/typemap_ns_using_runme.go
+++ b/Examples/test-suite/go/typemap_ns_using_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "typemap_ns_using"
+import "swigtests/typemap_ns_using"
 
 func main() {
 	if typemap_ns_using.Spam(37) != 37 {
diff --git a/Examples/test-suite/go/typemap_out_optimal_runme.go b/Examples/test-suite/go/typemap_out_optimal_runme.go
index 7cc3b38..0cccd97 100644
--- a/Examples/test-suite/go/typemap_out_optimal_runme.go
+++ b/Examples/test-suite/go/typemap_out_optimal_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "typemap_out_optimal"
+import . "swigtests/typemap_out_optimal"
 
 func main() {
 	SetXXDebug(false)
diff --git a/Examples/test-suite/go/typename_runme.go b/Examples/test-suite/go/typename_runme.go
index d166509..1e1696d 100644
--- a/Examples/test-suite/go/typename_runme.go
+++ b/Examples/test-suite/go/typename_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "typename"
+import "swigtests/typename"
 
 func main() {
 	f := typename.NewFoo()
diff --git a/Examples/test-suite/go/unions_runme.go b/Examples/test-suite/go/unions_runme.go
index b76ca5c..6e29811 100644
--- a/Examples/test-suite/go/unions_runme.go
+++ b/Examples/test-suite/go/unions_runme.go
@@ -3,7 +3,7 @@
 
 package main
 
-import "unions"
+import "swigtests/unions"
 
 func main() {
 	// Create new instances of SmallStruct and BigStruct for later use
diff --git a/Examples/test-suite/go/using1_runme.go b/Examples/test-suite/go/using1_runme.go
index a6a6fa7..09cc381 100644
--- a/Examples/test-suite/go/using1_runme.go
+++ b/Examples/test-suite/go/using1_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "using1"
+import "swigtests/using1"
 
 func main() {
 	if using1.Spam(37) != 37 {
diff --git a/Examples/test-suite/go/using2_runme.go b/Examples/test-suite/go/using2_runme.go
index f6b8d49..8109037 100644
--- a/Examples/test-suite/go/using2_runme.go
+++ b/Examples/test-suite/go/using2_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "using2"
+import "swigtests/using2"
 
 func main() {
 	if using2.Spam(37) != 37 {
diff --git a/Examples/test-suite/go/using_composition_runme.go b/Examples/test-suite/go/using_composition_runme.go
index 712d1fa..7ef09fe 100644
--- a/Examples/test-suite/go/using_composition_runme.go
+++ b/Examples/test-suite/go/using_composition_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "using_composition"
+import . "swigtests/using_composition"
 
 func main() {
 	f := NewFooBar()
diff --git a/Examples/test-suite/go/using_extend_runme.go b/Examples/test-suite/go/using_extend_runme.go
index 27d1ccc..dac300b 100644
--- a/Examples/test-suite/go/using_extend_runme.go
+++ b/Examples/test-suite/go/using_extend_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "using_extend"
+import . "swigtests/using_extend"
 
 func main() {
 	f := NewFooBar()
diff --git a/Examples/test-suite/go/using_inherit_runme.go b/Examples/test-suite/go/using_inherit_runme.go
index a881718..c875590 100644
--- a/Examples/test-suite/go/using_inherit_runme.go
+++ b/Examples/test-suite/go/using_inherit_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "using_inherit"
+import . "swigtests/using_inherit"
 
 func main() {
 	b := NewBar()
diff --git a/Examples/test-suite/go/using_private_runme.go b/Examples/test-suite/go/using_private_runme.go
index 2da62dc..4c86ef5 100644
--- a/Examples/test-suite/go/using_private_runme.go
+++ b/Examples/test-suite/go/using_private_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "using_private"
+import . "swigtests/using_private"
 
 func main() {
 	f := NewFooBar()
diff --git a/Examples/test-suite/go/using_protected_runme.go b/Examples/test-suite/go/using_protected_runme.go
index 3fd5029..4310818 100644
--- a/Examples/test-suite/go/using_protected_runme.go
+++ b/Examples/test-suite/go/using_protected_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "using_protected"
+import . "swigtests/using_protected"
 
 func main() {
 	f := NewFooBar()
diff --git a/Examples/test-suite/go/varargs_overload_runme.go b/Examples/test-suite/go/varargs_overload_runme.go
index 8ce580d..50a4308 100644
--- a/Examples/test-suite/go/varargs_overload_runme.go
+++ b/Examples/test-suite/go/varargs_overload_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "varargs_overload"
+import "swigtests/varargs_overload"
 
 func main() {
 	if varargs_overload.Vararg_over1("Hello") != "Hello" {
diff --git a/Examples/test-suite/go/varargs_runme.go b/Examples/test-suite/go/varargs_runme.go
index 60bd882..eb2fa94 100644
--- a/Examples/test-suite/go/varargs_runme.go
+++ b/Examples/test-suite/go/varargs_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "varargs"
+import "swigtests/varargs"
 
 func main() {
 	if varargs.Test("Hello") != "Hello" {
diff --git a/Examples/test-suite/go/virtual_derivation_runme.go b/Examples/test-suite/go/virtual_derivation_runme.go
index 4e2c6e5..2113530 100644
--- a/Examples/test-suite/go/virtual_derivation_runme.go
+++ b/Examples/test-suite/go/virtual_derivation_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import . "virtual_derivation"
+import . "swigtests/virtual_derivation"
 
 // very innocent example
 
diff --git a/Examples/test-suite/go/virtual_poly_runme.go b/Examples/test-suite/go/virtual_poly_runme.go
index 32906b3..9973f24 100644
--- a/Examples/test-suite/go/virtual_poly_runme.go
+++ b/Examples/test-suite/go/virtual_poly_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "virtual_poly"
+import "swigtests/virtual_poly"
 
 func main() {
 	d := virtual_poly.NewNDouble(3.5)
diff --git a/Examples/test-suite/go/voidtest_runme.go b/Examples/test-suite/go/voidtest_runme.go
index 133545c..35c5289 100644
--- a/Examples/test-suite/go/voidtest_runme.go
+++ b/Examples/test-suite/go/voidtest_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "voidtest"
+import "swigtests/voidtest"
 
 func main() {
 	voidtest.Globalfunc()
diff --git a/Examples/test-suite/go/wrapmacro_runme.go b/Examples/test-suite/go/wrapmacro_runme.go
index a251a05..d792d4f 100644
--- a/Examples/test-suite/go/wrapmacro_runme.go
+++ b/Examples/test-suite/go/wrapmacro_runme.go
@@ -1,6 +1,6 @@
 package main
 
-import "wrapmacro"
+import "swigtests/wrapmacro"
 
 func main() {
 	a := 2
diff --git a/Examples/test-suite/java/cpp11_initializer_list_runme.java b/Examples/test-suite/java/cpp11_initializer_list_runme.java
new file mode 100644
index 0000000..0318c9e
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_initializer_list_runme.java
@@ -0,0 +1,21 @@
+
+import cpp11_initializer_list.*;
+
+public class cpp11_initializer_list_runme {
+
+  static {
+    try {
+	System.loadLibrary("cpp11_initializer_list");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static void main(String argv[]) {
+    C c = new C(null);
+    String joined = c.get_joined_string();
+    if (!joined.equals("AbFab"))
+      throw new RuntimeException("Wrong joined string " + joined);
+  }
+}
diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java
index f307b3a..ab343b5 100644
--- a/Examples/test-suite/java/doxygen_basic_translate_runme.java
+++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java
@@ -54,6 +54,8 @@
     		" \n" +
     		" {@code \n" +
     		"int main() { while(true); } \n" +
+		"\n" +
+		"// Test blank line in code block \n" +
     		" }\n" +
     		" }\n" +
     		" \n" +
diff --git a/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java
new file mode 100644
index 0000000..05e51cf
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java
@@ -0,0 +1,101 @@
+
+import doxygen_basic_translate_style2.*;
+import com.sun.javadoc.*;
+import java.util.HashMap;
+
+public class doxygen_basic_translate_style2_runme {
+  static {
+    try {
+      System.loadLibrary("doxygen_basic_translate_style2");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+  
+  public static void main(String argv[]) 
+  {
+    /*
+      Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
+      and calls the start() method of that class with parsed information.
+    */
+    CommentParser parser = new CommentParser();
+    com.sun.tools.javadoc.Main.execute("doxygen_basic_translate_style2 runtime test",
+                                       "CommentParser",
+                                       new String[]{"-quiet", "doxygen_basic_translate_style2"});
+
+    HashMap<String, String> wantedComments = new HashMap<String, String>();
+    
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function()",
+    		" \n" +
+    		" Brief description.\n" +
+    		" \n" +
+    		" The comment text.\n" +
+    		" @author Some author\n" +
+    		" @return Some number\n" +
+    		" @see function2\n" +
+    		" \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function2()",
+    		" A test of a very very very very very very very very very very very very very very very very \n" +
+    		" very very very very very long comment string. \n" +
+    		" \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function4()",
+    		" A test of some mixed tag usage \n" +
+    		" If: CONDITION {\n" +
+    		" This <i>code </i>fragment shows us something . \n" +
+    		" <p alt=\"Minuses: \">\n" +
+    		" <li>it's senseless \n" +
+    		" </li><li>it's stupid \n" +
+    		" </li><li>it's null \n" +
+    		" \n" +
+    		" </li></p>Warning: This may not work as expected \n" +
+    		" \n" +
+    		" {@code \n" +
+    		"int main() { while(true); } \n" +
+		"\n" +
+		"// Test blank line in code block \n" +
+    		" }\n" +
+    		" }\n" +
+    		" \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function3(int)",
+    		" A test for overloaded functions \n" +
+    		" This is function <b>one </b>\n" +
+    		" \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function5(int)",
+    		" This is a post comment. \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function6(int)",
+    		" Test for default args \n" +
+    		" @param a Some parameter, default is 42" +
+    		" \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function6()",
+    		" Test for default args \n" +
+    		" \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function7(doxygen_basic_translate_style2.SWIGTYPE_p_p_p_Shape)",
+    		" Test for a parameter with difficult type \n" +
+    		" (mostly for python) \n" +
+    		" @param a Very strange param \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function3(int, int)",
+    		" A test for overloaded functions \n" +
+    		" This is function <b>two </b>\n" +
+    		" \n" +
+    		"");
+    wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.Atan2(double, double)",
+    		" Multiple parameters test.\n" +
+    		" \n" +
+    		" @param y Vertical coordinate.\n" +
+    		" @param x Horizontal coordinate.\n" +
+    		" @return Arc tangent of <code>y/x</code>.\n" +
+    		"");
+
+    // and ask the parser to check comments for us
+    System.exit(parser.check(wantedComments));
+  }
+}
diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java
index 8bd6522..d5c533f 100644
--- a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java
+++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java
@@ -40,7 +40,10 @@
     		" Not everything works right now...\n" +
     		" <code>codeword</code>\n\n\n\n\n\n" +
     		" <i>citationword</i>\n" +
-                " {@code some test code }\n");
+                " {@code some test code }\n\n" +
+    		" Code immediately following text.  Pydoc translation must add an\n" +
+    		" empty line before:\n" +
+    		" {@code more test code }");
     
     wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func02(int)",
     		" Conditional comment: SOMECONDITION \n" +
@@ -63,8 +66,11 @@
                        " @exception SuperError \n" +
                        " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
                        " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
-                       " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
-    		" This will only appear in hmtl \n");
+                       " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n\n" +
+                       "Math immediately following text.  Pydoc translation must add an\n" +
+                       "empty line before:\n\n" +
+                       " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\n" +
+                       " This will only appear in hmtl \n");
     
     wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func05(int)",
                        " If: ANOTHERCONDITION {\n" +
diff --git a/Examples/test-suite/java/java_enums_runme.java b/Examples/test-suite/java/java_enums_runme.java
index bc7d416..754d391 100644
--- a/Examples/test-suite/java/java_enums_runme.java
+++ b/Examples/test-suite/java/java_enums_runme.java
@@ -13,6 +13,12 @@
 
   public static void main(String argv[]) 
   {
+      if (WithTrailingComma.Second != 1)
+          throw new RuntimeException("Incorrect value for Second");
+
+      if (WithTrailingCommaAndIgnoredFirstItem.SecondNonIgnoredOne != 2)
+          throw new RuntimeException("Incorrect value for SecondNonIgnoredOne");
+
       int number = 200;
 
       // Switch statement will only compile if these enums are initialised 
diff --git a/Examples/test-suite/java/li_std_set_runme.java b/Examples/test-suite/java/li_std_set_runme.java
index 9763484..0e013eb 100644
--- a/Examples/test-suite/java/li_std_set_runme.java
+++ b/Examples/test-suite/java/li_std_set_runme.java
@@ -71,5 +71,20 @@
     checkThat(ss.removeAll(found));
     checkThat(ss.isEmpty());
     checkThat(ss.size() == 0);
+
+    // Check a set of another type.
+    java.util.AbstractSet<Foo> fooSet = new FooSet();
+    checkThat(fooSet.isEmpty());
+    checkThat(fooSet.add(new Foo(17)));
+    checkThat(fooSet.size() == 1);
+
+    // And a set of primitive type.
+    java.util.AbstractSet<Integer> intSet = new IntSet();
+    checkThat(intSet.isEmpty());
+    checkThat(intSet.add(17));
+    checkThat(!intSet.add(17));
+    checkThat(intSet.size() == 1);
+    checkThat(intSet.add(289));
+    checkThat(intSet.size() == 2);
   }
 }
diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java
index fc8ba0f..d4c0c95 100644
--- a/Examples/test-suite/java/li_std_vector_runme.java
+++ b/Examples/test-suite/java/li_std_vector_runme.java
@@ -11,54 +11,61 @@
     }
   }
 
+  public static void checkThat(boolean mustBeTrue) throws Throwable {
+    if (!mustBeTrue) {
+      // Index [2], since this function is one hop away from main, and [1] is the current method.
+      throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
+    }
+  }
+
   public static void main(String argv[]) throws Throwable
   {
     IntVector v1 = li_std_vector.vecintptr(new IntVector());
     IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector());
     IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector());
 
-    if (!v1.isEmpty()) throw new RuntimeException("v1 test (1) failed");
-    if (v1.size() != 0) throw new RuntimeException("v1 test (2) failed");
-    if (!v1.add(123)) throw new RuntimeException("v1 test (3) failed");
-    if (v1.size() != 1) throw new RuntimeException("v1 test (4) failed");
-    if (v1.isEmpty()) throw new RuntimeException("v1 test (5) failed");
+    checkThat(v1.isEmpty());
+    checkThat(v1.size() == 0);
+    checkThat(v1.add(123));
+    checkThat(v1.size() == 1);
+    checkThat(!v1.isEmpty());
 
     int sum = 0;
     for (int n : v1) {
-      if (n != 123) throw new RuntimeException("v1 loop test failed");
+      checkThat(n == 123);
       sum += n;
     }
-    if (sum != 123) throw new RuntimeException("v1 sum test failed");
-    if (v1.get(0) != 123) throw new RuntimeException("v1 test failed");
+    checkThat(sum == 123);
+    checkThat(v1.get(0) == 123);
     v1.clear();
-    if (!v1.isEmpty()) throw new RuntimeException("v1 test clear failed");
+    checkThat(v1.isEmpty());
     v1.add(123);
 
-    if (v1.set(0, 456) != 123) throw new RuntimeException("v1 test (6) failed");
-    if (v1.size() != 1) throw new RuntimeException("v1 test (7) failed");
-    if (v1.get(0) != 456) throw new RuntimeException("v1 test (8) failed");
+    checkThat(v1.set(0, 456) == 123);
+    checkThat(v1.size() == 1);
+    checkThat(v1.get(0) == 456);
 
     java.util.Iterator<Integer> v1_iterator = v1.iterator();
-    if (!v1_iterator.hasNext()) throw new RuntimeException("v1 test (9) failed");
-    if (v1_iterator.next() != 456) throw new RuntimeException("v1 test (10) failed");
-    if (v1_iterator.hasNext()) throw new RuntimeException("v1 test (11) failed");
+    checkThat(v1_iterator.hasNext());
+    checkThat(v1_iterator.next() == 456);
+    checkThat(!v1_iterator.hasNext());
     try {
       v1_iterator.next();
-      throw new RuntimeException("v1 test (12) failed");
+      checkThat(false);
     } catch (java.util.NoSuchElementException e) {
     }
 
-    if (v1.remove(Integer.valueOf(123))) throw new RuntimeException("v1 test (13) failed");
-    if (!v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (14) failed");
-    if (!v1.isEmpty()) throw new RuntimeException("v1 test (15) failed");
-    if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed");
-    if (v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (17) failed");
+    checkThat(!v1.remove(Integer.valueOf(123)));
+    checkThat(v1.remove(Integer.valueOf(456)));
+    checkThat(v1.isEmpty());
+    checkThat(v1.size() == 0);
+    checkThat(!v1.remove(Integer.valueOf(456)));
 
-    if (new IntVector(3, 0).size() != 3) throw new RuntimeException("constructor initial size test failed");
+    checkThat(new IntVector(3, 0).size() == 3);
     for (int n : new IntVector(10, 999))
-      if (n != 999) throw new RuntimeException("constructor initialization with value failed");
+      checkThat(n == 999);
     for (int n : new IntVector(new IntVector(10, 999)))
-      if (n != 999) throw new RuntimeException("copy constructor initialization with value failed");
+      checkThat(n == 999);
 
     StructVector v4 = li_std_vector.vecstruct(new StructVector());
     StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector());
@@ -68,18 +75,18 @@
     v5.add(new Struct(34));
     v6.add(new Struct(56));
 
-    if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed");
-    if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed");
-    if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed");
+    checkThat(v4.get(0).getNum() == 12);
+    checkThat(v5.get(0).getNum() == 34);
+    checkThat(v6.get(0).getNum() == 56);
 
     for (Struct s : v4) {
-      if (s.getNum() != 12) throw new RuntimeException("v4 loop test failed");
+      checkThat(s.getNum() == 12);
     }
     for (Struct s : v5) {
-      if (s.getNum() != 34) throw new RuntimeException("v5 loop test failed");
+      checkThat(s.getNum() == 34);
     }
     for (Struct s : v6) {
-      if (s.getNum() != 56) throw new RuntimeException("v6 loop test failed");
+      checkThat(s.getNum() == 56);
     }
 
     StructVector v7 = li_std_vector.vecstruct(new StructVector());
@@ -87,43 +94,43 @@
     v7.add(new Struct(23));
     v7.add(new Struct(456));
     v7.add(new Struct(7890));
-    if (v7.size() != 4) throw new RuntimeException("v7 test (1) failed");
+    checkThat(v7.size() == 4);
     {
       double[] a7 = {1, 23, 456, 7890};
       int i7 = 0;
       for (Struct s7 : v7) {
-        if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (2) failed");
+        checkThat(s7.getNum() == a7[i7]);
         i7++;
       }
-      if (i7 != a7.length) throw new RuntimeException("v7 test (3) failed");
+      checkThat(i7 == a7.length);
     }
-    if (v7.remove(2).getNum() != 456) throw new RuntimeException("v7 test (4) failed");
+    checkThat(v7.remove(2).getNum() == 456);
     {
       double[] a7 = {1, 23, 7890};
       int i7 = 0;
       for (Struct s7 : v7) {
-        if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (5) failed");
+        checkThat(s7.getNum() == a7[i7]);
         i7++;
       }
-      if (i7 != a7.length) throw new RuntimeException("v7 test (6) failed");
+      checkThat(i7 == a7.length);
     }
     v7.add(1, new Struct(123));
     {
       double[] a7 = {1, 123, 23, 7890};
       int i7 = 0;
       for (Struct s7 : v7) {
-        if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (7) failed");
+        checkThat(s7.getNum() == a7[i7]);
         i7++;
       }
-      if (i7 != a7.length) throw new RuntimeException("v7 test (8) failed");
+      checkThat(i7 == a7.length);
     }
 
     BoolVector v8 = new BoolVector();
-    if (!v8.add(true)) throw new RuntimeException("v8 test (1) failed");;
-    if (v8.get(0) != true) throw new RuntimeException("v8 test (2) failed");;
-    if (v8.set(0, false) != true) throw new RuntimeException("v8 test (3) failed");;
-    if (v8.set(0, false) != false) throw new RuntimeException("v8 test (4) failed");;
-    if (v8.size() != 1) throw new RuntimeException("v8 test (5) failed");;
+    checkThat(v8.add(true));
+    checkThat(v8.get(0) == true);
+    checkThat(v8.set(0, false) == true);
+    checkThat(v8.set(0, false) == false);
+    checkThat(v8.size() == 1);
 
     java.util.ArrayList<Boolean> bl = new java.util.ArrayList<Boolean>(java.util.Arrays.asList(true, false, true, false));
     BoolVector bv = new BoolVector(java.util.Arrays.asList(true, false, true, false));
@@ -136,36 +143,41 @@
     v9.add(50);
     v9.add(60);
     v9.add(70);
-    if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed");
-    if (!v9.remove(Integer.valueOf(60))) throw new RuntimeException("v9 test (2) failed");
-    if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed");
+    checkThat(v9.size() == 7);
+    checkThat(v9.remove(Integer.valueOf(60)));
+    checkThat(v9.size() == 6);
 
     IntVector v10 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40, 50));
     v10.subList(1, 4).clear(); // Recommended way to call protected method removeRange(1,3)
-    if (v10.size() != 2) throw new RuntimeException("v10 test (1) failed");
-    if (v10.get(0) != 10) throw new RuntimeException("v10 test (2) failed");
-    if (v10.get(1) != 50) throw new RuntimeException("v10 test (3) failed");
+    checkThat(v10.size() == 2);
+    checkThat(v10.get(0) == 10);
+    checkThat(v10.get(1) == 50);
     v10.addAll(1, java.util.Arrays.asList(22, 33));
-    if (v10.size() != 4) throw new RuntimeException("v10 test (4) failed");
-    if (v10.get(1) != 22) throw new RuntimeException("v10 test (5) failed");
-    if (v10.get(2) != 33) throw new RuntimeException("v10 test (6) failed");
+    checkThat(v10.size() == 4);
+    checkThat(v10.get(1) == 22);
+    checkThat(v10.get(2) == 33);
 
     v10.add(v10.size(), 55);
-    if (v10.size() != 5) throw new RuntimeException("v10 test (7) failed");
-    if (v10.get(4) != 55) throw new RuntimeException("v10 test (8) failed");
+    checkThat(v10.size() == 5);
+    checkThat(v10.get(4) == 55);
 
     IntVector v11 = new IntVector(java.util.Arrays.asList(11, 22, 33, 44));
     v11.listIterator(0);
     v11.listIterator(v11.size());
     try {
       v11.listIterator(v11.size() + 1);
-      throw new RuntimeException("v11 test (1) failed");
+      checkThat(false);
     } catch (IndexOutOfBoundsException e) {
     }
     try {
       v11.listIterator(-1);
-      throw new RuntimeException("v11 test (2) failed");
+      checkThat(false);
     } catch (IndexOutOfBoundsException e) {
     }
+
+    IntVector arrayInit = new IntVector(new int[]{1, 2, 3, 4, 5});
+    checkThat(arrayInit.size() == 5);
+    checkThat(arrayInit.get(0) == 1);
+    checkThat(arrayInit.get(4) == 5);
   }
 }
diff --git a/Examples/test-suite/java/nested_inheritance_interface_runme.java b/Examples/test-suite/java/nested_inheritance_interface_runme.java
new file mode 100644
index 0000000..8436ec2
--- /dev/null
+++ b/Examples/test-suite/java/nested_inheritance_interface_runme.java
@@ -0,0 +1,32 @@
+import nested_inheritance_interface.*;
+import java.util.Arrays;
+
+public class nested_inheritance_interface_runme {
+
+  static {
+    try {
+      System.loadLibrary("nested_inheritance_interface");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  private static void takeIA(IASwigInterface ia) {
+  }
+
+  public static void main(String argv[]) {
+	Class[] BNInterfaces = B.N.class.getInterfaces();
+    String expectedInterfacesString = "[interface nested_inheritance_interface.IASwigInterface]";
+    String actualInterfacesString = Arrays.toString(BNInterfaces);
+    if (!expectedInterfacesString.equals(actualInterfacesString))
+      throw new RuntimeException("Expected interfaces for " + B.N.class.getName() + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
+
+    if (!IASwigInterface.class.isInterface())
+      throw new RuntimeException(IASwigInterface.class.getName() + " should be an interface but is not");
+
+    // overloaded methods check
+    B.N d = new B.N();
+    takeIA(d);
+  }
+}
diff --git a/Examples/test-suite/java_enums.i b/Examples/test-suite/java_enums.i
index 855913d..cad4926 100644
--- a/Examples/test-suite/java_enums.i
+++ b/Examples/test-suite/java_enums.i
@@ -18,6 +18,21 @@
 // Set default Java const code generation
 %javaconst(1);
 
+// Test enums with trailing comma after the last item.
+enum WithTrailingComma
+{
+    First,
+    Second,
+};
+
+%ignore ReallyFirstOneIsIgnored;
+enum WithTrailingCommaAndIgnoredFirstItem
+{
+    ReallyFirstOneIsIgnored,
+    FirstNonIgnoredOne,
+    SecondNonIgnoredOne,
+};
+
 // Change the default generation so that these enums are generated into an interface instead of a class
 %typemap(javaclassmodifiers) enum stuff "public interface"
 
diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i
index 5fdc5fa..5bde387 100644
--- a/Examples/test-suite/li_std_auto_ptr.i
+++ b/Examples/test-suite/li_std_auto_ptr.i
@@ -4,6 +4,12 @@
 #if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // auto_ptr deprecation
 #endif
+
+#if defined(__clang__)
+#pragma clang diagnostic push
+// Suppress 'auto_ptr<>' is deprecated
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
 %}
 
 #if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPYTHON)
@@ -12,11 +18,29 @@
 
 %auto_ptr(Klass)
 
-%inline %{
-
+%{
+#if __cplusplus < 201703L
 #include <memory>
+#else
+// Simple std::auto_ptr implementation for testing after its removal in C++17
+namespace std {
+  template <class T> class auto_ptr {
+    T *ptr;
+    public:
+      auto_ptr(T *ptr = 0) : ptr(ptr) {}
+      auto_ptr(auto_ptr&& a) : ptr(a.ptr) { a.ptr = 0;}
+      ~auto_ptr() { delete ptr; }
+      T *release() { T *p = ptr; ptr = 0; return p; }
+      auto_ptr& operator=(auto_ptr&& a) { if (&a != this) { delete ptr; ptr = a.ptr; a.ptr = 0; } return *this; }
+  };
+}
+#endif
+
 #include <string>
 #include "swig_examples_lock.h"
+%}
+
+%inline %{
 
 class Klass {
 public:
diff --git a/Examples/test-suite/li_std_containers_overload.i b/Examples/test-suite/li_std_containers_overload.i
new file mode 100644
index 0000000..5e7c28e
--- /dev/null
+++ b/Examples/test-suite/li_std_containers_overload.i
@@ -0,0 +1,33 @@
+%module li_std_containers_overload
+
+// Suppress warning that ought not to appear, but there is no easy fix
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) VectorOverload;
+
+%include <std_string.i>
+%include <std_vector.i>
+
+%inline %{
+struct X {};
+struct Y {};
+%}
+
+%template(VectorX) std::vector<X>;
+%template(VectorY) std::vector<Y>;
+%template(VectorString) std::vector<std::string>;
+%template(VectorInt) std::vector<int>;
+
+%inline %{
+using namespace std;
+string VectorOverload(vector<X> v) {
+  return "vector<X>";
+}
+string VectorOverload(vector<Y> v) {
+  return "vector<Y>";
+}
+string VectorOverload(vector<string> v) {
+  return "vector<string>";
+}
+string VectorOverload(vector<int> v) {
+  return "vector<int>";
+}
+%}
diff --git a/Examples/test-suite/li_std_deque.i b/Examples/test-suite/li_std_deque.i
index 152bc86..c2f4a7f 100644
--- a/Examples/test-suite/li_std_deque.i
+++ b/Examples/test-suite/li_std_deque.i
@@ -36,8 +36,8 @@
 }
 
 void halve_in_place(std::deque<double>& v) {
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::deque<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 %}
diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/li_std_list.i
index 9cc6220..2ed5b9a 100644
--- a/Examples/test-suite/li_std_list.i
+++ b/Examples/test-suite/li_std_list.i
@@ -30,8 +30,8 @@
 
 
 void halve_in_place(std::list<double>& v) {
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::list<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 struct Struct {
diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i
index bb952cd..507272d 100644
--- a/Examples/test-suite/li_std_set.i
+++ b/Examples/test-suite/li_std_set.i
@@ -23,7 +23,26 @@
     %template(v_int) std::vector<int>;
     %template(set_string) std::set<std::string>;
 #elif defined(SWIGJAVA) || defined(SWIGCSHARP)
+    // This operator is only defined because it's needed to store objects of
+    // type Foo in std::set in C++, we don't need to wrap it.
+    %ignore operator<;
+    %inline %{
+        struct Foo
+        {
+            explicit Foo(int n) : n(n) {}
+
+            int n;
+
+            friend bool operator<(Foo foo1, Foo foo2)
+            {
+                return foo1.n < foo2.n;
+            }
+        };
+    %}
+
+    %template(IntSet) std::set<int>;
     %template(StringSet) std::set<std::string>;
+    %template(FooSet) std::set<Foo>;
 #endif
 
 #if defined(SWIGRUBY)
diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i
index ada146c..33fb797 100644
--- a/Examples/test-suite/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector.i
@@ -48,8 +48,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 struct Struct {
diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i
index 103242b..70b776b 100644
--- a/Examples/test-suite/li_std_vector_extra.i
+++ b/Examples/test-suite/li_std_vector_extra.i
@@ -62,8 +62,8 @@
 }
 
 void halve_in_place(std::vector<double>& v) {
-    std::transform(v.begin(),v.end(),v.begin(),
-                   std::bind2nd(std::divides<double>(),2.0));
+    for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+        *it /= 2.0;
 }
 
 %}
diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i
index b2b7305..55d4538 100644
--- a/Examples/test-suite/li_std_wstring.i
+++ b/Examples/test-suite/li_std_wstring.i
@@ -1,7 +1,9 @@
 %module li_std_wstring
-%include <std_basic_string.i>
-%include <std_wstring.i>
 
+// The languages below are yet to provide std_wstring.i
+#if !(defined(SWIGD) || defined(SWIGGO) || defined(SWIGGUILE) || defined(SWIGJAVASCRIPT) || defined(SWIGLUA) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGPHP) || defined(SWIGR) || defined(SWIGSCILAB))
+
+%include <std_wstring.i>
 
 // throw is invalid in C++17 and later, only SWIG to use it
 #define TESTCASE_THROW1(T1) throw(T1)
@@ -10,26 +12,7 @@
 %}
 
 %inline %{
-
-struct A : std::wstring 
-{
-  A(const std::wstring& s) : std::wstring(s)
-  {
-  }
-};
-
-struct B 
-{
-  B(const std::wstring& s) : cname(0), name(s), a(s)
-  {
-  }
-  
-  char *cname;
-  std::wstring name;
-  A a;
-
-};
- 
+#include <string>
 
 wchar_t test_wcvalue(wchar_t x) {
    return x;
@@ -63,33 +46,18 @@
 void test_pointer(std::wstring *x) {
 }
 
-std::wstring *test_pointer_out() {
-   static std::wstring x = L"x";
-   return &x;
-}
-
 void test_const_pointer(const std::wstring *x) {
 }
 
-const std::wstring *test_const_pointer_out() {
-   static std::wstring x = L"x";
-   return &x;
-}
-
 void test_reference(std::wstring &x) {
 }
 
-std::wstring& test_reference_out() {
-   static std::wstring x = L"x";
-   return x;
-}
-
 bool test_equal_abc(const std::wstring &s) {
   return L"abc" == s;
 }
 
 void test_throw() TESTCASE_THROW1(std::wstring){
-  static std::wstring x = L"x";
+  static std::wstring x = L"throwing test_throw";
   
   throw x;
 }
@@ -102,12 +70,7 @@
   return s.size();
 }
 
-#ifdef SWIGPYTHON_BUILTIN
-bool is_python_builtin() { return true; }
-#else
-bool is_python_builtin() { return false; }
-#endif
-
 %}
 
+#endif
 
diff --git a/Examples/test-suite/li_std_wstring_inherit.i b/Examples/test-suite/li_std_wstring_inherit.i
new file mode 100644
index 0000000..54c6bd8
--- /dev/null
+++ b/Examples/test-suite/li_std_wstring_inherit.i
@@ -0,0 +1,39 @@
+%module li_std_wstring_inherit
+%include <std_basic_string.i>
+%include <std_wstring.i>
+
+
+%inline %{
+
+struct A : std::wstring 
+{
+  A(const std::wstring& s) : std::wstring(s)
+  {
+  }
+};
+
+struct B 
+{
+  B(const std::wstring& s) : cname(0), name(s), a(s)
+  {
+  }
+  
+  char *cname;
+  std::wstring name;
+  A a;
+
+};
+ 
+std::wstring test_value(std::wstring x) {
+   return x;
+}
+
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+
+%}
+
+
diff --git a/Examples/test-suite/multivalue.i b/Examples/test-suite/multivalue.i
index f92e6c7..3bc3471 100644
--- a/Examples/test-suite/multivalue.i
+++ b/Examples/test-suite/multivalue.i
@@ -26,6 +26,11 @@
 
 void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
 
+#else
+%include "typemaps.i"
+void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
+void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
+void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
 #endif
 
 %{
@@ -49,4 +54,3 @@
 }
 
 %}
-
diff --git a/Examples/test-suite/nested_inheritance_interface.i b/Examples/test-suite/nested_inheritance_interface.i
new file mode 100644
index 0000000..f8335c0
--- /dev/null
+++ b/Examples/test-suite/nested_inheritance_interface.i
@@ -0,0 +1,20 @@
+%module  nested_inheritance_interface
+
+%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
+	    SWIGWARN_D_MULTIPLE_INHERITANCE,
+	    SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%include "swiginterface.i"
+%interface(IA)
+#endif
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature ("flatnested");
+#endif
+
+
+%inline %{
+struct IA {};
+struct B { struct N : IA {}; };
+%}
diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
index fd1daed..775b1ea 100644
--- a/Examples/test-suite/ocaml/Makefile.in
+++ b/Examples/test-suite/ocaml/Makefile.in
@@ -34,6 +34,12 @@
 enums \
 preproc_constants_c \
 
+CPP_TEST_CASES += \
+	inout \
+
+C_TEST_CASES += \
+	multivalue \
+
 ml_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
 
 run_testcase = \
diff --git a/Examples/test-suite/ocaml/inout_runme.ml b/Examples/test-suite/ocaml/inout_runme.ml
new file mode 100644
index 0000000..767bb43
--- /dev/null
+++ b/Examples/test-suite/ocaml/inout_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Inout
+
+let _ =
+  assert (_AddOne1 '(1.) as float = 2.);
+  assert (_AddOne3 '(1, 1, 1) = C_list ['2.;'2.;'2.]);
+  assert (_AddOne1r '(1.) as float = 2.);
+;;
diff --git a/Examples/test-suite/ocaml/multivalue_runme.ml b/Examples/test-suite/ocaml/multivalue_runme.ml
new file mode 100644
index 0000000..d7e19e7
--- /dev/null
+++ b/Examples/test-suite/ocaml/multivalue_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Multivalue
+
+let _ =
+  assert (_divide_l '(37, 5) = C_list ['7;'2]);
+  assert (_divide_v '(41, 7) = C_list ['5;'6]);
+  assert (_divide_mv '(91, 13) = C_list ['7;'0]);
+;;
diff --git a/Examples/test-suite/octave/li_std_containers_overload_runme.m b/Examples/test-suite/octave/li_std_containers_overload_runme.m
new file mode 100644
index 0000000..786d634
--- /dev/null
+++ b/Examples/test-suite/octave/li_std_containers_overload_runme.m
@@ -0,0 +1,37 @@
+# do not dump Octave core
+if exist("crash_dumps_octave_core", "builtin")
+  crash_dumps_octave_core(0);
+endif
+
+li_std_containers_overload
+
+function check(got, expected)
+  if (!strcmp(got, expected))
+    error("Failed check. '%s' != '%s'", got, expected)
+  endif
+end
+
+v = VectorX();
+check(VectorOverload(v), "vector<X>");
+
+v = VectorY();
+check(VectorOverload(v), "vector<Y>");
+
+v = VectorInt();
+check(VectorOverload(v), "vector<int>");
+
+v = VectorString();
+check(VectorOverload(v), "vector<string>");
+
+# TODO: Conversion from an Octave sequence not implemented yet
+# v = {X()};
+# check(VectorOverload(v), "vector<X>");
+
+# v = {Y()};
+# check(VectorOverload(v), "vector<Y>");
+
+# v = {1, 2, 3};
+# check(VectorOverload(v), "vector<int>");
+
+# v = {"aaa", "bbb", "ccc"};
+# check(VectorOverload(v), "vector<string>");
diff --git a/Examples/test-suite/octave/li_std_wstring_runme.m b/Examples/test-suite/octave/li_std_wstring_runme.m
deleted file mode 100644
index cbccc0c..0000000
--- a/Examples/test-suite/octave/li_std_wstring_runme.m
+++ /dev/null
@@ -1,95 +0,0 @@
-# do not dump Octave core
-if exist("crash_dumps_octave_core", "builtin")
-  crash_dumps_octave_core(0);
-endif
-
-li_std_wstring
-
-x="h";
-
-if (li_std_wstring.test_wcvalue(x) != x)
-  error("bad string mapping")
-endif
-
-x="hello";
-if (li_std_wstring.test_ccvalue(x) != x)
-  error("bad string mapping")
-endif
-
-if (li_std_wstring.test_cvalue(x) != x)
-  error("bad string mapping")
-endif
-
-if (li_std_wstring.test_value(x) != x)
-  error("bad string mapping")
-endif
-
-if (li_std_wstring.test_const_reference(x) != x)
-  error("bad string mapping")
-endif
-
-
-s = li_std_wstring.wstring("he");
-s = s + "llo";
-
-if (s != x)
-  error("bad string mapping")
-endif
-
-if (s(1:4) != x(1:4))
-  error("bad string mapping")
-endif
-
-if (li_std_wstring.test_value(s) != x)
-  error("bad string mapping")
-endif
-
-if (li_std_wstring.test_const_reference(s) != x)
-  error("bad string mapping")
-endif
-
-a = li_std_wstring.A(s);
-
-if (li_std_wstring.test_value(a) != x)
-  error("bad string mapping")
-endif
-
-if (li_std_wstring.test_const_reference(a) != x)
-  error("bad string mapping")
-endif
-
-b = li_std_wstring.wstring(" world");
-
-if (a + b != "hello world")
-  error("bad string mapping")
-endif
-  
-if (a + " world" != "hello world")
-  error("bad string mapping")
-endif
-
-if ("hello" + b != "hello world")
-  error("bad string mapping")
-endif
-
-c = "hello" + b;
-if (c.find_last_of("l") != 9)
-  error("bad string mapping")
-endif
-  
-s = "hello world";
-
-b = li_std_wstring.B("hi");
-
-b.name = li_std_wstring.wstring("hello");
-if (b.name != "hello")
-  error("bad string mapping")
-endif
-
-
-b.a = li_std_wstring.A("hello");
-if (b.a != "hello")
-  error("bad string mapping")
-endif
-
-
diff --git a/Examples/test-suite/octave/template_typedef_cplx2_runme.m b/Examples/test-suite/octave/template_typedef_cplx2_runme.m
index 94d3beb..a72e0f1 100644
--- a/Examples/test-suite/octave/template_typedef_cplx2_runme.m
+++ b/Examples/test-suite/octave/template_typedef_cplx2_runme.m
@@ -12,7 +12,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(d)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(d)) != 1)
   d
   error("is not an ArithUnaryFunction")
   error
@@ -26,7 +26,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(e)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(e)) != 1)
   e
   error("is not an ArithUnaryFunction")
 endif
@@ -44,7 +44,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(c)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(c)) != 1)
   c
   error("is not an ArithUnaryFunction")
 endif
@@ -57,7 +57,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(f)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(f)) != 1)
   f
   error("is not an ArithUnaryFunction")
 endif
@@ -74,7 +74,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(g)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(g)) != 1)
   g
   error("is not an ArithUnaryFunction")
   error
@@ -89,7 +89,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(h)) == -1)
+if (strfind('ArithUnaryFunction',swig_type(h)) == -1)
   h
   error("is not an ArithUnaryFunction")
 endif
diff --git a/Examples/test-suite/octave/template_typedef_cplx_runme.m b/Examples/test-suite/octave/template_typedef_cplx_runme.m
index d00981c..9e3e388 100644
--- a/Examples/test-suite/octave/template_typedef_cplx_runme.m
+++ b/Examples/test-suite/octave/template_typedef_cplx_runme.m
@@ -12,7 +12,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr("ArithUnaryFunction",swig_type(d)) != 1)
+if (strfind("ArithUnaryFunction",swig_type(d)) != 1)
   d
   error("is not an ArithUnaryFunction")
 endif
@@ -24,7 +24,7 @@
   error(e, "is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(e)) != 1);
+if (strfind('ArithUnaryFunction',swig_type(e)) != 1);
   c
   error("is not an ArithUnaryFunction")
 endif
@@ -42,7 +42,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(c)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(c)) != 1)
   c
   error("is not an ArithUnaryFunction")
 endif
@@ -55,7 +55,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(f)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(f)) != 1)
   f
   error("is not an ArithUnaryFunction")
 endif
@@ -72,7 +72,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(g)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(g)) != 1)
   g
   error("is not an ArithUnaryFunction")
 endif
@@ -86,7 +86,7 @@
   error("is not an instance")
 end_try_catch
 
-if (findstr('ArithUnaryFunction',swig_type(h)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(h)) != 1)
   h
   error("is not an ArithUnaryFunction")
 endif
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 0151f59..be06f7e 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -55,7 +55,7 @@
 	li_std_vectora \
 	li_std_vector_extra \
 	li_std_wstream \
-	li_std_wstring \
+	li_std_wstring_inherit \
 	primitive_types \
 	python_abstractbase \
 	python_append \
diff --git a/Examples/test-suite/python/argcargvtest_runme.py b/Examples/test-suite/python/argcargvtest_runme.py
index 38843b9..b034574 100644
--- a/Examples/test-suite/python/argcargvtest_runme.py
+++ b/Examples/test-suite/python/argcargvtest_runme.py
@@ -1,21 +1,21 @@
 from argcargvtest import *
 
-largs = ['hi', 'hola', 'hello']
+largs = ["hi", "hola", "hello"]
 if mainc(largs) != 3:
     raise RuntimeError("bad main typemap")
 
-targs = ('hi', 'hola')
-if mainv(targs, 1) != 'hola':
+targs = ("hi", "hola")
+if mainv(targs, 1) != "hola":
     print(mainv(targs, 1))
     raise RuntimeError("bad main typemap")
 
-targs = ('hi', 'hola')
-if mainv(targs, 1) != 'hola':
+targs = ("hi", "hola")
+if mainv(targs, 1) != "hola":
     raise RuntimeError("bad main typemap")
 
 try:
     error = 0
-    mainv('hello', 1)
+    mainv("hello", 1)
     error = 1
 except TypeError:
     pass
diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py
index 34caa32..0425fe1 100644
--- a/Examples/test-suite/python/char_binary_runme.py
+++ b/Examples/test-suite/python/char_binary_runme.py
@@ -1,26 +1,26 @@
 from char_binary import *
 
 t = Test()
-if t.strlen('hile') != 4:
-    print t.strlen('hile')
+if t.strlen("hile") != 4:
+    print t.strlen("hile")
     raise RuntimeError, "bad multi-arg typemap"
-if t.ustrlen('hile') != 4:
-    print t.ustrlen('hile')
+if t.ustrlen("hile") != 4:
+    print t.ustrlen("hile")
     raise RuntimeError, "bad multi-arg typemap"
 
-if t.strlen('hil\0') != 4:
+if t.strlen("hil\0") != 4:
     raise RuntimeError, "bad multi-arg typemap"
-if t.ustrlen('hil\0') != 4:
+if t.ustrlen("hil\0") != 4:
     raise RuntimeError, "bad multi-arg typemap"
 
 #
 # creating a raw char*
 #
 pc = new_pchar(5)
-pchar_setitem(pc, 0, 'h')
-pchar_setitem(pc, 1, 'o')
-pchar_setitem(pc, 2, 'l')
-pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 0, "h")
+pchar_setitem(pc, 1, "o")
+pchar_setitem(pc, 2, "l")
+pchar_setitem(pc, 3, "a")
 pchar_setitem(pc, 4, 0)
 
 
diff --git a/Examples/test-suite/python/comment_verifier.py b/Examples/test-suite/python/comment_verifier.py
index 57ac0b7..653cb49 100644
--- a/Examples/test-suite/python/comment_verifier.py
+++ b/Examples/test-suite/python/comment_verifier.py
@@ -1,10 +1,10 @@
 def check(got, expected, expected_builtin=None):
   if got is None:  # Absence of comment is equivalent to empty comment.
-      got = ''
+      got = ""
 
   if got != expected:
     import re
-    p = re.compile(r'^[+-]([^+-].*\S)?(\s+)$', re.M)
+    p = re.compile(r"^[+-]([^+-].*\S)?(\s+)$", re.M)
 
     def make_trailing_spaces_visible(str):
         def replace_trailing_spaces(match):
diff --git a/Examples/test-suite/python/cpp17_u8_char_literals_runme.py b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py
index 81f34f1..e2f8897 100644
--- a/Examples/test-suite/python/cpp17_u8_char_literals_runme.py
+++ b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py
@@ -1,10 +1,10 @@
 from cpp17_u8_char_literals import *
 
-if cvar.a != 'a':
+if cvar.a != "a":
     raise RuntimeError
 
-if cvar.u != 'u':
+if cvar.u != "u":
     raise RuntimeError
 
-if cvar.u8 != '8':
+if cvar.u8 != "8":
     raise RuntimeError
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index 683314d..14ef8c5 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -170,23 +170,23 @@
     if default_args.CDA().cdefaultargs_test2() != 1:
         raise RuntimeError
 
-    if default_args.chartest1() != 'x':
+    if default_args.chartest1() != "x":
         raise RuntimeError
 
-    if default_args.chartest2() != '\0':
+    if default_args.chartest2() != "\0":
         raise RuntimeError
 
-    if default_args.chartest3() != '\1':
+    if default_args.chartest3() != "\1":
         raise RuntimeError
 
-    if default_args.chartest4() != '\n':
+    if default_args.chartest4() != "\n":
         raise RuntimeError
 
-    if default_args.chartest5() != 'B':
+    if default_args.chartest5() != "B":
         raise RuntimeError
 
-    if default_args.chartest6() != 'C':
+    if default_args.chartest6() != "C":
         raise RuntimeError
 
 if __name__ == "__main__":
-    run('default_args')
+    run("default_args")
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index aa9d490..06856f3 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -75,7 +75,7 @@
 try:
     b.pong()
 except MyException, e:
-    if e.msg == 'foobar':
+    if e.msg == "foobar":
         ok = 1
     else:
         print "Unexpected error message: %s" % str(e)
diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py
index e664e06..9ef8dbd 100644
--- a/Examples/test-suite/python/doxygen_basic_translate_runme.py
+++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py
@@ -49,9 +49,9 @@
 
 .. code-block:: c++
 
-
     int main() { while(true); }
 
+    // Test blank line in code block
 }"""
 )
 comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5),
diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py
new file mode 100644
index 0000000..b75045d
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py
@@ -0,0 +1,82 @@
+import doxygen_basic_translate_style2
+import inspect
+import string
+import sys
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function),
+    """\
+Brief description.
+
+The comment text.
+
+Author: Some author
+
+:rtype: int
+:return: Some number
+
+See also: function2"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function2),
+    """\
+A test of a very very very very very very very very very very very very very very very very
+very very very very very long comment string."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function3),
+    """*Overload 1:*
+A test for overloaded functions
+This is function **one**
+
+|
+
+*Overload 2:*
+A test for overloaded functions
+This is function **two**"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function4),
+    """\
+A test of some mixed tag usage
+If: CONDITION {
+This *code* fragment shows us something .
+Title: Minuses:
+* it\'s senseless
+* it\'s stupid
+* it\'s null
+
+Warning: This may not work as expected
+
+.. code-block:: c++
+
+    int main() { while(true); }
+
+    // Test blank line in code block
+}"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5),
+    """This is a post comment."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function6),
+    """\
+Test for default args
+:type a: int
+:param a: Some parameter, default is 42"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function7),
+    """\
+Test for a parameter with difficult type
+(mostly for python)
+:type a: :py:class:`Shape`
+:param a: Very strange param"""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.Atan2),
+    """\
+Multiple parameters test.
+
+:type y: float
+:param y: Vertical coordinate.
+:type x: float
+:param x: Horizontal coordinate.
+:rtype: float
+:return: Arc tangent of ``y/x``."""
+)
diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
index c441c3d..11aa53b 100644
--- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py
+++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
@@ -44,7 +44,7 @@
 
 
 comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getFirstLetter),
-    r''
+    r""
 )
 
 comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.ClassWithNestedEnum),
@@ -73,7 +73,7 @@
 )
 
 comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidC),
-    r''
+    r""
 )
 
 comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashA),
diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py
index 53d087e..df1c0eb 100644
--- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py
+++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py
@@ -34,10 +34,16 @@
 
 'citationword'
 
+.. code-block:: c++
+
+    some test code
+
+Code immediately following text.  Pydoc translation must add an
+empty line before:
 
 .. code-block:: c++
 
-     some test code""")
+    more test code""")
 
 comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func02),
 r"""Conditional comment: SOMECONDITION
@@ -90,12 +96,16 @@
 
 :math:`\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}`
 
+.. math::
+
+    \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
 
 .. math::
 
     \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
 
-
+Math immediately following text.  Pydoc translation must add an
+empty line before:
 
 .. math::
 
@@ -111,7 +121,6 @@
 
 
 
-
 This will only appear in hmtl""")
 
 comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func05),
@@ -283,13 +292,11 @@
 
 
 
-
 very long
 text with tags <sometag>
 
 
 
-
 Version: 0.0.0.2
 
 Warning: This is senseless!
diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py
index 2d0840a..d698ba8 100644
--- a/Examples/test-suite/python/doxygen_translate_runme.py
+++ b/Examples/test-suite/python/doxygen_translate_runme.py
@@ -20,11 +20,9 @@
 
 'citationword'
 
-
 .. code-block:: c++
 
-     some test code
-
+    some test code
 
 Conditional comment: SOMECONDITION
 Some conditional comment
@@ -121,11 +119,9 @@
 :type b: float
 :param b: B is mentioned again...
 
-
 very long
 text with tags <sometag>
 
-
 Version: 0.0.0.2
 
 Warning: This is senseless!
diff --git a/Examples/test-suite/python/ignore_parameter_runme.py b/Examples/test-suite/python/ignore_parameter_runme.py
index 5f1342e..2b5c212 100644
--- a/Examples/test-suite/python/ignore_parameter_runme.py
+++ b/Examples/test-suite/python/ignore_parameter_runme.py
@@ -2,7 +2,7 @@
 
 def check(a, b):
     if a != b:
-        raise RuntimeError('"%s" != "%s"' % (a, b))
+        raise RuntimeError("'%s' != '%s'" % (a, b))
 
 check(jaguar(200, 0), "hello")
 check(lotus("foo", 1), 101)
diff --git a/Examples/test-suite/python/li_cstring_runme.py b/Examples/test-suite/python/li_cstring_runme.py
index 6fec536..b718f13 100644
--- a/Examples/test-suite/python/li_cstring_runme.py
+++ b/Examples/test-suite/python/li_cstring_runme.py
@@ -18,10 +18,10 @@
     print test4("hello")
     raise RuntimeError
 
-if test5(4) != 'xxxx':
+if test5(4) != "xxxx":
     raise RuntimeError
 
-if test6(10) != 'xxxxx':
+if test6(10) != "xxxxx":
     raise RuntimeError
 
 if test7() != "Hello world!":
diff --git a/Examples/test-suite/python/li_cwstring_runme.py b/Examples/test-suite/python/li_cwstring_runme.py
index b2b23a8..5dd7b9b 100644
--- a/Examples/test-suite/python/li_cwstring_runme.py
+++ b/Examples/test-suite/python/li_cwstring_runme.py
@@ -15,10 +15,10 @@
 if test4("hello") != u"hello-suffix":
     raise RuntimeError
 
-if test5(4) != u'xxxx':
+if test5(4) != u"xxxx":
     raise RuntimeError
 
-if test6(10) != u'xxxxx':
+if test6(10) != u"xxxxx":
     raise RuntimeError
 
 if test7() != u"Hello world!":
diff --git a/Examples/test-suite/python/li_std_containers_overload_runme.py b/Examples/test-suite/python/li_std_containers_overload_runme.py
new file mode 100644
index 0000000..dcb3835
--- /dev/null
+++ b/Examples/test-suite/python/li_std_containers_overload_runme.py
@@ -0,0 +1,29 @@
+from li_std_containers_overload import *
+
+def check(got, expected):
+    if got != expected:
+        raise RuntimeError("Failed check. '{}' != '{}'".format(got, expected))
+
+v = VectorX()
+check(VectorOverload(v), "vector<X>")
+
+v = VectorY()
+check(VectorOverload(v), "vector<Y>")
+
+v = VectorInt()
+check(VectorOverload(v), "vector<int>")
+
+v = VectorString()
+check(VectorOverload(v), "vector<string>")
+
+v = [X()]
+check(VectorOverload(v), "vector<X>")
+
+v = [Y()]
+check(VectorOverload(v), "vector<Y>")
+
+v = [1, 2, 3]
+check(VectorOverload(v), "vector<int>")
+
+v = ["aaa", "bbb", "ccc"]
+check(VectorOverload(v), "vector<string>")
diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py
index f6fad55..5e5b724 100644
--- a/Examples/test-suite/python/li_std_set_runme.py
+++ b/Examples/test-suite/python/li_std_set_runme.py
@@ -90,5 +90,5 @@
 for i in s:
     sum = sum + (i,)
 
-if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)):
+if (len(sum) != 3 or (not 1 in sum) or (not "hello" in sum) or (not (1, 2) in sum)):
     raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py
index 53d2bdc..087d92b 100644
--- a/Examples/test-suite/python/li_std_string_extra_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -19,7 +19,7 @@
 
 s = li_std_string_extra.string("he")
 #s += "ll"
-# s.append('o')
+# s.append("o")
 s = s + "llo"
 
 if s != x:
diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py
index 88105ea..59e729a 100644
--- a/Examples/test-suite/python/li_std_vector_extra_runme.py
+++ b/Examples/test-suite/python/li_std_vector_extra_runme.py
@@ -91,7 +91,7 @@
 
 
 v = vecStr(["hello ", "world"])
-if v[0] != 'hello world':
+if v[0] != "hello world":
     raise RuntimeError, "bad std::string+std::vector"
 
 
diff --git a/Examples/test-suite/python/li_std_wstring_inherit_runme.py b/Examples/test-suite/python/li_std_wstring_inherit_runme.py
new file mode 100644
index 0000000..558914e
--- /dev/null
+++ b/Examples/test-suite/python/li_std_wstring_inherit_runme.py
@@ -0,0 +1,45 @@
+import li_std_wstring_inherit
+import sys
+
+x = u"hello"
+
+s = li_std_wstring_inherit.wstring(u"he")
+s = s + u"llo"
+
+if s != x:
+    print s, x
+    raise RuntimeError("bad string mapping")
+
+if s[1:4] != x[1:4]:
+    raise RuntimeError("bad string mapping")
+
+a = li_std_wstring_inherit.A(s)
+b = li_std_wstring_inherit.wstring(" world")
+
+if a + b != "hello world":
+    raise RuntimeError("bad string mapping")
+
+if a + " world" != "hello world":
+    raise RuntimeError("bad string mapping")
+
+# This is expected to fail if -builtin is used
+# Reverse operators not supported in builtin types
+if not li_std_wstring_inherit.is_python_builtin():
+    if "hello" + b != "hello world":
+        raise RuntimeError("bad string mapping")
+
+    c = "hello" + b
+    if c.find_last_of("l") != 9:
+        raise RuntimeError("bad string mapping")
+
+b = li_std_wstring_inherit.B("hi")
+
+b.name = li_std_wstring_inherit.wstring(u"hello")
+if b.name != "hello":
+    raise RuntimeError("bad string mapping")
+
+
+b.a = li_std_wstring_inherit.A("hello")
+if b.a != u"hello":
+    raise RuntimeError("bad string mapping")
+
diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py
index bd49a43..c6210e2 100644
--- a/Examples/test-suite/python/li_std_wstring_runme.py
+++ b/Examples/test-suite/python/li_std_wstring_runme.py
@@ -1,87 +1,60 @@
 import li_std_wstring
 import sys
 
-x = u"h"
+def check_equal(a, b):
+    if a != b:
+        raise RuntimeError("failed {} {}".format(a, b))
 
-if li_std_wstring.test_wcvalue(x) != x:
-    print li_std_wstring.test_wcvalue(x)
-    raise RuntimeError("bad string mapping")
+h = u"h"
+check_equal(li_std_wstring.test_wcvalue(h), h)
 
-x = u"hello"
-if li_std_wstring.test_ccvalue(x) != x:
-    raise RuntimeError("bad string mapping")
+x = u"abc"
+check_equal(li_std_wstring.test_ccvalue(x), x)
+check_equal(li_std_wstring.test_cvalue(x), x)
 
-if li_std_wstring.test_cvalue(x) != x:
-    raise RuntimeError("bad string mapping")
+check_equal(li_std_wstring.test_wchar_overload(x), x)
+check_equal(li_std_wstring.test_wchar_overload(), None)
 
-if li_std_wstring.test_wchar_overload(x) != x:
-    raise RuntimeError("bad string mapping")
+li_std_wstring.test_pointer(None)
+li_std_wstring.test_const_pointer(None)
 
-if li_std_wstring.test_wchar_overload("not unicode") != "not unicode":
-    raise RuntimeError("bad string mapping")
+try:
+    li_std_wstring.test_value(None)
+    raise RuntimeError("NULL check failed")
+except TypeError as e:
+    pass
 
-if li_std_wstring.test_value(x) != x:
-    print x, li_std_wstring.test_value(x)
-    raise RuntimeError("bad string mapping")
+try:
+      li_std_wstring.test_reference(None)
+      raise RuntimeError("NULL check failed")
+except ValueError as e:
+    if "invalid null reference" not in str(e):
+        raise RuntimeError("Missing text {}".format(e))
+try:
+    li_std_wstring.test_const_reference(None)
+    raise RuntimeError("NULL check failed")
+except ValueError as e:
+    if "invalid null reference" not in str(e):
+        raise RuntimeError("Missing text {}".format(e))
 
-if li_std_wstring.test_const_reference(x) != x:
-    raise RuntimeError("bad string mapping")
+x = "hello"
+check_equal(li_std_wstring.test_const_reference(x), x)
 
+s = "abc"
+if not li_std_wstring.test_equal_abc(s):
+    raise RuntimeError("Not equal {}".format(s))
 
-s = li_std_wstring.wstring(u"he")
-s = s + u"llo"
+try:
+    li_std_wstring.test_throw
+except RuntimeError as e:
+    check_equal(e.message, "throwing test_throw")
 
-if s != x:
-    print s, x
-    raise RuntimeError("bad string mapping")
+x = "abc\0def"
+check_equal(li_std_wstring.test_value(x), x)
+check_equal(li_std_wstring.test_ccvalue(x), "abc")
+check_equal(li_std_wstring.test_wchar_overload(x), "abc")
 
-if s[1:4] != x[1:4]:
-    raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_value(s) != x:
-    raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_const_reference(s) != x:
-    raise RuntimeError("bad string mapping")
-
-a = li_std_wstring.A(s)
-
-if li_std_wstring.test_value(a) != x:
-    raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_const_reference(a) != x:
-    raise RuntimeError("bad string mapping")
-
-b = li_std_wstring.wstring(" world")
-
-if a + b != "hello world":
-    raise RuntimeError("bad string mapping")
-
-if a + " world" != "hello world":
-    raise RuntimeError("bad string mapping")
-
-# This is expected to fail if -builtin is used
-# Reverse operators not supported in builtin types
-if not li_std_wstring.is_python_builtin():
-    if "hello" + b != "hello world":
-        raise RuntimeError("bad string mapping")
-
-    c = "hello" + b
-    if c.find_last_of("l") != 9:
-        raise RuntimeError("bad string mapping")
-
-s = "hello world"
-
-b = li_std_wstring.B("hi")
-
-b.name = li_std_wstring.wstring(u"hello")
-if b.name != "hello":
-    raise RuntimeError("bad string mapping")
-
-
-b.a = li_std_wstring.A("hello")
-if b.a != u"hello":
-    raise RuntimeError("bad string mapping")
+################### Python specific
 
 # Byte strings only converted in Python 2
 if sys.version_info[0:2] < (3, 0):
diff --git a/Examples/test-suite/python/primitive_ref_runme.py b/Examples/test-suite/python/primitive_ref_runme.py
index f3a6403..2f1a514 100644
--- a/Examples/test-suite/python/primitive_ref_runme.py
+++ b/Examples/test-suite/python/primitive_ref_runme.py
@@ -33,7 +33,7 @@
 if ref_bool(True) != True:
     raise RuntimeError
 
-if ref_char('x') != 'x':
+if ref_char("x") != "x":
     raise RuntimeError
 
 if ref_over(0) != 0:
diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py
index c5009f6..04588dd 100644
--- a/Examples/test-suite/python/primitive_types_runme.py
+++ b/Examples/test-suite/python/primitive_types_runme.py
@@ -227,7 +227,7 @@
 t.v_check()
 
 # this value contains a '0' char!
-if def_namet != 'hola':
+if def_namet != "hola":
     print "bad namet", def_namet
     raise RuntimeError
 
@@ -236,54 +236,54 @@
     print "bad namet", t.var_namet, def_namet
     raise RuntimeError
 
-t.var_namet = 'hola'
+t.var_namet = "hola"
 
-if t.var_namet != 'hola':
+if t.var_namet != "hola":
     print "bad namet", t.var_namet
     raise RuntimeError
 
-t.var_namet = 'hol'
+t.var_namet = "hol"
 
-if t.var_namet != 'hol':
-    # if t.var_namet != 'hol\0\0':
+if t.var_namet != "hol":
+    # if t.var_namet != "hol\0\0":
     print "bad namet", t.var_namet
     raise RuntimeError
 
 
-cvar.var_char = '\0'
-if cvar.var_char != '\0':
+cvar.var_char = "\0"
+if cvar.var_char != "\0":
     raise RuntimeError, "bad char '0' case"
 
 cvar.var_char = 0
-if cvar.var_char != '\0':
+if cvar.var_char != "\0":
     raise RuntimeError, "bad char '0' case"
 
-cvar.var_namet = '\0'
-# if cvar.var_namet != '\0\0\0\0\0':
-if cvar.var_namet != '':
-    print 'hola', '', cvar.var_namet
+cvar.var_namet = "\0"
+# if cvar.var_namet != "\0\0\0\0\0":
+if cvar.var_namet != "":
+    print "hola", "", cvar.var_namet
     raise RuntimeError, "bad char '\0' case"
 
-cvar.var_namet = ''
-# if cvar.var_namet != '\0\0\0\0\0':
-if cvar.var_namet != '':
+cvar.var_namet = ""
+# if cvar.var_namet != "\0\0\0\0\0":
+if cvar.var_namet != "":
     raise RuntimeError, "bad char empty case"
 
 cvar.var_pchar = None
 if cvar.var_pchar != None:
     raise RuntimeError, "bad None case"
 
-cvar.var_pchar = ''
-if cvar.var_pchar != '':
-    print '%c' % (cvar.var_pchar[0],)
+cvar.var_pchar = ""
+if cvar.var_pchar != "":
+    print "%c" % (cvar.var_pchar[0],)
     raise RuntimeError, "bad char empty case"
 
 cvar.var_pcharc = None
 if cvar.var_pcharc != None:
     raise RuntimeError, "bad None case"
 
-cvar.var_pcharc = ''
-if cvar.var_pcharc != '':
+cvar.var_pcharc = ""
+if cvar.var_pcharc != "":
     raise RuntimeError, "bad char empty case"
 
 
@@ -291,10 +291,10 @@
 # creating a raw char*
 #
 pc = new_pchar(5)
-pchar_setitem(pc, 0, 'h')
-pchar_setitem(pc, 1, 'o')
-pchar_setitem(pc, 2, 'l')
-pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 0, "h")
+pchar_setitem(pc, 1, "o")
+pchar_setitem(pc, 2, "l")
+pchar_setitem(pc, 3, "a")
 pchar_setitem(pc, 4, 0)
 
 
@@ -331,7 +331,7 @@
 try:
     error = 0
     a = t.var_char
-    t.var_char = '23'
+    t.var_char = "23"
     error = 1
 except TypeError:
     if a != t.var_char:
@@ -393,7 +393,7 @@
 try:
     error = 0
     a = t.var_namet
-    t.var_namet = '123456'
+    t.var_namet = "123456"
     error = 1
 except TypeError:
     if a != t.var_namet:
@@ -410,11 +410,11 @@
     raise RuntimeError, "bad SWIGTYPE* typemap"
 
 
-if cvar.fixsize != 'ho\0la\0\0\0':
+if cvar.fixsize != "ho\0la\0\0\0":
     raise RuntimeError, "bad FIXSIZE typemap"
 
-cvar.fixsize = 'ho'
-if cvar.fixsize != 'ho\0\0\0\0\0\0':
+cvar.fixsize = "ho"
+if cvar.fixsize != "ho\0\0\0\0\0\0":
     raise RuntimeError, "bad FIXSIZE typemap"
 
 
@@ -487,26 +487,26 @@
     """t = Test object, e = type name (e.g. ulong), val = max or min allowed value, delta = +1 for max, -1 for min"""
     error = 0
     # Set the extreme valid value for var_*
-    setattr(t, 'var_' + e, val)
+    setattr(t, "var_" + e, val)
     # Make sure it was set properly and works properly in the val_* and ref_* methods
-    if getattr(t, 'var_' + e) != val or getattr(t, 'val_' + e)(val) != val or getattr(t, 'ref_' + e)(val) != val:
+    if getattr(t, "var_" + e) != val or getattr(t, "val_" + e)(val) != val or getattr(t, "ref_" + e)(val) != val:
         error = 1
     # Make sure setting a more extreme value fails without changing the value
     try:
-        a = getattr(t, 'var_' + e)
-        setattr(t, 'var_' + e, val + delta)
+        a = getattr(t, "var_" + e)
+        setattr(t, "var_" + e, val + delta)
         error = 1
     except OverflowError:
-        if a != getattr(t, 'var_' + e):
+        if a != getattr(t, "var_" + e):
             error = 1
     # Make sure the val_* and ref_* methods fail with a more extreme value
     try:
-        getattr(t, 'val_' + e)(val + delta)
+        getattr(t, "val_" + e)(val + delta)
         error = 1
     except OverflowError:
         pass
     try:
-        getattr(t, 'ref_' + e)(val + delta)
+        getattr(t, "ref_" + e)(val + delta)
         error = 1
     except OverflowError:
         pass
@@ -518,16 +518,16 @@
     checkType(t, e, maxval,  1)
     checkType(t, e, minval, -1)
 
-checkFull(t, 'llong',  maxllong,  minllong)
-checkFull(t, 'long',   maxlong,   minlong)
-checkFull(t, 'int',    maxint,    minint)
-checkFull(t, 'short',  maxshort,  minshort)
-checkFull(t, 'schar',  maxchar,   minchar)
-checkFull(t, 'ullong', maxullong, 0)
-checkFull(t, 'ulong',  maxulong,  0)
-checkFull(t, 'uint',   maxuint,   0)
-checkFull(t, 'ushort', maxushort, 0)
-checkFull(t, 'uchar',  maxuchar,  0)
+checkFull(t, "llong",  maxllong,  minllong)
+checkFull(t, "long",   maxlong,   minlong)
+checkFull(t, "int",    maxint,    minint)
+checkFull(t, "short",  maxshort,  minshort)
+checkFull(t, "schar",  maxchar,   minchar)
+checkFull(t, "ullong", maxullong, 0)
+checkFull(t, "ulong",  maxulong,  0)
+checkFull(t, "uint",   maxuint,   0)
+checkFull(t, "ushort", maxushort, 0)
+checkFull(t, "uchar",  maxuchar,  0)
 
 def checkOverload(t, name, val, delta, prevval, limit):
     """
@@ -556,16 +556,16 @@
                 raise RuntimeError, "bad " + name + " typemap"
 
 # Check that overloading works: uchar > schar > ushort > short > uint > int > ulong > long > ullong > llong
-checkOverload(t, 'uchar',  maxuchar,  +1, 0,         maxullong)
-checkOverload(t, 'ushort', maxushort, +1, maxuchar,  maxullong)
-checkOverload(t, 'uint',   maxuint,   +1, maxushort, maxullong)
-checkOverload(t, 'ulong',  maxulong,  +1, maxuint,   maxullong)
-checkOverload(t, 'ullong', maxullong, +1, maxulong,  maxullong)
-checkOverload(t, 'schar',  minchar,   -1, 0,         minllong)
-checkOverload(t, 'short',  minshort,  -1, minchar,   minllong)
-checkOverload(t, 'int',    minint,    -1, minshort,  minllong)
-checkOverload(t, 'long',   minlong,   -1, minint,    minllong)
-checkOverload(t, 'llong',  minllong,  -1, minlong,   minllong)
+checkOverload(t, "uchar",  maxuchar,  +1, 0,         maxullong)
+checkOverload(t, "ushort", maxushort, +1, maxuchar,  maxullong)
+checkOverload(t, "uint",   maxuint,   +1, maxushort, maxullong)
+checkOverload(t, "ulong",  maxulong,  +1, maxuint,   maxullong)
+checkOverload(t, "ullong", maxullong, +1, maxulong,  maxullong)
+checkOverload(t, "schar",  minchar,   -1, 0,         minllong)
+checkOverload(t, "short",  minshort,  -1, minchar,   minllong)
+checkOverload(t, "int",    minint,    -1, minshort,  minllong)
+checkOverload(t, "long",   minlong,   -1, minint,    minllong)
+checkOverload(t, "llong",  minllong,  -1, minlong,   minllong)
 
 # Make sure that large ints can be converted to doubles properly
 if val_double(sys.maxint + 1) != float(sys.maxint + 1):
diff --git a/Examples/test-suite/python/python_pybuffer_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py
index 85cfb75..8ecdb52 100644
--- a/Examples/test-suite/python/python_pybuffer_runme.py
+++ b/Examples/test-suite/python/python_pybuffer_runme.py
@@ -14,13 +14,13 @@
     k = 1000000  # number of times to execute the functions
 
     t = time.time()
-    a = bytearray(b'hello world')
+    a = bytearray(b"hello world")
     for i in range(k):
         python_pybuffer.title1(a)
     print "Time used by bytearray:", time.time() - t
 
     t = time.time()
-    b = 'hello world'
+    b = "hello world"
     for i in range(k):
         python_pybuffer.title2(b)
     print "Time used by string:", time.time() - t
@@ -30,7 +30,7 @@
     buf2 = bytearray(50)
 
     python_pybuffer.func1(buf1)
-    check(buf1 == b'a' * 10)
+    check(buf1 == b"a" * 10)
 
     python_pybuffer.func2(buf2)
     check(buf2.startswith(b"Hello world!\x00"))
@@ -43,4 +43,4 @@
 
     buf3 = bytearray(b"hello")
     python_pybuffer.title1(buf3)
-    check(buf3 == b'Hello')
+    check(buf3 == b"Hello")
diff --git a/Examples/test-suite/python/python_strict_unicode_runme.py b/Examples/test-suite/python/python_strict_unicode_runme.py
index afb9e89..e7fae25 100644
--- a/Examples/test-suite/python/python_strict_unicode_runme.py
+++ b/Examples/test-suite/python/python_strict_unicode_runme.py
@@ -1,8 +1,8 @@
 import python_strict_unicode
 
-test_bytes   = b'hello \x01world\x99'
-BYTES        = b'BYTES'
-test_unicode = u'h\udce9llo w\u00f6rld'
+test_bytes   = b"hello \x01world\x99"
+BYTES        = b"BYTES"
+test_unicode = u"h\udce9llo w\u00f6rld"
 
 # Test that byte string inputs and outputs work as expected
 bdbl = python_strict_unicode.double_str(test_bytes)
@@ -20,12 +20,12 @@
 udbl = python_strict_unicode.double_wstr(test_unicode)
 if udbl != test_unicode + test_unicode:
     raise RuntimeError("Failed to double wide string")
-if type(udbl) != type(u''):
+if type(udbl) != type(u""):
     raise RuntimeError("Wrong type output for wide string")
 uout = python_strict_unicode.same_wstr(test_unicode)
 if uout != test_unicode:
     raise RuntimeError("Failed to copy wchar_t*")
-if type(uout) != type(u''):
+if type(uout) != type(u""):
     raise RuntimeError("Wrong type output for wchar_t*")
 
 # Test that overloading is handled properly
@@ -35,9 +35,9 @@
 if type(bovr) != type(BYTES):
     raise RuntimeError("Wrong type output from overload")
 uovr = python_strict_unicode.overload(test_unicode)
-if uovr != u'UNICODE':
+if uovr != u"UNICODE":
     raise RuntimeError("Failed to return unicode from overload")
-if type(uovr) != type(u''):
+if type(uovr) != type(u""):
     raise RuntimeERror("Wrong type output from overload")
 
 # Test that bytes aren't accepted as wide strings and unicode isn't accepted as narrow strings
diff --git a/Examples/test-suite/python/reference_global_vars_runme.py b/Examples/test-suite/python/reference_global_vars_runme.py
index 6c2d181..6f86527 100644
--- a/Examples/test-suite/python/reference_global_vars_runme.py
+++ b/Examples/test-suite/python/reference_global_vars_runme.py
@@ -13,8 +13,8 @@
 if value_bool(cvar.var_bool) != True:
     raise RuntimeError
 
-cvar.var_char = createref_char('w')
-if value_char(cvar.var_char) != 'w':
+cvar.var_char = createref_char("w")
+if value_char(cvar.var_char) != "w":
     raise RuntimeError
 
 cvar.var_unsigned_char = createref_unsigned_char(10)
diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py
index 63ff74c..7404cd5 100644
--- a/Examples/test-suite/python/std_containers_runme.py
+++ b/Examples/test-suite/python/std_containers_runme.py
@@ -60,9 +60,9 @@
 
 
 map = {}
-map['hello'] = 1
-map['hi'] = 2
-map['3'] = 2
+map["hello"] = 1
+map["hi"] = 2
+map["3"] = 2
 
 imap = std_containers.mapident(map)
 for k in map:
@@ -70,13 +70,13 @@
         raise RuntimeError, "bad map"
 
 # Test __contains__ (required for 'x in y' to work)
-if not imap.__contains__('hello'):
+if not imap.__contains__("hello"):
     raise RuntimeError("hello imap.__contains__")
-if 'hello' not in imap:
+if "hello" not in imap:
     raise RuntimeError("hello not in imap")
-if imap.__contains__('oops'):
+if imap.__contains__("oops"):
     raise RuntimeError("oops imap.__contains__")
-if 'oops' in imap:
+if "oops" in imap:
     raise RuntimeError("oops in imap")
 
 mapc = {}
diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py
index 346b05d..de232f5 100644
--- a/Examples/test-suite/python/swigobject_runme.py
+++ b/Examples/test-suite/python/swigobject_runme.py
@@ -15,11 +15,11 @@
 # match pointer value, but deal with leading zeros on 8/16 bit systems and
 # different C++ compilers interpretation of %p
 xstr1 = "%016X" % (lthis,)
-xstr1 = str.lstrip(xstr1, '0')
+xstr1 = str.lstrip(xstr1, "0")
 xstr2 = pointer_str(a)
 xstr2 = str.replace(xstr2, "0x", "")
 xstr2 = str.replace(xstr2, "0X", "")
-xstr2 = str.lstrip(xstr2, '0')
+xstr2 = str.lstrip(xstr2, "0")
 xstr2 = str.upper(xstr2)
 
 if xstr1 != xstr2:
diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py
index 3043d42..161bd51 100644
--- a/Examples/test-suite/python/template_typedef_cplx2_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py
@@ -11,8 +11,8 @@
     print d, "is not an instance"
     raise RuntimeError
 
-s = '%s' % d
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % d
+if str.find(s, "ArithUnaryFunction") == -1:
     print d, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -23,8 +23,8 @@
     print e, "is not an instance"
     raise RuntimeError
 
-s = '%s' % e
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % e
+if str.find(s, "ArithUnaryFunction") == -1:
     print e, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -40,8 +40,8 @@
     print c, "is not an instance"
     raise RuntimeError
 
-s = '%s' % c
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % c
+if str.find(s, "ArithUnaryFunction") == -1:
     print c, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -52,8 +52,8 @@
     print f, "is not an instance"
     raise RuntimeError
 
-s = '%s' % f
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % f
+if str.find(s, "ArithUnaryFunction") == -1:
     print f, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -68,8 +68,8 @@
     print g, "is not an instance"
     raise RuntimeError
 
-s = '%s' % g
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % g
+if str.find(s, "ArithUnaryFunction") == -1:
     print g, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -81,8 +81,8 @@
     print h, "is not an instance"
     raise RuntimeError
 
-s = '%s' % h
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % h
+if str.find(s, "ArithUnaryFunction") == -1:
     print h, "is not an ArithUnaryFunction"
     raise RuntimeError
 
diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py
index afb97d0..1846739 100644
--- a/Examples/test-suite/python/template_typedef_cplx_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx_runme.py
@@ -11,8 +11,8 @@
     print d, "is not an instance"
     raise RuntimeError
 
-s = '%s' % d
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % d
+if str.find(s, "ArithUnaryFunction") == -1:
     print d, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -23,8 +23,8 @@
     print e, "is not an instance"
     raise RuntimeError
 
-s = '%s' % e
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % e
+if str.find(s, "ArithUnaryFunction") == -1:
     print e, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -40,8 +40,8 @@
     print c, "is not an instance"
     raise RuntimeError
 
-s = '%s' % c
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % c
+if str.find(s, "ArithUnaryFunction") == -1:
     print c, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -52,8 +52,8 @@
     print f, "is not an instance"
     raise RuntimeError
 
-s = '%s' % f
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % f
+if str.find(s, "ArithUnaryFunction") == -1:
     print f, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -68,8 +68,8 @@
     print g, "is not an instance"
     raise RuntimeError
 
-s = '%s' % g
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % g
+if str.find(s, "ArithUnaryFunction") == -1:
     print g, "is not an ArithUnaryFunction"
     raise RuntimeError
 
@@ -81,7 +81,7 @@
     print h, "is not an instance"
     raise RuntimeError
 
-s = '%s' % h
-if str.find(s, 'ArithUnaryFunction') == -1:
+s = "%s" % h
+if str.find(s, "ArithUnaryFunction") == -1:
     print h, "is not an ArithUnaryFunction"
     raise RuntimeError
diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py
index 39e93b0..4e661f0 100644
--- a/Examples/test-suite/python/unicode_strings_runme.py
+++ b/Examples/test-suite/python/unicode_strings_runme.py
@@ -5,13 +5,13 @@
 # The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant
 # in 3.3+. Since this file is run through 2to3 before testing, though,
 # mark this as a unicode string in 2.x so it'll become a str in 3.x.
-test_string = u'h\udce9llo w\u00f6rld'
+test_string = u"h\udce9llo w\u00f6rld"
 
 if sys.version_info[0:2] >= (3, 1):
     if unicode_strings.non_utf8_c_str() != test_string:
-        raise ValueError('Test comparison mismatch')
+        raise ValueError("Test comparison mismatch")
     if unicode_strings.non_utf8_std_string() != test_string:
-        raise ValueError('Test comparison mismatch')
+        raise ValueError("Test comparison mismatch")
 
 def check(s1, s2):
     if s1 != s2:
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index 6393026..d75cdb0 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -20,7 +20,7 @@
 	li_std_queue \
 	li_std_set \
 	li_std_stack \
-	li_std_wstring \
+	li_std_wstring_inherit \
 	primitive_types \
 	ruby_alias_method \
 	ruby_keywords \
diff --git a/Examples/test-suite/ruby/li_std_containers_overload_runme.rb b/Examples/test-suite/ruby/li_std_containers_overload_runme.rb
new file mode 100644
index 0000000..913b611
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_containers_overload_runme.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+# 
+# 
+# 
+#
+
+require 'swig_assert'
+
+require 'li_std_containers_overload'
+
+include Li_std_containers_overload
+
+def check(got, expected)
+  if (got != expected)
+    raise RuntimeError, "Failed check. '#{got}' != '#{expected}'"
+  end
+end
+
+v = VectorX.new()
+check(VectorOverload(v), "vector<X>")
+
+v = VectorY.new()
+check(VectorOverload(v), "vector<Y>")
+
+v = VectorInt.new()
+check(VectorOverload(v), "vector<int>")
+
+v = VectorString.new()
+check(VectorOverload(v), "vector<string>")
+
+v = [X.new()]
+check(VectorOverload(v), "vector<X>")
+
+v = [Y.new()]
+check(VectorOverload(v), "vector<Y>")
+
+v = [1, 2, 3]
+check(VectorOverload(v), "vector<int>")
+
+v = ["aaa", "bbb", "ccc"]
+check(VectorOverload(v), "vector<string>")
diff --git a/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb
new file mode 100644
index 0000000..b5a90d8
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+require 'swig_assert'
+require 'li_std_wstring_inherit'
+x = "abc"
+swig_assert_equal("Li_std_wstring_inherit.test_value(Li_std_wstring_inherit::Wstring.new(x))", "x", binding)
+
+
+x = "y"
+swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding)
+a = Li_std_wstring_inherit::A.new(x)
+swig_assert_equal("Li_std_wstring_inherit.test_value(a)", "x", binding)
+
diff --git a/Examples/test-suite/ruby/li_std_wstring_runme.rb b/Examples/test-suite/ruby/li_std_wstring_runme.rb
index 0cf38ae..4922d8d 100644
--- a/Examples/test-suite/ruby/li_std_wstring_runme.rb
+++ b/Examples/test-suite/ruby/li_std_wstring_runme.rb
@@ -2,38 +2,48 @@
 require 'swig_assert'
 require 'li_std_wstring'
 
-x = "abc"
-swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", "x", binding)
-swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding)
-swig_assert_equal("Li_std_wstring.test_value(Li_std_wstring::Wstring.new(x))", "x", binding)
+h = "h"
+swig_assert_equal("Li_std_wstring.test_wcvalue(h)", "h", binding)
 
+x = "abc"
+swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding)
+swig_assert_equal("Li_std_wstring.test_cvalue(x)", "x", binding)
+
+swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", "x", binding)
 swig_assert_equal("Li_std_wstring.test_wchar_overload()", "nil", binding)
 
-swig_assert_equal("Li_std_wstring.test_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
-swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
-swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
-swig_assert_equal("Li_std_wstring.test_reference(Li_std_wstring::Wstring.new(x))", "nil", binding)
+Li_std_wstring.test_pointer(nil)
+Li_std_wstring.test_const_pointer(nil)
 
-x = "y"
-swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding)
-a = Li_std_wstring::A.new(x)
-swig_assert_equal("Li_std_wstring.test_value(a)", "x", binding)
+begin
+  Li_std_wstring.test_value(nil)
+  raise RuntimeError, "NULL check failed"
+rescue TypeError => e
+end
+
+begin
+  Li_std_wstring.test_reference(nil)
+  raise RuntimeError, "NULL check failed"
+rescue ArgumentError => e
+  swig_assert_simple(e.message.include? "invalid null reference")
+end
+begin
+  Li_std_wstring.test_const_reference(nil)
+  raise RuntimeError, "NULL check failed"
+rescue ArgumentError => e
+  swig_assert_simple(e.message.include? "invalid null reference")
+end
 
 x = "hello"
 swig_assert_equal("Li_std_wstring.test_const_reference(x)", "x", binding)
 
-
-swig_assert_equal("Li_std_wstring.test_pointer_out", "'x'", binding)
-swig_assert_equal("Li_std_wstring.test_const_pointer_out", "'x'", binding)
-swig_assert_equal("Li_std_wstring.test_reference_out()", "'x'", binding)
-
 s = "abc"
 swig_assert("Li_std_wstring.test_equal_abc(s)", binding)
 
 begin
   Li_std_wstring.test_throw
 rescue RuntimeError => e
-  swig_assert_equal("e.message", "'x'", binding)
+  swig_assert_equal("e.message", "'throwing test_throw'", binding)
 end
 
 x = "abc\0def"
diff --git a/Examples/test-suite/typemap_template_parms.i b/Examples/test-suite/typemap_template_parms.i
index fd0f7f5..90231e8 100644
--- a/Examples/test-suite/typemap_template_parms.i
+++ b/Examples/test-suite/typemap_template_parms.i
@@ -26,3 +26,16 @@
 %}
 
 %template(Xint) X<int>;
+
+
+// The function name and parameter name are both 'labels'
+%inline %{
+template <typename T>
+void labels(T labels) {}
+void voido(int vooo) {}
+%}
+
+// TODO: R has a problem with parameter names clashing with the function name
+#if !defined(SWIGR)
+%template(ShortLabels) labels<short>;
+#endif
diff --git a/Lib/csharp/arrays_csharp.i b/Lib/csharp/arrays_csharp.i
index 237067a..861da83 100644
--- a/Lib/csharp/arrays_csharp.i
+++ b/Lib/csharp/arrays_csharp.i
@@ -103,7 +103,47 @@
 CSHARP_ARRAYS(unsigned long long, ulong)
 CSHARP_ARRAYS(float, float)
 CSHARP_ARRAYS(double, double)
-CSHARP_ARRAYS(bool, bool)
+
+// By default C# will marshal bools as 4 bytes
+// UnmanagedType.I1 will change this to 1 byte
+// FIXME - When running on mono ArraySubType appears to be ignored and bools will be marshalled as 4-byte
+// https://github.com/mono/mono/issues/15592
+
+// input only arrays
+%typemap(ctype)   bool INPUT[] "bool*"
+%typemap(cstype)  bool INPUT[] "bool[]"
+%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool INPUT[] "bool[]"
+%typemap(csin)    bool INPUT[] "$csinput"
+
+%typemap(in)      bool INPUT[] %{
+$1 = $input;
+%}
+%typemap(freearg) bool INPUT[] ""
+%typemap(argout)  bool INPUT[] ""
+
+// output only arrays
+%typemap(ctype)   bool OUTPUT[] "bool*"
+%typemap(cstype)  bool OUTPUT[] "bool[]"
+%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool OUTPUT[] "bool[]"
+%typemap(csin)    bool OUTPUT[] "$csinput"
+
+%typemap(in)      bool OUTPUT[] %{
+$1 = $input;
+%}
+%typemap(freearg) bool OUTPUT[] ""
+%typemap(argout)  bool OUTPUT[] ""
+
+// inout arrays
+%typemap(ctype)   bool INOUT[] "bool*"
+%typemap(cstype)  bool INOUT[] "bool[]"
+%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool INOUT[] "bool[]"
+%typemap(csin)    bool INOUT[] "$csinput"
+
+%typemap(in)      bool INOUT[] %{
+$1 = $input;
+%}
+%typemap(freearg) bool INOUT[] ""
+%typemap(argout)  bool INOUT[] ""
 
 
 %define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE )
diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i
index 3b2492e..82f010a 100644
--- a/Lib/csharp/std_set.i
+++ b/Lib/csharp/std_set.i
@@ -30,7 +30,7 @@
 
 %typemap(csinterfaces) std::set<T> "global::System.IDisposable, global::System.Collections.Generic.ISet<$typemap(cstype, T)>\n";
 %proxycode %{
-  void global::System.Collections.Generic.ICollection<$typemap(cstype, T)>.Add(string item) {
+  void global::System.Collections.Generic.ICollection<$typemap(cstype, T)>.Add($typemap(cstype, T) item) {
       ((global::System.Collections.Generic.ISet<$typemap(cstype, T)>)this).Add(item);
   }
 
@@ -192,7 +192,7 @@
     private $csclassname collectionRef;
     private global::System.Collections.Generic.IList<$typemap(cstype, T)> ItemsCollection;
     private int currentIndex;
-    private $typemap(cstype, T) currentObject;
+    private object currentObject;
     private int currentSize;
 
     public $csclassnameEnumerator($csclassname collection) {
@@ -212,7 +212,7 @@
           throw new global::System.InvalidOperationException("Enumeration finished.");
         if (currentObject == null)
           throw new global::System.InvalidOperationException("Collection modified.");
-        return currentObject;
+        return ($typemap(cstype, T))currentObject;
       }
     }
 
diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i
index 09bdaaa..162b90e 100644
--- a/Lib/csharp/std_wstring.i
+++ b/Lib/csharp/std_wstring.i
@@ -23,7 +23,10 @@
 
 // wstring
 %typemap(ctype, out="void *") wstring "wchar_t *"
-%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") wstring "string"
+%typemap(imtype,
+         inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
+         outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
+         ) wstring "string"
 %typemap(cstype) wstring "string"
 %typemap(csdirectorin) wstring "$iminput"
 %typemap(csdirectorout) wstring "$cscall"
@@ -60,7 +63,10 @@
 
 // const wstring &
 %typemap(ctype, out="void *") const wstring & "wchar_t *"
-%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") const wstring & "string"  
+%typemap(imtype,
+         inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
+         outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
+         ) const wstring & "string"
 %typemap(cstype) const wstring & "string"
 
 %typemap(csdirectorin) const wstring & "$iminput"
diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i
index 9361edf..7981941 100644
--- a/Lib/csharp/wchar.i
+++ b/Lib/csharp/wchar.i
@@ -20,6 +20,7 @@
 %pragma(csharp) imclasscode=%{
   protected class SWIGWStringHelper {
 
+    [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]
     public delegate string SWIGWStringDelegate(global::System.IntPtr message);
     static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);
 
@@ -52,7 +53,7 @@
 
 // wchar_t
 %typemap(ctype) wchar_t "wchar_t"
-%typemap(imtype) wchar_t "char"
+%typemap(imtype) wchar_t "char" // Requires adding CharSet=CharSet.Unicode to the DllImport to correctly marshal Unicode characters
 %typemap(cstype) wchar_t "char"
 
 %typemap(csin) wchar_t "$csinput"
diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg
index 685bba1..2e10254 100644
--- a/Lib/java/javahead.swg
+++ b/Lib/java/javahead.swg
@@ -5,7 +5,7 @@
  * ----------------------------------------------------------------------------- */
 
 
-/* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so 
+/* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so
  * that the same typemaps can be used for generating code for both C and C++. The SWIG preprocessor can expand
  * the macros thereby generating the correct calling convention. It is thus essential that all typemaps that
  * use the macros are not within %{ %} brackets as they won't be run through the SWIG preprocessor. */
@@ -50,15 +50,16 @@
 %insert(runtime) %{
 /* Support for throwing Java exceptions */
 typedef enum {
-  SWIG_JavaOutOfMemoryError = 1, 
-  SWIG_JavaIOException, 
-  SWIG_JavaRuntimeException, 
+  SWIG_JavaOutOfMemoryError = 1,
+  SWIG_JavaIOException,
+  SWIG_JavaRuntimeException,
   SWIG_JavaIndexOutOfBoundsException,
   SWIG_JavaArithmeticException,
   SWIG_JavaIllegalArgumentException,
   SWIG_JavaNullPointerException,
   SWIG_JavaDirectorPureVirtual,
-  SWIG_JavaUnknownError
+  SWIG_JavaUnknownError,
+  SWIG_JavaIllegalStateException,
 } SWIG_JavaExceptionCodes;
 
 typedef struct {
@@ -80,6 +81,7 @@
     { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
     { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
     { SWIG_JavaUnknownError,  "java/lang/UnknownError" },
+    { SWIG_JavaIllegalStateException, "java/lang/IllegalStateException" },
     { (SWIG_JavaExceptionCodes)0,  "java/lang/UnknownError" }
   };
   const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i
index 04658f7..73e0c2c 100644
--- a/Lib/java/std_set.i
+++ b/Lib/java/std_set.i
@@ -57,6 +57,10 @@
     return sizeImpl();
   }
 
+  public boolean add($typemap(jboxtype, T) key) {
+    return addImpl(key);
+  }
+
   public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
     boolean didAddElement = false;
     for (java.lang.Object object : collection) {
@@ -172,7 +176,7 @@
       %fragment("SWIG_SetSize");
 
       // Returns whether item was inserted.
-      bool add(const T& key) {
+      bool addImpl(const T& key) {
         return self->insert(key).second;
       }
 
diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i
index 955e20c..60ee23e 100644
--- a/Lib/java/std_vector.i
+++ b/Lib/java/std_vector.i
@@ -29,6 +29,8 @@
 %proxycode %{
   public $javaclassname($typemap(jstype, CTYPE)[] initialElements) {
     this();
+    reserve(initialElements.length);
+
     for ($typemap(jstype, CTYPE) element : initialElements) {
       add(element);
     }
@@ -181,4 +183,3 @@
 %define specialize_std_vector(T)
 #warning "specialize_std_vector - specialization for type T no longer needed"
 %enddef
-
diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
index 9636cdc..bd764d6 100644
--- a/Lib/lua/luarun.swg
+++ b/Lib/lua/luarun.swg
@@ -289,7 +289,7 @@
 typedef struct {
   swig_type_info   *type;
   int     own;  /* 1 if owned & must be destroyed */
-  char data[1];       /* arbitrary amount of data */    
+  char data[1];       /* arbitrary amount of data */
 } swig_lua_rawdata;
 
 /* Common SWIG API */
@@ -341,7 +341,7 @@
 #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))
 
 #ifdef __cplusplus
-/* Special helper for member function pointers 
+/* Special helper for member function pointers
 it gets the address, casts it, then dereferences it */
 /*#define SWIG_mem_fn_as_voidptr(a)  (*((char**)&(a))) */
 #endif
@@ -444,7 +444,7 @@
           lua_pop(L,1); /*remove nil */
           lua_newtable(L);
           SWIG_Lua_elua_emulate_register(L,entry->value.value.table);
-        } 
+        }
         if(is_metatable) {
           assert(lua_istable(L,-1));
           lua_pushvalue(L,-1);
@@ -453,11 +453,11 @@
 
         break;
       case LUA_TUSERDATA:
-        if(entry->value.value.userdata.member) 
+        if(entry->value.value.userdata.member)
           SWIG_NewMemberObj(L,entry->value.value.userdata.pvalue,
               entry->value.value.userdata.lvalue,
               *(entry->value.value.userdata.ptype));
-        else 
+        else
           SWIG_NewPointerObj(L,entry->value.value.userdata.pvalue,
               *(entry->value.value.userdata.ptype),0);
         break;
@@ -502,7 +502,7 @@
   }
   assert(lua_gettop(L) == 2);
   return 1;
-  
+
 fail:
   lua_error(L);
   return 0;
@@ -520,7 +520,7 @@
   lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable);
   lua_rawset(L,-3);
   lua_pop(L,2);
-      
+
 }
 /* END OF REMOVE */
 
@@ -1039,17 +1039,11 @@
 {
 /*  there should be 1 param passed in
   (1) userdata (not the metatable) */
-  const char *className;
-  void* userData;
+  swig_lua_userdata* userData;
   assert(lua_isuserdata(L,1));  /* just in case */
-  userData = lua_touserdata(L,1); /* get the userdata address for later */
-  lua_getmetatable(L,1);    /* get the meta table */
-  assert(lua_istable(L,-1));  /* just in case */
+  userData = (swig_lua_userdata*)lua_touserdata(L,1); /* get the userdata address */
 
-  lua_getfield(L, -1, ".type");
-  className = lua_tostring(L, -1);
-
-  lua_pushfstring(L, "<%s userdata: %p>", className, userData);
+  lua_pushfstring(L, "<userdata of type '%s' at %p>", userData->type->str, userData->ptr);
   return 1;
 }
 
@@ -1061,7 +1055,7 @@
   swig_lua_userdata *usr;
   assert(lua_isuserdata(L,-1));  /* just in case */
   usr=(swig_lua_userdata*)lua_touserdata(L,-1);  /* get it */
-  
+
   usr->own = 0; /* clear our ownership */
   return 0;
 }
@@ -1170,7 +1164,7 @@
 Each class structure has a list of pointers to the base class structures.
 This function fills them.
 It cannot be done at compile time, as this will not work with hireachies
-spread over more than one swig file. 
+spread over more than one swig file.
 Therefore it must be done at runtime, querying the SWIG type system.
 */
 SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss)
@@ -1404,11 +1398,11 @@
 
   lua_checkstack(L,5);
   numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */
-  
+
   /* Get upvalues from closure */
   lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/
   metamethod_name_idx = lua_gettop(L);
-  
+
   lua_pushvalue(L, lua_upvalueindex(2));
   clss = (const swig_lua_class*)(lua_touserdata(L,-1));
   lua_pop(L,1); /* remove lightuserdata with clss from stack */
@@ -1440,7 +1434,7 @@
 
   /* metamethod name - on the top of the stack */
   assert(lua_isstring(L,-1));
-  
+
   key_index = lua_gettop(L);
 
   /* Check whether method is already defined in metatable */
@@ -1450,7 +1444,7 @@
     lua_pop(L,1);
     return -1;
   }
-  lua_pop(L,1); 
+  lua_pop(L,1);
 
   /* Iterating over immediate bases */
   for(i=0;clss->bases[i];i++)
@@ -1460,13 +1454,13 @@
     lua_pushvalue(L, key_index);
     lua_rawget(L, -2);
     if( !lua_isnil(L,-1) ) {
-      lua_pushvalue(L, key_index); 
+      lua_pushvalue(L, key_index);
 
       /* Add proxy function */
       lua_pushvalue(L, key_index); /* first closure value is function name */
       lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */
       lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2);
-      
+
       lua_rawset(L, metatable_index);
       success = 1;
     }
@@ -1477,7 +1471,7 @@
       break;
   }
 
-  return success; 
+  return success;
 }
 
 SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss)
@@ -1816,7 +1810,7 @@
   memcpy(raw->data,ptr,size); /* copy the data */
   SWIG_Lua_AddMetatable(L,type); /* add metatable */
 }
-    
+
 /* converts a packed userdata. user for member fn pointers only */
 SWIGRUNTIME int  SWIG_Lua_ConvertPacked(lua_State *L,int index,void *ptr,size_t size,swig_type_info *type)
 {
@@ -1915,7 +1909,7 @@
 In lua 5.0.X it's lua_dostring()
 In lua 5.1.X it's luaL_dostring()
 */
-SWIGINTERN int 
+SWIGINTERN int
 SWIG_Lua_dostring(lua_State *L, const char *str) {
   int ok,top;
   if (str==0 || str[0]==0) return 0; /* nothing to do */
@@ -1930,7 +1924,7 @@
   }
   lua_settop(L,top); /* restore the stack */
   return ok;
-}    
+}
 
 #ifdef __cplusplus
 }
diff --git a/Lib/ocaml/ocaml.i b/Lib/ocaml/ocaml.i
index 96a36c8..cc26d18 100644
--- a/Lib/ocaml/ocaml.i
+++ b/Lib/ocaml/ocaml.i
@@ -8,7 +8,7 @@
 %insert(runtime) "swigrun.swg"
 
 /* Include headers */
-%insert(runtime) "ocamldec.swg"
+%insert(runtime) "ocamlrundec.swg"
 
 /* Type registration */
 %insert(init) "swiginit.swg"
@@ -28,18 +28,14 @@
 %}
 
 /*#ifndef SWIG_NOINCLUDE*/
-%insert(runtime) "ocaml.swg"
+%insert(runtime) "ocamlrun.swg"
 /*#endif*/
 
 %insert(classtemplate) "class.swg"
 
-/* Definitions */
-#define SWIG_malloc(size) swig_malloc(size, FUNC_NAME)
-#define SWIG_free(mem) free(mem)
-
 /* Read in standard typemaps. */
 %include <swig.swg>
-%include <typemaps.i>
+%include <ocaml.swg>
 %include <typecheck.i>
 %include <exception.i>
 %include <preamble.swg>
diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg
index 3d552cc..ac496bd 100644
--- a/Lib/ocaml/ocaml.swg
+++ b/Lib/ocaml/ocaml.swg
@@ -1,607 +1,311 @@
-/* -*-c-*- */
+/* -----------------------------------------------------------------------------
+ * ocaml.swg
+ *
+ * The Ocaml module handles all types uniformly via typemaps. Here
+ * are the definitions.
+ * ----------------------------------------------------------------------------- */
 
-/* SWIG pointer structure */
+/* Pointers */
 
-#include <string.h>
-#include <assert.h>
+%typemap(in) void ""
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+%typemap(out) void "$result = Val_int(0);"
 
-#define C_bool 0
-#define C_char 1
-#define C_uchar 2
-#define C_short 3
-#define C_ushort 4
-#define C_int 5
-#define C_uint 6
-#define C_int32 7
-#define C_int64 8
-#define C_float 9
-#define C_double 10
-#define C_ptr 11
-#define C_array 12
-#define C_list 13
-#define C_obj 14
-#define C_string 15
-#define C_enum 16
-#define C_director_core 17
+%typemap(in) void * {
+    $1 = caml_ptr_val($input,$descriptor);
+}
 
+%typemap(varin) void * {
+    $1 = ($ltype)caml_ptr_val($input,$descriptor);
+}
 
-/* Cast a pointer if possible; returns 1 if successful */
-    
-    SWIGINTERN int
-    SWIG_Cast (void *source, swig_type_info *source_type,
-	       void **ptr, swig_type_info *dest_type)
-    {
-	if( !source ) { /* Special case for NULL.  This is a popular question
-	     for other modules on the list, so I want an easy way out... */
-	    *ptr = 0;
-	    return 0;
-	}
+%typemap(out) void * {
+    $result = caml_val_ptr($1,$descriptor);
+}
 
-#ifdef TYPE_CAST_VERBOSE
-	fprintf( stderr, "Trying to cast %s to %s\n", 
-		 source_type ? source_type->str : "<none>",
-		 dest_type ? dest_type->str : "<none>" );
-#endif
-	if (dest_type != source_type) {
-	    /* We have a type mismatch.  Will have to look through our type
-	       mapping table to figure out whether or not we can accept this
-	       datatype. 
-	       --
-	       Ignore typechecks for void *.  Allow any conversion. */
-	    if( !dest_type || !source_type || 
-		!strcmp(dest_type->name,"_p_void") ||
-		!strcmp(source_type->name,"_p_void") ) {
-		*ptr = source;
-		return 0;
-	    } else {
-		swig_cast_info *tc = 
-		    SWIG_TypeCheckStruct(source_type, dest_type );
-#ifdef TYPE_CAST_VERBOSE
-		fprintf( stderr, "Typecheck -> %s\n",
-			 tc ? tc->type->str : "<none>" );
-#endif
-		if( tc ) {
-		    int newmemory = 0;
-		    *ptr = SWIG_TypeCast(tc, source, &newmemory);
-		    assert(!newmemory); /* newmemory handling not yet implemented */
-		    return 0;
-		} else
-		    return -1;
-	    }
-	} else {
-	    *ptr = source;
-	    return 0;
-	}
+%typemap(varout) void * {
+    $result = caml_val_ptr($1,$descriptor);
+}
+
+%typemap(in) char *& (char *temp) {
+  temp = (char*)caml_val_ptr($1,$descriptor);
+  $1 = &temp;
+}
+
+%typemap(argout) char *& {
+  swig_result =	caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1)));
+}
+
+%typemap(in) SWIGTYPE & {
+    $1 = ($ltype) caml_ptr_val($input,$1_descriptor);
+}
+
+%typemap(in) SWIGTYPE && {
+    $1 = ($ltype) caml_ptr_val($input,$1_descriptor);
+}
+
+%typemap(varin) SWIGTYPE & {
+    $1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
+}
+
+%typemap(varin) SWIGTYPE && {
+    $1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
+}
+
+%typemap(varout) SWIGTYPE &, SWIGTYPE && {
+    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)&$1, $1_descriptor);
+}
+
+%typemap(out) SWIGTYPE &, SWIGTYPE && {
+    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, $1_descriptor);
+}
+
+#if 0
+%typemap(argout) SWIGTYPE & {
+    CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
+    if( fromval ) {
+	swig_result =
+	    caml_list_append(swig_result,
+			     caml_callback(*fromval,caml_val_ptr((void *) $1,
+							    $1_descriptor)));
+    } else {
+	swig_result =
+	    caml_list_append(swig_result,
+			     caml_val_ptr ((void *) $1,$1_descriptor));
     }
-
-/* Return 0 if successful. */
-    SWIGINTERN int
-    SWIG_GetPtr(void *inptr, void **outptr, 
-		swig_type_info *intype, swig_type_info *outtype) {
-	if (intype) {
-	    return SWIG_Cast(inptr, intype,
-			     outptr, outtype) == -1;
-	} else {
-	    *outptr = inptr;
-	    return 0;
-	}
+}
+%typemap(argout) SWIGTYPE && {
+    CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
+    if( fromval ) {
+	swig_result =
+	    caml_list_append(swig_result,
+			     caml_callback(*fromval,caml_val_ptr((void *) $1,
+							    $1_descriptor)));
+    } else {
+	swig_result =
+	    caml_list_append(swig_result,
+			     caml_val_ptr ((void *) $1,$1_descriptor));
     }
-
-    SWIGINTERN void caml_print_list( CAML_VALUE v );
-
-    SWIGINTERN void caml_print_val( CAML_VALUE v ) {
-	switch( SWIG_Tag_val(v) ) {
-	case C_bool:
-	    if( Bool_val(SWIG_Field(v,0)) ) fprintf( stderr, "true " );
-	    else fprintf( stderr, "false " );
-	    break;
-	case C_char:
-	case C_uchar:
-	    fprintf( stderr, "'%c' (\\%03d) ", 
-		     (Int_val(SWIG_Field(v,0)) >= ' ' &&
-		      Int_val(SWIG_Field(v,0)) < 127) ? Int_val(SWIG_Field(v,0)) : '.',
-		     Int_val(SWIG_Field(v,0)) );
-	    break;
-	case C_short:
-	case C_ushort:
-	case C_int:
-	    fprintf( stderr, "%d ", (int)caml_long_val(v) );
-	    break;
-
-	case C_uint:
-	case C_int32:
-	    fprintf( stderr, "%ud ", (unsigned int)caml_long_val(v) );
-	    break;
-	case C_int64:
-	    fprintf( stderr, "%ld ", caml_long_val(v) );
-	    break;
-	case C_float:
-	case C_double:
-	    fprintf( stderr, "%f ", caml_double_val(v) );
-	    break;
-
-	case C_ptr:
-	{
-	    void *vout = 0;
-	    swig_type_info *ty = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1));
-	    caml_ptr_val_internal(v,&vout,0);
-	    fprintf( stderr, "PTR(%p,%s) ", 
-		     vout,
-		     ty ? ty->name : "(null)" );
-	}
-	break;
-	case C_array:
-	{
-	    unsigned int i;
-	    for( i = 0; i < Wosize_val( SWIG_Field(v,0) ); i++ ) 
-		caml_print_val( SWIG_Field(SWIG_Field(v,0),i) );
-	}
-	break;
-	case C_list:
-	    caml_print_list( SWIG_Field(v,0) );
-	    break;
-	case C_obj:
-	    fprintf( stderr, "OBJ(%p) ", (void *)SWIG_Field(v,0) );
-	    break;
-	case C_string:
-	{
-	    void *cout;
-	    caml_ptr_val_internal(v,&cout,0);
-	    fprintf( stderr, "'%s' ", (char *)cout );
-	} 
-	break;
-	}
-    }
-
-    SWIGINTERN void caml_print_list( CAML_VALUE v ) {
-	CAMLparam1(v);
-	while( v && Is_block(v) ) {
-	    fprintf( stderr, "[ " );
-	    caml_print_val( SWIG_Field(v,0) );
-	    fprintf( stderr, "]\n" );
-	    v = SWIG_Field(v,1);
-	}
-	CAMLreturn0;
-    }
-
-    SWIGINTERN CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) {
-	CAMLparam1(lst);
-	int i = 0;
-	while( i < n && lst && Is_block(lst) ) {
-	    i++; lst = SWIG_Field(lst,1);
-	}
-	if( lst == Val_unit ) CAMLreturn(Val_unit);
-	else CAMLreturn(SWIG_Field(lst,0));
-    }
-    
-    SWIGINTERN CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) {
-	CAMLparam2(lst,elt);
-	SWIG_CAMLlocal3(v,vt,lh);
-	lh = Val_unit;
-	v = Val_unit;
-
-	/* Appending C_void should have no effect */
-	if( !Is_block(elt) ) return lst;
-
-	while( lst && Is_block(lst) ) {
-	    if( v && v != Val_unit ) {
-		vt = caml_alloc_tuple(2);
-		SWIG_Store_field(v,1,vt);
-		v = vt;
-	    } else {
-		v = lh = caml_alloc_tuple(2);
-	    }
-	    SWIG_Store_field(v,0,SWIG_Field(lst,0));
-	    lst = SWIG_Field(lst,1);
-	}
-
-	if( v && Is_block(v) ) {
-	    vt = caml_alloc_tuple(2);
-	    SWIG_Store_field(v,1,vt);
-	    v = vt;
-	} else {
-	    v = lh = caml_alloc_tuple(2);
-	}
-	SWIG_Store_field(v,0,elt);
-	SWIG_Store_field(v,1,Val_unit);
-
-	CAMLreturn(lh);
-    }
-
-    SWIGINTERN int caml_list_length( CAML_VALUE lst ) {
-	CAMLparam1(lst);
-	int i = 0;
-	while( lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); }
-	CAMLreturn(i);
-    }
-
-    SWIGINTERN void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) {
-	CAMLparam2(arr,item);
-	SWIG_Store_field(SWIG_Field(arr,0),n,item);
-	CAMLreturn0;
-    }
-
-    SWIGINTERN value caml_array_nth( CAML_VALUE arr, int n ) {
-	CAMLparam1(arr);
-	if( SWIG_Tag_val(arr) == C_array )
-	    CAMLreturn(SWIG_Field(SWIG_Field(arr,0),n));
-	else if( SWIG_Tag_val(arr) == C_list )
-	    CAMLreturn(caml_list_nth(arr,0));
-	else
-	    caml_failwith("Need array or list");
-    }
-
-    SWIGINTERN int caml_array_len( CAML_VALUE arr ) {
-	CAMLparam1(arr);
-	if( SWIG_Tag_val(arr) == C_array )
-	    CAMLreturn(Wosize_val(SWIG_Field(arr,0)));
-	else if( SWIG_Tag_val(arr) == C_list )
-	    CAMLreturn(caml_list_length(arr));
-	else
-	    caml_failwith("Need array or list");
-    }
-
-    SWIGINTERN CAML_VALUE caml_swig_alloc(int x,int y) {
-	return caml_alloc(x,y);
-    }
-
-    SWIGINTERN value caml_array_new( int n ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(vv);
-	vv = caml_swig_alloc(1,C_array);
-	SWIG_Store_field(vv,0,caml_alloc_tuple(n));
-	CAMLreturn(vv);
-    }
-    
-    SWIGINTERN CAML_VALUE caml_val_bool( int b ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(bv);
-	bv = caml_swig_alloc(1,C_bool);
-	SWIG_Store_field(bv,0,Val_bool(b));
-	CAMLreturn(bv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_char( char c ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(cv);
-	cv = caml_swig_alloc(1,C_char);
-	SWIG_Store_field(cv,0,Val_int(c));
-	CAMLreturn(cv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_uchar( unsigned char uc ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(ucv);
-	ucv = caml_swig_alloc(1,C_uchar);
-	SWIG_Store_field(ucv,0,Val_int(uc));
-	CAMLreturn(ucv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_short( short s ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(sv);
-	sv = caml_swig_alloc(1,C_short);
-	SWIG_Store_field(sv,0,Val_int(s));
-	CAMLreturn(sv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_ushort( unsigned short us ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(usv);
-	usv = caml_swig_alloc(1,C_ushort);
-	SWIG_Store_field(usv,0,Val_int(us));
-	CAMLreturn(usv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_int( int i ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(iv);
-	iv = caml_swig_alloc(1,C_int);
-	SWIG_Store_field(iv,0,Val_int(i));
-	CAMLreturn(iv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_uint( unsigned int ui ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(uiv);
-	uiv = caml_swig_alloc(1,C_int);
-	SWIG_Store_field(uiv,0,Val_int(ui));
-	CAMLreturn(uiv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_long( long l ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(lv);
-	lv = caml_swig_alloc(1,C_int64);
-	SWIG_Store_field(lv,0,caml_copy_int64(l));
-	CAMLreturn(lv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_ulong( unsigned long ul ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(ulv);
-	ulv = caml_swig_alloc(1,C_int64);
-	SWIG_Store_field(ulv,0,caml_copy_int64(ul));
-	CAMLreturn(ulv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_float( float f ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(fv);
-	fv = caml_swig_alloc(1,C_float);
-	SWIG_Store_field(fv,0,caml_copy_double((double)f));
-	CAMLreturn(fv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_double( double d ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(fv);
-	fv = caml_swig_alloc(1,C_double);
-	SWIG_Store_field(fv,0,caml_copy_double(d));
-	CAMLreturn(fv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(vv);
-	vv = caml_swig_alloc(2,C_ptr);
-	SWIG_Store_field(vv,0,caml_copy_int64((long)p));
-	SWIG_Store_field(vv,1,caml_copy_int64((long)info));
-	CAMLreturn(vv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_string( const char *p ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(vv);
-	if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 ));
-	vv = caml_swig_alloc(1,C_string);
-	SWIG_Store_field(vv,0,caml_copy_string(p));
-	CAMLreturn(vv);
-    }
-
-    SWIGINTERN CAML_VALUE caml_val_string_len( const char *p, int len ) {
-	CAMLparam0();
-	SWIG_CAMLlocal1(vv);
-	if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 ));
-	vv = caml_swig_alloc(1,C_string);
-	SWIG_Store_field(vv,0,caml_alloc_string(len));
-	memcpy(String_val(SWIG_Field(vv,0)),p,len);
-	CAMLreturn(vv);
-    }
-
-    #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name)
-    SWIGINTERN CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) {
-	CAMLparam0();
-	CAMLreturn(caml_callback2(*caml_named_value("caml_create_object_fn"),
-			     caml_val_ptr(v,type),
-			     caml_copy_string(name)));
-    }
-
-    SWIGINTERN long caml_long_val_full( CAML_VALUE v, const char *name ) {
-	CAMLparam1(v);
-	if( !Is_block(v) ) return 0;
-
-	switch( SWIG_Tag_val(v) ) {
-	case C_bool:
-	case C_char:
-	case C_uchar:
-	case C_short:
-	case C_ushort:
-	case C_int:
-	    CAMLreturn(Int_val(SWIG_Field(v,0)));
-	case C_uint:
-	case C_int32:
-	    CAMLreturn(Int32_val(SWIG_Field(v,0)));
-	case C_int64:
-	    CAMLreturn((long)SWIG_Int64_val(SWIG_Field(v,0)));
-	case C_float:
-	case C_double:
-	    CAMLreturn((long)Double_val(SWIG_Field(v,0)));
-	case C_string:
-	    CAMLreturn((long)String_val(SWIG_Field(v,0)));
-	case C_ptr:
-	    CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0)));
-	case C_enum: {
-	    SWIG_CAMLlocal1(ret);
-	    CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int");
-	    if( !name ) caml_failwith( "Not an enum conversion" );
-	    ret = caml_callback2(*enum_to_int,*caml_named_value(name),v);
-	    CAMLreturn(caml_long_val(ret));
-	}
-	default:
-	    caml_failwith("No conversion to int");
-	}
-    }
-
-    SWIGINTERN long caml_long_val( CAML_VALUE v ) {
-	return caml_long_val_full(v,0);
-    }
-
-    SWIGINTERN double caml_double_val( CAML_VALUE v ) {
-	CAMLparam1(v);
-	if( !Is_block(v) ) return 0.0;
-	switch( SWIG_Tag_val(v) ) {
-	case C_bool:
-	case C_char:
-	case C_uchar:
-	case C_short:
-	case C_ushort:
-	case C_int:
-	    CAMLreturn_type(Int_val(SWIG_Field(v,0)));
-	case C_uint:
-	case C_int32:
-	    CAMLreturn_type(Int32_val(SWIG_Field(v,0)));
-	case C_int64:
-	    CAMLreturn_type(SWIG_Int64_val(SWIG_Field(v,0)));
-	case C_float:
-	case C_double:
-	    CAMLreturn_type(Double_val(SWIG_Field(v,0)));
-	default:
-	    fprintf( stderr, "Unknown block tag %d\n", SWIG_Tag_val(v) );
-	    caml_failwith("No conversion to double");
-	}
-    }
-
-    SWIGINTERN int caml_ptr_val_internal( CAML_VALUE v, void **out,
-					  swig_type_info *descriptor ) {
-	CAMLparam1(v);
-	void *outptr = NULL;
-        swig_type_info *outdescr = NULL;
-        static CAML_VALUE *func_val = NULL;
-
-	if( v == Val_unit ) {
-	    *out = 0;
-	    CAMLreturn_type(0);
-	}
-	if( !Is_block(v) ) return -1;
-	switch( SWIG_Tag_val(v) ) {
-	case C_obj:
-	    if (!func_val) {
-	        func_val = caml_named_value("caml_obj_ptr");
-	    }
-	    CAMLreturn_type(caml_ptr_val_internal(caml_callback(*func_val, v), out, descriptor));
-	case C_string:
-	    outptr = (void *)String_val(SWIG_Field(v,0));
-	    break;
-	case C_ptr:
-	    outptr = (void *)(long)SWIG_Int64_val(SWIG_Field(v,0));
-            outdescr = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1));
-	    break;
-	default:
-	    *out = 0;
-	    CAMLreturn_type(1);
-	    break;
-	}
-
-	CAMLreturn_type(SWIG_GetPtr(outptr, out, outdescr, descriptor));
-    }
-
-    SWIGINTERN void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) {
-        CAMLparam0();
-#ifdef TYPE_CAST_VERBOSE
-	caml_print_val( v );
-#endif
-	void *out = NULL;
-	if( !caml_ptr_val_internal( v, &out, descriptor ) )
-	    CAMLreturn_type(out);
-	else
-	    caml_failwith( "No appropriate conversion found." );
-    }
-
-    SWIGINTERN char *caml_string_val( CAML_VALUE v ) {
-	return (char *)caml_ptr_val( v, 0 );
-    }
-
-    SWIGINTERN int caml_string_len( CAML_VALUE v ) {
-	switch( SWIG_Tag_val(v) ) {
-	case C_string:
-	    return caml_string_length(SWIG_Field(v,0));
-	default:
-	    return strlen((char *)caml_ptr_val(v,0));
-	}
-    }
-
-    SWIGINTERN int caml_bool_check( CAML_VALUE v ) {
-	CAMLparam1(v);
-	
-	if( !Is_block(v) ) return 0;
-	
-	switch( SWIG_Tag_val(v) ) {
-	case C_bool:
-	case C_ptr:
-	case C_string:
-	    CAMLreturn(1);
-	default:
-	    CAMLreturn(0);
-	}
-    }
-
-    SWIGINTERN int caml_int_check( CAML_VALUE v ) {
-	CAMLparam1(v);
-	
-	if( !Is_block(v) ) return 0;
-	
-	switch( SWIG_Tag_val(v) ) {
-	case C_char:
-	case C_uchar:
-	case C_short:
-	case C_ushort:
-	case C_int:
-	case C_uint:
-	case C_int32:
-	case C_int64:
-	    CAMLreturn(1);
-
-	default:
-	    CAMLreturn(0);
-	}
-    }
-
-    SWIGINTERN int caml_float_check( CAML_VALUE v ) {
-	CAMLparam1(v);
-	if( !Is_block(v) ) return 0;
-
-	switch( SWIG_Tag_val(v) ) {
-	case C_float:
-	case C_double:
-	    CAMLreturn(1);
-
-	default:
-	    CAMLreturn(0);
-	}	
-    }
-
-    SWIGINTERN int caml_ptr_check( CAML_VALUE v ) {
-	CAMLparam1(v);
-	if( !Is_block(v) ) return 0;
-
-	switch( SWIG_Tag_val(v) ) {
-	case C_string:
-	case C_ptr:
-	case C_int64:
-	    CAMLreturn(1);
-
-	default:
-	    CAMLreturn(0);
-	}	
-    }
-
-    SWIGINTERN CAML_VALUE SWIG_Ocaml_ptr_to_val(const char *name, void *ptr, swig_type_info *descriptor) {
-        CAMLparam0();
-        SWIG_CAMLlocal1(result);
-
-        CAML_VALUE *fromval = caml_named_value(name);
-        if (fromval) {
-            result = caml_callback(*fromval, caml_val_ptr(ptr, descriptor));
-        } else {
-            result = caml_val_ptr(ptr, descriptor);
-        }
-        CAMLreturn(result);
-    }
-
-    static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
-      CAML_VALUE pointer;
-
-      pointer = caml_callback(*caml_named_value("swig_find_type_info"), caml_val_int(0));
-      if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) {
-        return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0));
-      }
-      return 0;
-    }
-
-    static void SWIG_Ocaml_SetModule(swig_module_info *pointer) {
-      CAML_VALUE mod_pointer;
-
-      mod_pointer = caml_val_ptr(pointer, NULL);
-      caml_callback(*caml_named_value("swig_set_type_info"), mod_pointer);
-    }
-
-#ifdef __cplusplus
 }
 #endif
-#undef value
+
+%typemap(in) SWIGTYPE {
+    $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ;
+}
+
+#ifdef __cplusplus
+
+%typemap(out) SWIGTYPE {
+    $&1_ltype temp = new $ltype((const $1_ltype &) $1);
+    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)temp, $&1_descriptor);
+}
+
+#else
+
+%typemap(out) SWIGTYPE {
+    void *temp = calloc(1,sizeof($ltype));
+    memmove(temp, &$1, sizeof($1_type));
+    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", temp, $&1_descriptor);
+}
+
+#endif
+
+%typemap(directorin) SWIGTYPE {
+    $&ltype temp = new $ltype((const $ltype &)$1);
+    swig_result = SWIG_Ocaml_ptr_to_val("create_$ltype_from_ptr", (void *)temp, $&1_descriptor);
+    args = caml_list_append(args, swig_result);
+}
+
+%typemap(directorin) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && {
+    swig_result = SWIG_Ocaml_ptr_to_val("create_$ltype_from_ptr", (void *)&$1, $&1_descriptor);
+    args = caml_list_append(args, swig_result);
+}
+
+/* The SIMPLE_MAP macro below defines the whole set of typemaps needed
+   for simple types. */
+
+%define SIMPLE_MAP(C_NAME, C_TO_OCAML, OCAML_TO_C)
+/* In */
+%typemap(in) C_NAME {
+    $1 = OCAML_TO_C($input);
+}
+%typemap(varin) C_NAME {
+    $1 = OCAML_TO_C($input);
+}
+%typemap(in) const C_NAME & ($*1_ltype temp) {
+    temp = ($*1_ltype) OCAML_TO_C($input);
+    $1 = &temp;
+}
+%typemap(varin) const C_NAME & {
+    $1 = OCAML_TO_C($input);
+}
+%typemap(directorout) C_NAME {
+    $1 = OCAML_TO_C($input);
+}
+/* Out */
+%typemap(out) C_NAME {
+    $result = C_TO_OCAML($1);
+}
+%typemap(varout) C_NAME {
+    $result = C_TO_OCAML($1);
+}
+%typemap(varout) const C_NAME & {
+    $result = C_TO_OCAML($1);
+}
+%typemap(out) const C_NAME & {
+    $result = C_TO_OCAML(*$1);
+}
+%typemap(directorin) C_NAME {
+    args = caml_list_append(args, C_TO_OCAML($1));
+}
+%enddef
+
+SIMPLE_MAP(bool, caml_val_bool, caml_long_val);
+SIMPLE_MAP(char, caml_val_char, caml_long_val);
+SIMPLE_MAP(signed char, caml_val_char, caml_long_val);
+SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val);
+SIMPLE_MAP(int, caml_val_int, caml_long_val);
+SIMPLE_MAP(short, caml_val_short, caml_long_val);
+SIMPLE_MAP(wchar_t, caml_val_short, caml_long_val);
+SIMPLE_MAP(long, caml_val_long, caml_long_val);
+SIMPLE_MAP(ptrdiff_t, caml_val_int, caml_long_val);
+SIMPLE_MAP(unsigned int, caml_val_uint, caml_long_val);
+SIMPLE_MAP(unsigned short, caml_val_ushort, caml_long_val);
+SIMPLE_MAP(unsigned long, caml_val_ulong, caml_long_val);
+SIMPLE_MAP(size_t, caml_val_int, caml_long_val);
+SIMPLE_MAP(float, caml_val_float, caml_double_val);
+SIMPLE_MAP(double, caml_val_double, caml_double_val);
+SIMPLE_MAP(long long,caml_val_ulong,caml_long_val);
+SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
+
+/* Void */
+
+%typemap(out) void "$result = Val_unit;";
+
+/* Pass through value */
+
+%typemap (in) CAML_VALUE "$1=$input;";
+%typemap (out) CAML_VALUE "$result=$1;";
+
+#if 0
+%include <carray.i>
+#endif
+
+/* Handle char arrays as strings */
+
+%define %char_ptr_in(how)
+%typemap(how)  char *, signed char *, unsigned char * {
+    $1 = ($ltype)caml_string_val($input);
+}
+/* Again work around the empty array bound bug */
+%typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] {
+    char *temp = caml_string_val($input);
+    strcpy((char *)$1,temp); 
+}
+%enddef
+
+%char_ptr_in(in);
+%char_ptr_in(varin);
+%char_ptr_in(directorout);
+
+%define %char_ptr_out(how) 
+%typemap(how) 
+    char *, signed char *, unsigned char *, 
+    const char *, const signed char *, const unsigned char * {
+    $result = caml_val_string((char *)$1);
+}
+/* I'd like to use the length here but can't because it might be empty */
+%typemap(how)
+    char [ANY], signed char [ANY], unsigned char [ANY],
+    const char [ANY], const signed char [ANY], const unsigned char [ANY] {
+    $result = caml_val_string((char *)$1);
+}
+%enddef
+
+%char_ptr_out(out);
+%char_ptr_out(varout);
+%char_ptr_out(directorin);
+
+%define %swigtype_ptr_in(how)
+%typemap(how) SWIGTYPE * {
+    $1 = ($ltype)caml_ptr_val($input,$1_descriptor);
+}
+%typemap(how) SWIGTYPE (CLASS::*) {
+    void *v = caml_ptr_val($input,$1_descriptor);
+    memcpy(& $1, &v, sizeof(v));
+}
+%enddef
+
+%typemap(out) SWIGTYPE * {
+    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, $1_descriptor);
+}
+
+%define %swigtype_ptr_out(how)
+%typemap(how) SWIGTYPE (CLASS::*) {
+    void *v;
+    memcpy(&v,& $1, sizeof(void *));
+    $result = caml_val_ptr (v,$1_descriptor);
+}
+%enddef
+
+%swigtype_ptr_in(in);
+%swigtype_ptr_in(varin);
+%swigtype_ptr_in(directorout);
+%swigtype_ptr_out(out);
+%swigtype_ptr_out(varout);
+%swigtype_ptr_out(directorin);
+
+%define %swigtype_array_fail(how,msg)
+%typemap(how) SWIGTYPE [] {
+    caml_failwith(msg);
+}
+%enddef
+
+%swigtype_array_fail(in,"Array arguments for arbitrary types need a typemap");
+%swigtype_array_fail(varin,"Assignment to global arrays for arbitrary types need a typemap");
+%swigtype_array_fail(out,"Array arguments for arbitrary types need a typemap");
+%swigtype_array_fail(varout,"Array variables need a typemap");
+%swigtype_array_fail(directorin,"Array results with arbitrary types need a typemap");
+%swigtype_array_fail(directorout,"Array arguments with arbitrary types need a typemap");
+
+/* C++ References */
+
+/* Enums */
+%define %swig_enum_in(how)
+%typemap(how) enum SWIGTYPE {
+    $1 = ($type)caml_long_val_full($input,"$type_marker");
+}
+%enddef
+
+%define %swig_enum_out(how)
+%typemap(how) enum SWIGTYPE {
+    $result = caml_callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1));
+}
+%enddef
+
+%swig_enum_in(in)
+%swig_enum_in(varin)
+%swig_enum_in(directorout)
+%swig_enum_out(out)
+%swig_enum_out(varout)
+%swig_enum_out(directorin)
+
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
+    $1 = ($1_ltype) caml_string_val($input);
+    $2 = ($2_ltype) caml_string_len($input);
+}
+
+%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
+    swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **)&$1);
+    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, ty);
+}
+
+/* Array reference typemaps */
+%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+%apply SWIGTYPE && { SWIGTYPE ((&)[ANY]) }
+
+/* const pointers */
+%apply SWIGTYPE * { SWIGTYPE *const }
+%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
+%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
 
diff --git a/Lib/ocaml/ocamlrun.swg b/Lib/ocaml/ocamlrun.swg
new file mode 100644
index 0000000..3d552cc
--- /dev/null
+++ b/Lib/ocaml/ocamlrun.swg
@@ -0,0 +1,607 @@
+/* -*-c-*- */
+
+/* SWIG pointer structure */
+
+#include <string.h>
+#include <assert.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define C_bool 0
+#define C_char 1
+#define C_uchar 2
+#define C_short 3
+#define C_ushort 4
+#define C_int 5
+#define C_uint 6
+#define C_int32 7
+#define C_int64 8
+#define C_float 9
+#define C_double 10
+#define C_ptr 11
+#define C_array 12
+#define C_list 13
+#define C_obj 14
+#define C_string 15
+#define C_enum 16
+#define C_director_core 17
+
+
+/* Cast a pointer if possible; returns 1 if successful */
+    
+    SWIGINTERN int
+    SWIG_Cast (void *source, swig_type_info *source_type,
+	       void **ptr, swig_type_info *dest_type)
+    {
+	if( !source ) { /* Special case for NULL.  This is a popular question
+	     for other modules on the list, so I want an easy way out... */
+	    *ptr = 0;
+	    return 0;
+	}
+
+#ifdef TYPE_CAST_VERBOSE
+	fprintf( stderr, "Trying to cast %s to %s\n", 
+		 source_type ? source_type->str : "<none>",
+		 dest_type ? dest_type->str : "<none>" );
+#endif
+	if (dest_type != source_type) {
+	    /* We have a type mismatch.  Will have to look through our type
+	       mapping table to figure out whether or not we can accept this
+	       datatype. 
+	       --
+	       Ignore typechecks for void *.  Allow any conversion. */
+	    if( !dest_type || !source_type || 
+		!strcmp(dest_type->name,"_p_void") ||
+		!strcmp(source_type->name,"_p_void") ) {
+		*ptr = source;
+		return 0;
+	    } else {
+		swig_cast_info *tc = 
+		    SWIG_TypeCheckStruct(source_type, dest_type );
+#ifdef TYPE_CAST_VERBOSE
+		fprintf( stderr, "Typecheck -> %s\n",
+			 tc ? tc->type->str : "<none>" );
+#endif
+		if( tc ) {
+		    int newmemory = 0;
+		    *ptr = SWIG_TypeCast(tc, source, &newmemory);
+		    assert(!newmemory); /* newmemory handling not yet implemented */
+		    return 0;
+		} else
+		    return -1;
+	    }
+	} else {
+	    *ptr = source;
+	    return 0;
+	}
+    }
+
+/* Return 0 if successful. */
+    SWIGINTERN int
+    SWIG_GetPtr(void *inptr, void **outptr, 
+		swig_type_info *intype, swig_type_info *outtype) {
+	if (intype) {
+	    return SWIG_Cast(inptr, intype,
+			     outptr, outtype) == -1;
+	} else {
+	    *outptr = inptr;
+	    return 0;
+	}
+    }
+
+    SWIGINTERN void caml_print_list( CAML_VALUE v );
+
+    SWIGINTERN void caml_print_val( CAML_VALUE v ) {
+	switch( SWIG_Tag_val(v) ) {
+	case C_bool:
+	    if( Bool_val(SWIG_Field(v,0)) ) fprintf( stderr, "true " );
+	    else fprintf( stderr, "false " );
+	    break;
+	case C_char:
+	case C_uchar:
+	    fprintf( stderr, "'%c' (\\%03d) ", 
+		     (Int_val(SWIG_Field(v,0)) >= ' ' &&
+		      Int_val(SWIG_Field(v,0)) < 127) ? Int_val(SWIG_Field(v,0)) : '.',
+		     Int_val(SWIG_Field(v,0)) );
+	    break;
+	case C_short:
+	case C_ushort:
+	case C_int:
+	    fprintf( stderr, "%d ", (int)caml_long_val(v) );
+	    break;
+
+	case C_uint:
+	case C_int32:
+	    fprintf( stderr, "%ud ", (unsigned int)caml_long_val(v) );
+	    break;
+	case C_int64:
+	    fprintf( stderr, "%ld ", caml_long_val(v) );
+	    break;
+	case C_float:
+	case C_double:
+	    fprintf( stderr, "%f ", caml_double_val(v) );
+	    break;
+
+	case C_ptr:
+	{
+	    void *vout = 0;
+	    swig_type_info *ty = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1));
+	    caml_ptr_val_internal(v,&vout,0);
+	    fprintf( stderr, "PTR(%p,%s) ", 
+		     vout,
+		     ty ? ty->name : "(null)" );
+	}
+	break;
+	case C_array:
+	{
+	    unsigned int i;
+	    for( i = 0; i < Wosize_val( SWIG_Field(v,0) ); i++ ) 
+		caml_print_val( SWIG_Field(SWIG_Field(v,0),i) );
+	}
+	break;
+	case C_list:
+	    caml_print_list( SWIG_Field(v,0) );
+	    break;
+	case C_obj:
+	    fprintf( stderr, "OBJ(%p) ", (void *)SWIG_Field(v,0) );
+	    break;
+	case C_string:
+	{
+	    void *cout;
+	    caml_ptr_val_internal(v,&cout,0);
+	    fprintf( stderr, "'%s' ", (char *)cout );
+	} 
+	break;
+	}
+    }
+
+    SWIGINTERN void caml_print_list( CAML_VALUE v ) {
+	CAMLparam1(v);
+	while( v && Is_block(v) ) {
+	    fprintf( stderr, "[ " );
+	    caml_print_val( SWIG_Field(v,0) );
+	    fprintf( stderr, "]\n" );
+	    v = SWIG_Field(v,1);
+	}
+	CAMLreturn0;
+    }
+
+    SWIGINTERN CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) {
+	CAMLparam1(lst);
+	int i = 0;
+	while( i < n && lst && Is_block(lst) ) {
+	    i++; lst = SWIG_Field(lst,1);
+	}
+	if( lst == Val_unit ) CAMLreturn(Val_unit);
+	else CAMLreturn(SWIG_Field(lst,0));
+    }
+    
+    SWIGINTERN CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) {
+	CAMLparam2(lst,elt);
+	SWIG_CAMLlocal3(v,vt,lh);
+	lh = Val_unit;
+	v = Val_unit;
+
+	/* Appending C_void should have no effect */
+	if( !Is_block(elt) ) return lst;
+
+	while( lst && Is_block(lst) ) {
+	    if( v && v != Val_unit ) {
+		vt = caml_alloc_tuple(2);
+		SWIG_Store_field(v,1,vt);
+		v = vt;
+	    } else {
+		v = lh = caml_alloc_tuple(2);
+	    }
+	    SWIG_Store_field(v,0,SWIG_Field(lst,0));
+	    lst = SWIG_Field(lst,1);
+	}
+
+	if( v && Is_block(v) ) {
+	    vt = caml_alloc_tuple(2);
+	    SWIG_Store_field(v,1,vt);
+	    v = vt;
+	} else {
+	    v = lh = caml_alloc_tuple(2);
+	}
+	SWIG_Store_field(v,0,elt);
+	SWIG_Store_field(v,1,Val_unit);
+
+	CAMLreturn(lh);
+    }
+
+    SWIGINTERN int caml_list_length( CAML_VALUE lst ) {
+	CAMLparam1(lst);
+	int i = 0;
+	while( lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); }
+	CAMLreturn(i);
+    }
+
+    SWIGINTERN void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) {
+	CAMLparam2(arr,item);
+	SWIG_Store_field(SWIG_Field(arr,0),n,item);
+	CAMLreturn0;
+    }
+
+    SWIGINTERN value caml_array_nth( CAML_VALUE arr, int n ) {
+	CAMLparam1(arr);
+	if( SWIG_Tag_val(arr) == C_array )
+	    CAMLreturn(SWIG_Field(SWIG_Field(arr,0),n));
+	else if( SWIG_Tag_val(arr) == C_list )
+	    CAMLreturn(caml_list_nth(arr,0));
+	else
+	    caml_failwith("Need array or list");
+    }
+
+    SWIGINTERN int caml_array_len( CAML_VALUE arr ) {
+	CAMLparam1(arr);
+	if( SWIG_Tag_val(arr) == C_array )
+	    CAMLreturn(Wosize_val(SWIG_Field(arr,0)));
+	else if( SWIG_Tag_val(arr) == C_list )
+	    CAMLreturn(caml_list_length(arr));
+	else
+	    caml_failwith("Need array or list");
+    }
+
+    SWIGINTERN CAML_VALUE caml_swig_alloc(int x,int y) {
+	return caml_alloc(x,y);
+    }
+
+    SWIGINTERN value caml_array_new( int n ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(vv);
+	vv = caml_swig_alloc(1,C_array);
+	SWIG_Store_field(vv,0,caml_alloc_tuple(n));
+	CAMLreturn(vv);
+    }
+    
+    SWIGINTERN CAML_VALUE caml_val_bool( int b ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(bv);
+	bv = caml_swig_alloc(1,C_bool);
+	SWIG_Store_field(bv,0,Val_bool(b));
+	CAMLreturn(bv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_char( char c ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(cv);
+	cv = caml_swig_alloc(1,C_char);
+	SWIG_Store_field(cv,0,Val_int(c));
+	CAMLreturn(cv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_uchar( unsigned char uc ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(ucv);
+	ucv = caml_swig_alloc(1,C_uchar);
+	SWIG_Store_field(ucv,0,Val_int(uc));
+	CAMLreturn(ucv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_short( short s ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(sv);
+	sv = caml_swig_alloc(1,C_short);
+	SWIG_Store_field(sv,0,Val_int(s));
+	CAMLreturn(sv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_ushort( unsigned short us ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(usv);
+	usv = caml_swig_alloc(1,C_ushort);
+	SWIG_Store_field(usv,0,Val_int(us));
+	CAMLreturn(usv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_int( int i ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(iv);
+	iv = caml_swig_alloc(1,C_int);
+	SWIG_Store_field(iv,0,Val_int(i));
+	CAMLreturn(iv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_uint( unsigned int ui ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(uiv);
+	uiv = caml_swig_alloc(1,C_int);
+	SWIG_Store_field(uiv,0,Val_int(ui));
+	CAMLreturn(uiv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_long( long l ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(lv);
+	lv = caml_swig_alloc(1,C_int64);
+	SWIG_Store_field(lv,0,caml_copy_int64(l));
+	CAMLreturn(lv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_ulong( unsigned long ul ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(ulv);
+	ulv = caml_swig_alloc(1,C_int64);
+	SWIG_Store_field(ulv,0,caml_copy_int64(ul));
+	CAMLreturn(ulv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_float( float f ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(fv);
+	fv = caml_swig_alloc(1,C_float);
+	SWIG_Store_field(fv,0,caml_copy_double((double)f));
+	CAMLreturn(fv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_double( double d ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(fv);
+	fv = caml_swig_alloc(1,C_double);
+	SWIG_Store_field(fv,0,caml_copy_double(d));
+	CAMLreturn(fv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(vv);
+	vv = caml_swig_alloc(2,C_ptr);
+	SWIG_Store_field(vv,0,caml_copy_int64((long)p));
+	SWIG_Store_field(vv,1,caml_copy_int64((long)info));
+	CAMLreturn(vv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_string( const char *p ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(vv);
+	if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 ));
+	vv = caml_swig_alloc(1,C_string);
+	SWIG_Store_field(vv,0,caml_copy_string(p));
+	CAMLreturn(vv);
+    }
+
+    SWIGINTERN CAML_VALUE caml_val_string_len( const char *p, int len ) {
+	CAMLparam0();
+	SWIG_CAMLlocal1(vv);
+	if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 ));
+	vv = caml_swig_alloc(1,C_string);
+	SWIG_Store_field(vv,0,caml_alloc_string(len));
+	memcpy(String_val(SWIG_Field(vv,0)),p,len);
+	CAMLreturn(vv);
+    }
+
+    #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name)
+    SWIGINTERN CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) {
+	CAMLparam0();
+	CAMLreturn(caml_callback2(*caml_named_value("caml_create_object_fn"),
+			     caml_val_ptr(v,type),
+			     caml_copy_string(name)));
+    }
+
+    SWIGINTERN long caml_long_val_full( CAML_VALUE v, const char *name ) {
+	CAMLparam1(v);
+	if( !Is_block(v) ) return 0;
+
+	switch( SWIG_Tag_val(v) ) {
+	case C_bool:
+	case C_char:
+	case C_uchar:
+	case C_short:
+	case C_ushort:
+	case C_int:
+	    CAMLreturn(Int_val(SWIG_Field(v,0)));
+	case C_uint:
+	case C_int32:
+	    CAMLreturn(Int32_val(SWIG_Field(v,0)));
+	case C_int64:
+	    CAMLreturn((long)SWIG_Int64_val(SWIG_Field(v,0)));
+	case C_float:
+	case C_double:
+	    CAMLreturn((long)Double_val(SWIG_Field(v,0)));
+	case C_string:
+	    CAMLreturn((long)String_val(SWIG_Field(v,0)));
+	case C_ptr:
+	    CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0)));
+	case C_enum: {
+	    SWIG_CAMLlocal1(ret);
+	    CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int");
+	    if( !name ) caml_failwith( "Not an enum conversion" );
+	    ret = caml_callback2(*enum_to_int,*caml_named_value(name),v);
+	    CAMLreturn(caml_long_val(ret));
+	}
+	default:
+	    caml_failwith("No conversion to int");
+	}
+    }
+
+    SWIGINTERN long caml_long_val( CAML_VALUE v ) {
+	return caml_long_val_full(v,0);
+    }
+
+    SWIGINTERN double caml_double_val( CAML_VALUE v ) {
+	CAMLparam1(v);
+	if( !Is_block(v) ) return 0.0;
+	switch( SWIG_Tag_val(v) ) {
+	case C_bool:
+	case C_char:
+	case C_uchar:
+	case C_short:
+	case C_ushort:
+	case C_int:
+	    CAMLreturn_type(Int_val(SWIG_Field(v,0)));
+	case C_uint:
+	case C_int32:
+	    CAMLreturn_type(Int32_val(SWIG_Field(v,0)));
+	case C_int64:
+	    CAMLreturn_type(SWIG_Int64_val(SWIG_Field(v,0)));
+	case C_float:
+	case C_double:
+	    CAMLreturn_type(Double_val(SWIG_Field(v,0)));
+	default:
+	    fprintf( stderr, "Unknown block tag %d\n", SWIG_Tag_val(v) );
+	    caml_failwith("No conversion to double");
+	}
+    }
+
+    SWIGINTERN int caml_ptr_val_internal( CAML_VALUE v, void **out,
+					  swig_type_info *descriptor ) {
+	CAMLparam1(v);
+	void *outptr = NULL;
+        swig_type_info *outdescr = NULL;
+        static CAML_VALUE *func_val = NULL;
+
+	if( v == Val_unit ) {
+	    *out = 0;
+	    CAMLreturn_type(0);
+	}
+	if( !Is_block(v) ) return -1;
+	switch( SWIG_Tag_val(v) ) {
+	case C_obj:
+	    if (!func_val) {
+	        func_val = caml_named_value("caml_obj_ptr");
+	    }
+	    CAMLreturn_type(caml_ptr_val_internal(caml_callback(*func_val, v), out, descriptor));
+	case C_string:
+	    outptr = (void *)String_val(SWIG_Field(v,0));
+	    break;
+	case C_ptr:
+	    outptr = (void *)(long)SWIG_Int64_val(SWIG_Field(v,0));
+            outdescr = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1));
+	    break;
+	default:
+	    *out = 0;
+	    CAMLreturn_type(1);
+	    break;
+	}
+
+	CAMLreturn_type(SWIG_GetPtr(outptr, out, outdescr, descriptor));
+    }
+
+    SWIGINTERN void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) {
+        CAMLparam0();
+#ifdef TYPE_CAST_VERBOSE
+	caml_print_val( v );
+#endif
+	void *out = NULL;
+	if( !caml_ptr_val_internal( v, &out, descriptor ) )
+	    CAMLreturn_type(out);
+	else
+	    caml_failwith( "No appropriate conversion found." );
+    }
+
+    SWIGINTERN char *caml_string_val( CAML_VALUE v ) {
+	return (char *)caml_ptr_val( v, 0 );
+    }
+
+    SWIGINTERN int caml_string_len( CAML_VALUE v ) {
+	switch( SWIG_Tag_val(v) ) {
+	case C_string:
+	    return caml_string_length(SWIG_Field(v,0));
+	default:
+	    return strlen((char *)caml_ptr_val(v,0));
+	}
+    }
+
+    SWIGINTERN int caml_bool_check( CAML_VALUE v ) {
+	CAMLparam1(v);
+	
+	if( !Is_block(v) ) return 0;
+	
+	switch( SWIG_Tag_val(v) ) {
+	case C_bool:
+	case C_ptr:
+	case C_string:
+	    CAMLreturn(1);
+	default:
+	    CAMLreturn(0);
+	}
+    }
+
+    SWIGINTERN int caml_int_check( CAML_VALUE v ) {
+	CAMLparam1(v);
+	
+	if( !Is_block(v) ) return 0;
+	
+	switch( SWIG_Tag_val(v) ) {
+	case C_char:
+	case C_uchar:
+	case C_short:
+	case C_ushort:
+	case C_int:
+	case C_uint:
+	case C_int32:
+	case C_int64:
+	    CAMLreturn(1);
+
+	default:
+	    CAMLreturn(0);
+	}
+    }
+
+    SWIGINTERN int caml_float_check( CAML_VALUE v ) {
+	CAMLparam1(v);
+	if( !Is_block(v) ) return 0;
+
+	switch( SWIG_Tag_val(v) ) {
+	case C_float:
+	case C_double:
+	    CAMLreturn(1);
+
+	default:
+	    CAMLreturn(0);
+	}	
+    }
+
+    SWIGINTERN int caml_ptr_check( CAML_VALUE v ) {
+	CAMLparam1(v);
+	if( !Is_block(v) ) return 0;
+
+	switch( SWIG_Tag_val(v) ) {
+	case C_string:
+	case C_ptr:
+	case C_int64:
+	    CAMLreturn(1);
+
+	default:
+	    CAMLreturn(0);
+	}	
+    }
+
+    SWIGINTERN CAML_VALUE SWIG_Ocaml_ptr_to_val(const char *name, void *ptr, swig_type_info *descriptor) {
+        CAMLparam0();
+        SWIG_CAMLlocal1(result);
+
+        CAML_VALUE *fromval = caml_named_value(name);
+        if (fromval) {
+            result = caml_callback(*fromval, caml_val_ptr(ptr, descriptor));
+        } else {
+            result = caml_val_ptr(ptr, descriptor);
+        }
+        CAMLreturn(result);
+    }
+
+    static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
+      CAML_VALUE pointer;
+
+      pointer = caml_callback(*caml_named_value("swig_find_type_info"), caml_val_int(0));
+      if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) {
+        return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0));
+      }
+      return 0;
+    }
+
+    static void SWIG_Ocaml_SetModule(swig_module_info *pointer) {
+      CAML_VALUE mod_pointer;
+
+      mod_pointer = caml_val_ptr(pointer, NULL);
+      caml_callback(*caml_named_value("swig_set_type_info"), mod_pointer);
+    }
+
+#ifdef __cplusplus
+}
+#endif
+#undef value
+
diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamlrundec.swg
similarity index 99%
rename from Lib/ocaml/ocamldec.swg
rename to Lib/ocaml/ocamlrundec.swg
index 0c2faf7..555f9a4 100644
--- a/Lib/ocaml/ocamldec.swg
+++ b/Lib/ocaml/ocamlrundec.swg
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * ocamldec.swg
+ * ocamlrundec.swg
  *
  * Ocaml runtime code -- declarations
  * ----------------------------------------------------------------------------- */
diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i
index 23e2955..39231e2 100644
--- a/Lib/ocaml/typemaps.i
+++ b/Lib/ocaml/typemaps.i
@@ -1,321 +1,44 @@
-/* -----------------------------------------------------------------------------
+/* ----------------------------------------------------------------------------
  * typemaps.i
  *
- * The Ocaml module handles all types uniformly via typemaps. Here
- * are the definitions.
- * ----------------------------------------------------------------------------- */
+ * These typemaps provide support for input/output arguments for C/C++ pointers
+ * and C++ references.
+* ---------------------------------------------------------------------------- */
 
-/* Pointers */
-
-%typemap(in) void ""
-
-%typemap(out) void "$result = Val_int(0);"
-
-%typemap(in) void * {
-    $1 = caml_ptr_val($input,$descriptor);
-}
-
-%typemap(varin) void * {
-    $1 = ($ltype)caml_ptr_val($input,$descriptor);
-}
-
-%typemap(out) void * {
-    $result = caml_val_ptr($1,$descriptor);
-}
-
-%typemap(varout) void * {
-    $result = caml_val_ptr($1,$descriptor);
-}
-
-%typemap(in) char *& (char *temp) {
-  temp = (char*)caml_val_ptr($1,$descriptor);
+%define INPUT_OUTPUT_INOUT_TYPEMAPS(type, c_to_ocaml, ocaml_to_c)
+%typemap(in) type *INPUT(type temp), type &INPUT(type temp) {
+  temp = (type)ocaml_to_c($input);
   $1 = &temp;
 }
+%typemap(typecheck) type *INPUT = type;
+%typemap(typecheck) type &INPUT = type;
 
-%typemap(argout) char *& {
-  swig_result =	caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1)));
+%typemap(in, numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;"
+%typemap(argout) type *OUTPUT, type &OUTPUT {
+  swig_result = caml_list_append(swig_result, c_to_ocaml(*$1));
 }
+%typemap(in) type *INOUT = type *INPUT;
+%typemap(in) type &INOUT = type &INPUT;
 
-%typemap(in) SWIGTYPE & {
-    $1 = ($ltype) caml_ptr_val($input,$1_descriptor);
-}
+%typemap(argout) type *INOUT = type *OUTPUT;
+%typemap(argout) type &INOUT = type &OUTPUT;
 
-%typemap(in) SWIGTYPE && {
-    $1 = ($ltype) caml_ptr_val($input,$1_descriptor);
-}
-
-%typemap(varin) SWIGTYPE & {
-    $1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
-}
-
-%typemap(varin) SWIGTYPE && {
-    $1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
-}
-
-%typemap(varout) SWIGTYPE &, SWIGTYPE && {
-    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)&$1, $1_descriptor);
-}
-
-%typemap(out) SWIGTYPE &, SWIGTYPE && {
-    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, $1_descriptor);
-}
-
-#if 0
-%typemap(argout) SWIGTYPE & {
-    CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
-    if( fromval ) {
-	swig_result =
-	    caml_list_append(swig_result,
-			     caml_callback(*fromval,caml_val_ptr((void *) $1,
-							    $1_descriptor)));
-    } else {
-	swig_result =
-	    caml_list_append(swig_result,
-			     caml_val_ptr ((void *) $1,$1_descriptor));
-    }
-}
-%typemap(argout) SWIGTYPE && {
-    CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
-    if( fromval ) {
-	swig_result =
-	    caml_list_append(swig_result,
-			     caml_callback(*fromval,caml_val_ptr((void *) $1,
-							    $1_descriptor)));
-    } else {
-	swig_result =
-	    caml_list_append(swig_result,
-			     caml_val_ptr ((void *) $1,$1_descriptor));
-    }
-}
-#endif
-
-%typemap(in) SWIGTYPE {
-    $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ;
-}
-
-#ifdef __cplusplus
-
-%typemap(out) SWIGTYPE {
-    $&1_ltype temp = new $ltype((const $1_ltype &) $1);
-    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)temp, $&1_descriptor);
-}
-
-#else
-
-%typemap(out) SWIGTYPE {
-    void *temp = calloc(1,sizeof($ltype));
-    memmove(temp, &$1, sizeof($1_type));
-    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", temp, $&1_descriptor);
-}
-
-#endif
-
-%typemap(directorin) SWIGTYPE {
-    $&ltype temp = new $ltype((const $ltype &)$1);
-    swig_result = SWIG_Ocaml_ptr_to_val("create_$ltype_from_ptr", (void *)temp, $&1_descriptor);
-    args = caml_list_append(args, swig_result);
-}
-
-%typemap(directorin) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && {
-    swig_result = SWIG_Ocaml_ptr_to_val("create_$ltype_from_ptr", (void *)&$1, $&1_descriptor);
-    args = caml_list_append(args, swig_result);
-}
-
-/* The SIMPLE_MAP macro below defines the whole set of typemaps needed
-   for simple types. */
-
-%define SIMPLE_MAP(C_NAME, C_TO_OCAML, OCAML_TO_C)
-/* In */
-%typemap(in) C_NAME {
-    $1 = OCAML_TO_C($input);
-}
-%typemap(varin) C_NAME {
-    $1 = OCAML_TO_C($input);
-}
-%typemap(in) const C_NAME & ($*1_ltype temp) {
-    temp = ($*1_ltype) OCAML_TO_C($input);
-    $1 = &temp;
-}
-%typemap(varin) const C_NAME & {
-    $1 = OCAML_TO_C($input);
-}
-%typemap(directorout) C_NAME {
-    $1 = OCAML_TO_C($input);
-}
-%typemap(in) C_NAME *INPUT ($*1_ltype temp) {
-    temp = ($*1_ltype) OCAML_TO_C($input);
-    $1 = &temp;
-}
-%typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) {
-    $1 = &temp;
-}
-/* Out */
-%typemap(out) C_NAME {
-    $result = C_TO_OCAML($1);
-}
-%typemap(varout) C_NAME {
-    $result = C_TO_OCAML($1);
-}
-%typemap(varout) const C_NAME & {
-    $result = C_TO_OCAML($1);
-}
-%typemap(argout) C_NAME *OUTPUT {
-    swig_result = caml_list_append(swig_result, C_TO_OCAML((long)*$1));
-}
-%typemap(out) const C_NAME & {
-    $result = C_TO_OCAML(*$1);
-}
-%typemap(directorin) C_NAME {
-    args = caml_list_append(args, C_TO_OCAML($1));
-}
+%typemap(typecheck) type *INOUT = type;
+%typemap(typecheck) type &INOUT = type;
 %enddef
 
-SIMPLE_MAP(bool, caml_val_bool, caml_long_val);
-SIMPLE_MAP(char, caml_val_char, caml_long_val);
-SIMPLE_MAP(signed char, caml_val_char, caml_long_val);
-SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val);
-SIMPLE_MAP(int, caml_val_int, caml_long_val);
-SIMPLE_MAP(short, caml_val_short, caml_long_val);
-SIMPLE_MAP(wchar_t, caml_val_short, caml_long_val);
-SIMPLE_MAP(long, caml_val_long, caml_long_val);
-SIMPLE_MAP(ptrdiff_t, caml_val_int, caml_long_val);
-SIMPLE_MAP(unsigned int, caml_val_uint, caml_long_val);
-SIMPLE_MAP(unsigned short, caml_val_ushort, caml_long_val);
-SIMPLE_MAP(unsigned long, caml_val_ulong, caml_long_val);
-SIMPLE_MAP(size_t, caml_val_int, caml_long_val);
-SIMPLE_MAP(float, caml_val_float, caml_double_val);
-SIMPLE_MAP(double, caml_val_double, caml_double_val);
-SIMPLE_MAP(long long,caml_val_ulong,caml_long_val);
-SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
-
-/* Void */
-
-%typemap(out) void "$result = Val_unit;";
-
-/* Pass through value */
-
-%typemap (in) CAML_VALUE "$1=$input;";
-%typemap (out) CAML_VALUE "$result=$1;";
-
-#if 0
-%include <carray.i>
-#endif
-
-/* Handle char arrays as strings */
-
-%define %char_ptr_in(how)
-%typemap(how)  char *, signed char *, unsigned char * {
-    $1 = ($ltype)caml_string_val($input);
-}
-/* Again work around the empty array bound bug */
-%typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] {
-    char *temp = caml_string_val($input);
-    strcpy((char *)$1,temp); 
-}
-%enddef
-
-%char_ptr_in(in);
-%char_ptr_in(varin);
-%char_ptr_in(directorout);
-
-%define %char_ptr_out(how) 
-%typemap(how) 
-    char *, signed char *, unsigned char *, 
-    const char *, const signed char *, const unsigned char * {
-    $result = caml_val_string((char *)$1);
-}
-/* I'd like to use the length here but can't because it might be empty */
-%typemap(how)
-    char [ANY], signed char [ANY], unsigned char [ANY],
-    const char [ANY], const signed char [ANY], const unsigned char [ANY] {
-    $result = caml_val_string((char *)$1);
-}
-%enddef
-
-%char_ptr_out(out);
-%char_ptr_out(varout);
-%char_ptr_out(directorin);
-
-%define %swigtype_ptr_in(how)
-%typemap(how) SWIGTYPE * {
-    $1 = ($ltype)caml_ptr_val($input,$1_descriptor);
-}
-%typemap(how) SWIGTYPE (CLASS::*) {
-    void *v = caml_ptr_val($input,$1_descriptor);
-    memcpy(& $1, &v, sizeof(v));
-}
-%enddef
-
-%typemap(out) SWIGTYPE * {
-    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, $1_descriptor);
-}
-
-%define %swigtype_ptr_out(how)
-%typemap(how) SWIGTYPE (CLASS::*) {
-    void *v;
-    memcpy(&v,& $1, sizeof(void *));
-    $result = caml_val_ptr (v,$1_descriptor);
-}
-%enddef
-
-%swigtype_ptr_in(in);
-%swigtype_ptr_in(varin);
-%swigtype_ptr_in(directorout);
-%swigtype_ptr_out(out);
-%swigtype_ptr_out(varout);
-%swigtype_ptr_out(directorin);
-
-%define %swigtype_array_fail(how,msg)
-%typemap(how) SWIGTYPE [] {
-    caml_failwith(msg);
-}
-%enddef
-
-%swigtype_array_fail(in,"Array arguments for arbitrary types need a typemap");
-%swigtype_array_fail(varin,"Assignment to global arrays for arbitrary types need a typemap");
-%swigtype_array_fail(out,"Array arguments for arbitrary types need a typemap");
-%swigtype_array_fail(varout,"Array variables need a typemap");
-%swigtype_array_fail(directorin,"Array results with arbitrary types need a typemap");
-%swigtype_array_fail(directorout,"Array arguments with arbitrary types need a typemap");
-
-/* C++ References */
-
-/* Enums */
-%define %swig_enum_in(how)
-%typemap(how) enum SWIGTYPE {
-    $1 = ($type)caml_long_val_full($input,"$type_marker");
-}
-%enddef
-
-%define %swig_enum_out(how)
-%typemap(how) enum SWIGTYPE {
-    $result = caml_callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1));
-}
-%enddef
-
-%swig_enum_in(in)
-%swig_enum_in(varin)
-%swig_enum_in(directorout)
-%swig_enum_out(out)
-%swig_enum_out(varout)
-%swig_enum_out(directorin)
-
-%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
-    $1 = ($1_ltype) caml_string_val($input);
-    $2 = ($2_ltype) caml_string_len($input);
-}
-
-%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
-    swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **)&$1);
-    $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, ty);
-}
-
-/* Array reference typemaps */
-%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
-%apply SWIGTYPE && { SWIGTYPE ((&)[ANY]) }
-
-/* const pointers */
-%apply SWIGTYPE * { SWIGTYPE *const }
-%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
-%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
-
+INPUT_OUTPUT_INOUT_TYPEMAPS(bool, caml_val_bool, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(int, caml_val_int, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(long, caml_val_long, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(short, caml_val_int, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(char, caml_val_char, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(signed char, caml_val_char, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(float, caml_val_float, caml_double_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(double, caml_val_double, caml_double_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned int, caml_val_uint, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long, caml_val_ulong, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned short, caml_val_ushort, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned char, caml_val_uchar, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(long long, caml_val_long, caml_long_val);
+INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long long, caml_val_ulong, caml_long_val);
+#undef INPUT_OUTPUT_INOUT_TYPEMAPS
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index 269ff75..310a849 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -401,20 +401,14 @@
       return const_reference(_seq, n);
     }
 
-    bool check(bool set_err = true) const
+    bool check() const
     {
       int s = size();
       for (int i = 0; i < s; ++i) {
 	//	swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, i);
 	octave_value item; // * todo
-	if (!swig::check<value_type>(item)) {
-	  if (set_err) {
-	    char msg[1024];
-	    sprintf(msg, "in sequence element %d", i);
-	    SWIG_Error(SWIG_RuntimeError, msg);
-	  }
+	if (!swig::check<value_type>(item))
 	  return false;
-	}
       }
       return true;
     }
diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg
index 5062a8b..28051e6 100644
--- a/Lib/python/builtin.swg
+++ b/Lib/python/builtin.swg
@@ -117,7 +117,7 @@
 
 SWIGINTERN void
 SwigPyStaticVar_dealloc(PyDescrObject *descr) {
-  _PyObject_GC_UNTRACK(descr);
+  PyObject_GC_UnTrack(descr);
   Py_XDECREF(PyDescr_TYPE(descr));
   Py_XDECREF(PyDescr_NAME(descr));
   PyObject_GC_Del(descr);
diff --git a/Lib/python/director.swg b/Lib/python/director.swg
index 4bdc94d..9694c62 100644
--- a/Lib/python/director.swg
+++ b/Lib/python/director.swg
@@ -199,46 +199,6 @@
     }
   };
 
-  /* unknown exception handler  */
-  class UnknownExceptionHandler {
-#ifdef SWIG_DIRECTOR_UEH
-    static void handler() {
-      try {
-        throw;
-      } catch (DirectorException& e) {
-        std::cerr << "SWIG Director exception caught:" << std::endl
-                  << e.what() << std::endl;
-      } catch (std::exception& e) {
-        std::cerr << "std::exception caught: "<< e.what() << std::endl;
-      } catch (...) {
-        std::cerr << "Unknown exception caught." << std::endl;
-      }
-
-      std::cerr << std::endl
-                << "Python interpreter traceback:" << std::endl;
-      PyErr_Print();
-      std::cerr << std::endl;
-
-      std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl
-                << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
-                << std::endl
-                << "Exception is being re-thrown, program will likely abort/terminate." << std::endl;
-      throw;
-    }
-
-  public:
-
-    std::unexpected_handler old;
-    UnknownExceptionHandler(std::unexpected_handler nh = handler) {
-      old = std::set_unexpected(nh);
-    }
-
-    ~UnknownExceptionHandler() {
-      std::set_unexpected(old);
-    }
-#endif
-  };
-
   /* type mismatch in the return value from a python method call */
   class DirectorTypeMismatchException : public DirectorException {
   public:
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index ef2f725..fef4e9b 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -672,19 +672,13 @@
       return const_reference(_seq, n);
     }
 
-    bool check(bool set_err = true) const
+    bool check() const
     {
       Py_ssize_t s = size();
       for (Py_ssize_t i = 0; i < s; ++i) {
 	swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i);
-	if (!swig::check<value_type>(item)) {
-	  if (set_err) {
-	    char msg[1024];
-	    sprintf(msg, "in sequence element %d", (int)i);
-	    SWIG_Error(SWIG_RuntimeError, msg);
-	  }
+	if (!swig::check<value_type>(item))
 	  return false;
-	}
       }
       return true;
     }
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index ad1b819..445a1e3 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -184,7 +184,7 @@
 }
 
 /* A functor is a function object with one single object argument */
-#define SWIG_Python_CallFunctor(functor, obj)	        PyObject_CallFunction(functor, (char *)"O", obj);
+#define SWIG_Python_CallFunctor(functor, obj)	        PyObject_CallFunctionObjArgs(functor, obj, NULL);
 
 /*
   Helper for static pointer initialization for both C and C++ code, for example
diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg
index c6c53a3..9395b81 100644
--- a/Lib/ruby/director.swg
+++ b/Lib/ruby/director.swg
@@ -153,43 +153,6 @@
     }
   };
 
-  /* unknown exception handler  */
-  class UnknownExceptionHandler {
-#ifdef SWIG_DIRECTOR_UEH
-    static void handler() {
-      try {
-	throw;
-      } catch (DirectorException& e) {
-	std::cerr << "SWIG Director exception caught:" << std::endl
-		  << e.what() << std::endl;
-      } catch (std::exception& e) {
-	std::cerr << "std::exception caught: "<< e.what() << std::endl;
-      } catch (...) {
-	std::cerr << "Unknown exception caught." << std::endl;
-      }
-      std::cerr << std::endl
-		<< "Ruby interpreter traceback:" << std::endl;
-      std::cerr << std::endl;
-      std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl
-		<< "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
-		<< std::endl
-		<< "Exception is being re-thrown, program will like abort/terminate." << std::endl;
-      throw;
-    }
-
-  public:
-    std::unexpected_handler old;
-    UnknownExceptionHandler(std::unexpected_handler nh = handler) {
-      old = std::set_unexpected(nh);
-    }
-
-    ~UnknownExceptionHandler() {
-      std::set_unexpected(old);
-    }
-#endif
-  };
-
-
   /* Type mismatch in the return value from a Ruby method call */
   class DirectorTypeMismatchException : public DirectorException {
   public:
diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg
index e8830a7..9fa205b 100644
--- a/Lib/ruby/rubycontainer.swg
+++ b/Lib/ruby/rubycontainer.swg
@@ -395,19 +395,13 @@
       return const_reference(_seq, n);
     }
 
-    bool check(bool set_err = false) const
+    bool check() const
     {
       int s = (int) size();
       for (int i = 0; i < s; ++i) {
 	VALUE item = rb_ary_entry(_seq, i );
-	if (!swig::check<value_type>(item)) {
-	  if (set_err) {
-	    char msg[1024];
-	    sprintf(msg, "in sequence element %d", i);
-	    SWIG_Error(SWIG_RuntimeError, msg);
-	  }
+	if (!swig::check<value_type>(item))
 	  return false;
-	}
       }
       return true;
     }
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index b526da9..470b7d0 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1779,7 +1779,7 @@
 		  } else {
 		      Swig_error(cparse_file, cparse_line, "Syntax error in input(1).\n");
 		  }
-		  exit(1);
+		  SWIG_exit(EXIT_FAILURE);
                }
 /* Out of class constructor/destructor declarations */
                | c_constructor_decl { 
@@ -3359,7 +3359,7 @@
 		   } else {
 		       Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon.\n");
 		   }
-		   exit(1);
+		   SWIG_exit(EXIT_FAILURE);
                }
               ;
 
@@ -3649,7 +3649,7 @@
 		    }
 		    if (err) {
 		      Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n");
-		      exit(1);
+		      SWIG_exit(EXIT_FAILURE);
 		    }
                 }
                 ;
@@ -4632,7 +4632,7 @@
 	       int start_line = cparse_line;
 	       skip_decl();
 	       Swig_error(cparse_file,start_line,"Syntax error in input(3).\n");
-	       exit(1);
+	       SWIG_exit(EXIT_FAILURE);
 	       } cpp_members { 
 		 $$ = $3;
    	     }
@@ -6375,6 +6375,12 @@
 		;
 
 /* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */
+
+/*
+   Note that "_last" attribute is not supposed to be set on the last enum element, as might be expected from its name, but on the _first_ one, and _only_ on it,
+   so we propagate it back to the first item while parsing and reset it on all the subsequent ones.
+ */
+
 enumlist	: enumlist_item {
 		  Setattr($1,"_last",$1);
 		  $$ = $1;
@@ -6389,6 +6395,8 @@
 		    set_nextSibling($1, $3);
 		    Setattr($1,"_last",Getattr($3,"_last"));
 		    Setattr($3,"_last",NULL);
+		  } else {
+		    Setattr($1,"_last",$1);
 		  }
 		  $$ = $1;
 		}
@@ -6397,6 +6405,8 @@
 		    set_nextSibling($1, $4);
 		    Setattr($1,"_last",Getattr($4,"_last"));
 		    Setattr($4,"_last",NULL);
+		  } else {
+		    Setattr($1,"_last",$1);
 		  }
 		  set_comment($1, $3);
 		  $$ = $1;
diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c
index 6b1a270..22d49fa 100644
--- a/Source/CParse/templ.c
+++ b/Source/CParse/templ.c
@@ -26,14 +26,19 @@
 }
 
 
-static void add_parms(ParmList *p, List *patchlist, List *typelist) {
+static void add_parms(ParmList *p, List *patchlist, List *typelist, int is_pattern) {
   while (p) {
     SwigType *ty = Getattr(p, "type");
     SwigType *val = Getattr(p, "value");
-    SwigType *name = Getattr(p, "name");
     Append(typelist, ty);
     Append(typelist, val);
-    Append(typelist, name);
+    if (is_pattern) {
+      /* Typemap patterns are not simple parameter lists.
+       * Output style ("out", "ret" etc) typemap names can be
+       * qualified names and so may need template expansion */
+      SwigType *name = Getattr(p, "name");
+      Append(typelist, name);
+    }
     Append(patchlist, val);
     p = nextSibling(p);
   }
@@ -108,8 +113,8 @@
       Append(typelist, Getattr(n, "name"));
     }
 
-    add_parms(Getattr(n, "parms"), cpatchlist, typelist);
-    add_parms(Getattr(n, "throws"), cpatchlist, typelist);
+    add_parms(Getattr(n, "parms"), cpatchlist, typelist, 0);
+    add_parms(Getattr(n, "throws"), cpatchlist, typelist, 0);
 
   } else if (Equal(nodeType, "class")) {
     /* Patch base classes */
@@ -175,8 +180,8 @@
     }
     Append(cpatchlist, Getattr(n, "code"));
     Append(typelist, Getattr(n, "decl"));
-    add_parms(Getattr(n, "parms"), cpatchlist, typelist);
-    add_parms(Getattr(n, "throws"), cpatchlist, typelist);
+    add_parms(Getattr(n, "parms"), cpatchlist, typelist, 0);
+    add_parms(Getattr(n, "throws"), cpatchlist, typelist, 0);
   } else if (Equal(nodeType, "destructor")) {
     /* We only need to patch the dtor of the template itself, not the destructors of any nested classes, so check that the parent of this node is the root
      * template node, with the special exception for %extend which adds its methods under an intermediate node. */
@@ -217,10 +222,10 @@
     Append(cpatchlist, Getattr(n, "code"));
     Append(typelist, Getattr(n, "type"));
     Append(typelist, Getattr(n, "decl"));
-    add_parms(Getattr(n, "parms"), cpatchlist, typelist);
-    add_parms(Getattr(n, "kwargs"), cpatchlist, typelist);
-    add_parms(Getattr(n, "pattern"), cpatchlist, typelist);
-    add_parms(Getattr(n, "throws"), cpatchlist, typelist);
+    add_parms(Getattr(n, "parms"), cpatchlist, typelist, 0);
+    add_parms(Getattr(n, "kwargs"), cpatchlist, typelist, 0);
+    add_parms(Getattr(n, "pattern"), cpatchlist, typelist, 1);
+    add_parms(Getattr(n, "throws"), cpatchlist, typelist, 0);
     cn = firstChild(n);
     while (cn) {
       cparse_template_expand(templnode, cn, tname, rname, templateargs, patchlist, typelist, cpatchlist);
diff --git a/Source/DOH/base.c b/Source/DOH/base.c
index 12351dd..f5e4188 100644
--- a/Source/DOH/base.c
+++ b/Source/DOH/base.c
@@ -756,25 +756,6 @@
 }
 
 /* -----------------------------------------------------------------------------
- * DohClose()
- * ----------------------------------------------------------------------------- */
-
-/*
-int DohClose(DOH *obj) {
-  DohBase *b = (DohBase *) obj;
-  DohObjInfo *objinfo;
-  if (DohCheck(obj)) {
-    objinfo = b->type;
-    if (objinfo->doh_file->doh_close) {
-      return (objinfo->doh_file->doh_close) (b);
-    }
-    return 0;
-  }
-  return fclose((FILE *) obj);
-}
-*/
-
-/* -----------------------------------------------------------------------------
  * DohIsString()
  * ----------------------------------------------------------------------------- */
 
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index 5a9bae2..7fb64c0 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -103,7 +103,6 @@
 #define DohNewFileFromFile DOH_NAMESPACE(NewFileFromFile)
 #define DohNewFileFromFd   DOH_NAMESPACE(NewFileFromFd)
 #define DohFileErrorDisplay   DOH_NAMESPACE(FileErrorDisplay)
-#define DohClose           DOH_NAMESPACE(Close)
 #define DohCopyto          DOH_NAMESPACE(Copyto)
 #define DohNewList         DOH_NAMESPACE(NewList)
 #define DohNewHash         DOH_NAMESPACE(NewHash)
@@ -303,15 +302,12 @@
  * Files
  * ----------------------------------------------------------------------------- */
 
-extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles);
+extern DOHFile *DohNewFile(DOHString *filename, const char *mode, DOHList *outfiles);
 extern DOHFile *DohNewFileFromFile(FILE *f);
 extern DOHFile *DohNewFileFromFd(int fd);
 extern void DohFileErrorDisplay(DOHString * filename);
-/*
- Deprecated, just use DohDelete
-extern int DohClose(DOH *file);
-*/
 extern int DohCopyto(DOHFile * input, DOHFile * output);
+extern void DohCloseAllOpenFiles(void);
 
 
 /* -----------------------------------------------------------------------------
@@ -392,7 +388,6 @@
 /* #define StringChar         DohStringChar */
 /* #define StringEqual        DohStringEqual */
 
-#define Close              DohClose
 #define vPrintf            DohvPrintf
 #define GetInt             DohGetInt
 #define GetDouble          DohGetDouble
@@ -424,7 +419,6 @@
 #define NewFileFromFile    DohNewFileFromFile
 #define NewFileFromFd      DohNewFileFromFd
 #define FileErrorDisplay   DohFileErrorDisplay
-#define Close              DohClose
 #define NewVoid            DohNewVoid
 #define Keys               DohKeys
 #define Strcmp             DohStrcmp
@@ -432,6 +426,7 @@
 #define Strstr             DohStrstr
 #define Strchr             DohStrchr
 #define Copyto             DohCopyto
+#define CloseAllOpenFiles  DohCloseAllOpenFiles
 #define Split              DohSplit
 #define SplitLines         DohSplitLines
 #define Setmark            DohSetmark
diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h
index c073bd9..87def9d 100644
--- a/Source/DOH/dohint.h
+++ b/Source/DOH/dohint.h
@@ -49,7 +49,6 @@
   int (*doh_ungetc) (DOH *obj, int ch);	/* Unget character */
   int (*doh_seek) (DOH *obj, long offset, int whence);	/* Seek */
   long (*doh_tell) (DOH *obj);	/* Tell */
-  int (*doh_close) (DOH *obj);	/* Close */
 } DohFileMethods;
 
 /* String methods */
diff --git a/Source/DOH/file.c b/Source/DOH/file.c
index 5c56771..570f84e 100644
--- a/Source/DOH/file.c
+++ b/Source/DOH/file.c
@@ -26,6 +26,73 @@
 } DohFile;
 
 /* -----------------------------------------------------------------------------
+ * open_files_list_instance
+ * open_files_list_add
+ * open_files_list_remove
+ *
+ * Singleton list containing all the files that have been opened by DohNewFile.
+ * Open file pointers are held in the list as strings so as to not affect the
+ * reference count of the underlying DOH objects.
+ * ----------------------------------------------------------------------------- */
+
+static DOHList *open_files_list_instance() {
+  static DOHList *all_open_files = 0;
+  if (!all_open_files)
+    all_open_files = DohNewList();
+  return all_open_files;
+}
+
+static void open_files_list_add(DohFile *f) {
+  DOHList *all_open_files = open_files_list_instance();
+  DOHString *sf = NewStringf("%p", f);
+  Append(all_open_files, sf);
+  Delete(sf);
+}
+
+static void open_files_list_remove(DohFile *f) {
+  int i;
+  int removed = 0;
+  DOHList *all_open_files = open_files_list_instance();
+  DOHString *sf = NewStringf("%p", f);
+  for (i = 0; i < DohLen(all_open_files); i++) {
+    DOHString *sf_i = Getitem(all_open_files, i);
+    if (Strcmp(sf, sf_i) == 0) {
+      DohDelitem(all_open_files, i);
+      removed = 1;
+      break;
+    }
+  }
+  Delete(sf);
+  assert(removed);
+}
+
+/* -----------------------------------------------------------------------------
+ * DohCloseAllOpenFiles()
+ *
+ * Close all opened files, to be called on program termination
+ * ----------------------------------------------------------------------------- */
+
+void DohCloseAllOpenFiles() {
+  int i;
+  DOHList *all_open_files = open_files_list_instance();
+  for (i = 0; i < DohLen(all_open_files); i++) {
+    DohFile *f = 0;
+    DOHString *sf = Getitem(all_open_files, i);
+    int check = sscanf(Char(sf), "%p", (void **)&f);
+    assert(check == 1);
+    if (f->closeondel) {
+      if (f->filep) {
+	check = fclose(f->filep);
+	assert(check == 0);
+      }
+      f->closeondel = 0;
+      f->filep = 0;
+    }
+  }
+  DohClear(all_open_files);
+}
+
+/* -----------------------------------------------------------------------------
  * DelFile()
  * ----------------------------------------------------------------------------- */
 
@@ -40,6 +107,7 @@
       close(f->fd);
     }
 #endif
+  open_files_list_remove(f);
   }
   DohFree(f);
 }
@@ -166,27 +234,6 @@
   return -1;
 }
 
-/* -----------------------------------------------------------------------------
- * File_close()
- *
- * Close the file
- * ----------------------------------------------------------------------------- */
-
-static int File_close(DOH *fo) {
-  int ret = 0;
-  DohFile *f = (DohFile *) ObjData(fo);
-  if (f->filep) {
-    ret = fclose(f->filep);
-    f->filep = 0;
-  } else if (f->fd) {
-#ifdef DOH_INTFILE
-    ret = close(f->fd);
-    f->fd = 0;
-#endif
-  }
-  return ret;
-}
-
 static DohFileMethods FileFileMethods = {
   File_read,
   File_write,
@@ -195,7 +242,6 @@
   File_ungetc,
   File_seek,
   File_tell,
-  File_close,			/* close */
 };
 
 static DohObjInfo DohFileType = {
@@ -231,8 +277,9 @@
  * If newfiles is non-zero, the filename is added to the list of new files.
  * ----------------------------------------------------------------------------- */
 
-DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) {
+DOH *DohNewFile(DOHString *filename, const char *mode, DOHList *newfiles) {
   DohFile *f;
+  DOH *obj;
   FILE *file;
   char *filen;
 
@@ -251,7 +298,9 @@
   f->filep = file;
   f->fd = 0;
   f->closeondel = 1;
-  return DohObjMalloc(&DohFileType, f);
+  obj = DohObjMalloc(&DohFileType, f);
+  open_files_list_add(f);
+  return obj;
 }
 
 /* -----------------------------------------------------------------------------
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index 94d2737..6c67285 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -987,7 +987,6 @@
   String_ungetc,
   String_seek,
   String_tell,
-  0,				/* close */
 };
 
 static DohStringMethods StringStringMethods = {
diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx
index 7286ade..2e826b2 100644
--- a/Source/Doxygen/doxyparser.cxx
+++ b/Source/Doxygen/doxyparser.cxx
@@ -289,6 +289,18 @@
   TokenListCIt endOfParagraph = m_tokenListIt;
 
   while (endOfParagraph != tokList.end()) {
+    // If \code or \verbatim is encountered within a paragraph, then
+    // go all the way to the end of that command, since the content
+    // could contain empty lines that would appear to be paragraph
+    // ends:
+    if (endOfParagraph->m_tokenType == COMMAND &&
+	(endOfParagraph->m_tokenString == "code" ||
+	 endOfParagraph->m_tokenString == "verbatim")) {
+      const string theCommand = endOfParagraph->m_tokenString;
+      endOfParagraph = getEndCommand("end" + theCommand, tokList);
+      endOfParagraph++; // Move after the end command
+      return endOfParagraph;
+    }
     if (endOfParagraph->m_tokenType == END_LINE) {
       endOfParagraph++;
       if (endOfParagraph != tokList.end()
@@ -959,7 +971,9 @@
   std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string";
   DoxygenEntityList aNewList;
 
-  while (m_tokenListIt != endParsingIndex) {
+  // Less than check (instead of not equal) is a safeguard in case the
+  // iterator is incremented past the end
+  while (m_tokenListIt < endParsingIndex) {
 
     Token currToken = *m_tokenListIt;
 
@@ -976,6 +990,10 @@
       addCommand(currPlainstringCommandType, tokList, aNewList);
     }
 
+    // If addCommand above misbehaves, it can move the iterator past endParsingIndex
+    if (m_tokenListIt > endParsingIndex)
+      printListError(WARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE, "Unexpected iterator value in DoxygenParser::parse");
+
     if (endParsingIndex != tokList.end() && m_tokenListIt == tokList.end()) {
       // this could happen if we can't reach the original endParsingIndex
       printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of Doxygen comment encountered.");
@@ -1294,7 +1312,7 @@
     string lastLine = lines[lines.size() - 1];
 
     if (trim(lastLine).empty()) {
-      lines.pop_back(); // remove trailing empy line
+      lines.pop_back(); // remove trailing empty line
     }
   }
 
diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx
index fc3b0ea..eb48993 100644
--- a/Source/Doxygen/pydoc.cxx
+++ b/Source/Doxygen/pydoc.cxx
@@ -138,6 +138,52 @@
     s.erase(lastNonSpace + 1);
 }
 
+// Erase the first character in the string if it is a newline
+static void eraseLeadingNewLine(string &s) {
+  if (!s.empty() && s[0] == '\n')
+    s.erase(s.begin());
+}
+
+// Erase the last character in the string if it is a newline
+static void eraseTrailingNewLine(string &s) {
+  if (!s.empty() && s[s.size() - 1] == '\n')
+    s.erase(s.size() - 1);
+}
+
+// Check the generated docstring line by line and make sure that any
+// code and verbatim blocks have an empty line preceding them, which
+// is necessary for Sphinx.  Additionally, this strips any empty lines
+// appearing at the beginning of the docstring.
+static string padCodeAndVerbatimBlocks(const string &docString) {
+  std::string result;
+
+  std::istringstream iss(docString);
+
+  // Initialize to false because there is no previous line yet
+  bool lastLineWasNonBlank = false;
+  
+  for (string line; std::getline(iss, line); result += line) {
+    if (!result.empty()) {
+      // Terminate the previous line
+      result += '\n';
+    }
+
+    const size_t pos = line.find_first_not_of(" \t");
+    if (pos == string::npos) {
+      lastLineWasNonBlank = false;
+    } else {
+      if (lastLineWasNonBlank &&
+	  (line.compare(pos, 13, ".. code-block") == 0 ||
+	  line.compare(pos, 7, ".. math") == 0)) {
+	// Must separate code or math blocks from the previous line
+	result += '\n';
+      }
+      lastLineWasNonBlank = true;
+    }
+  }
+  return result;
+}
+
 /* static */
 PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) {
   return make_pair(handler, std::string());
@@ -219,7 +265,7 @@
   tagHandlers["short"] = make_handler(&PyDocConverter::handleParagraph);
   tagHandlers["todo"] = make_handler(&PyDocConverter::handleParagraph);
   tagHandlers["version"] = make_handler(&PyDocConverter::handleParagraph);
-  tagHandlers["verbatim"] = make_handler(&PyDocConverter::handleParagraph);
+  tagHandlers["verbatim"] = make_handler(&PyDocConverter::handleVerbatimBlock);
   tagHandlers["warning"] = make_handler(&PyDocConverter::handleParagraph);
   tagHandlers["xmlonly"] = make_handler(&PyDocConverter::handleParagraph);
   // these commands have special handlers
@@ -419,6 +465,17 @@
   translatedComment += translateSubtree(tag);
 }
 
+void PyDocConverter::handleVerbatimBlock(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
+  string verb = translateSubtree(tag);
+
+  eraseLeadingNewLine(verb);
+
+  // Remove the last newline to prevent doubling the newline already present after \endverbatim
+  trimWhitespace(verb); // Needed to catch trailing newline below
+  eraseTrailingNewLine(verb);
+  translatedComment += verb;
+}
+
 void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
   IndentGuard indent;
 
@@ -433,7 +490,6 @@
     indent.Init(translatedComment, m_indent);
 
     trimWhitespace(translatedComment);
-    translatedComment += '\n';
 
     const string formulaIndent = indent.getFirstLineIndent();
     translatedComment += formulaIndent;
@@ -467,8 +523,6 @@
 
   if (inlineFormula) {
     translatedComment += "`";
-  } else {
-    translatedComment += '\n';
   }
 }
 
@@ -476,23 +530,28 @@
   IndentGuard indent(translatedComment, m_indent);
 
   trimWhitespace(translatedComment);
-  translatedComment += '\n';
 
   // Use the current indent for the code-block line itself.
-  string codeIndent = indent.getFirstLineIndent();
-  translatedComment += codeIndent;
+  translatedComment += indent.getFirstLineIndent();
 
   // Go out on a limb and assume that examples in the C or C++ sources use C++.
   // In the worst case, we'll highlight C code using C++ syntax which is not a
   // big deal (TODO: handle Doxygen code command language argument).
   translatedComment += ".. code-block:: c++\n\n";
 
-  // For now on, use extra indent level for all the subsequent lines.
-  codeIndent += m_indent;
+  // Specify the level of extra indentation that will be used for
+  // subsequent lines within the code block.  Note that the correct
+  // "starting indentation" is already present in the input, so we
+  // only need to add the desired code block indentation.
+  string codeIndent = m_indent;
 
   std::string code;
   handleTagVerbatim(tag, code, arg);
 
+  // Try and remove leading newline, which is present for block \code
+  // command:
+  eraseLeadingNewLine(code);
+
   translatedComment += codeIndent;
   for (size_t n = 0; n < code.length(); n++) {
     if (code[n] == '\n') {
@@ -510,8 +569,11 @@
   }
 
   trimWhitespace(translatedComment);
-  if (*translatedComment.rbegin() != '\n')
-    translatedComment += '\n';
+
+  // For block commands, the translator adds the newline after
+  // \endcode, so try and compensate by removing the last newline from
+  // the code text:
+  eraseTrailingNewLine(translatedComment);
 }
 
 void PyDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
@@ -519,7 +581,7 @@
 }
 
 void PyDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
-  translatedComment += arg + " ";
+  translatedComment += arg;
   for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) {
     translatedComment += it->data;
   }
@@ -833,9 +895,10 @@
   if (!pyDocString.empty()) {
 
     // remove the last '\n' since additional one is added during writing to file
-    if (pyDocString[pyDocString.size() - 1] == '\n') {
-      pyDocString.erase(pyDocString.size() - 1);
-    }
+    eraseTrailingNewLine(pyDocString);
+
+    // ensure that a blank line occurs before code or math blocks
+    pyDocString = padCodeAndVerbatimBlocks(pyDocString);
 
     if (m_flags & debug_translator) {
       std::cout << "\n---RESULT IN PYDOC---" << std::endl;
diff --git a/Source/Doxygen/pydoc.h b/Source/Doxygen/pydoc.h
index 8f432fd..df8997d 100644
--- a/Source/Doxygen/pydoc.h
+++ b/Source/Doxygen/pydoc.h
@@ -80,6 +80,11 @@
   void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg = std::string());
 
   /*
+   * Handle Doxygen verbatim tag
+   */
+  void handleVerbatimBlock(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg = std::string());
+
+  /*
    * Handle one of the Doxygen formula-related tags.
    */
   void handleMath(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index fbcea4d..a08693a 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -221,6 +221,7 @@
 #define WARN_DOXYGEN_HTML_ERROR               563
 #define WARN_DOXYGEN_COMMAND_ERROR            564
 #define WARN_DOXYGEN_UNKNOWN_CHARACTER        565
+#define WARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE  566
 
 /* -- Reserved (600-799) -- */
 
diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx
index f32d349..97af186 100644
--- a/Source/Modules/allegrocl.cxx
+++ b/Source/Modules/allegrocl.cxx
@@ -471,7 +471,7 @@
 	  // a synonym type was found (held in variable 'match')
 	  // Printf(stderr, "setting primary synonym of %p to %p\n", new_node, match);
 	  if (new_node == match)
-	    Printf(stderr, "Hey-4 * - '%s' is a synonym of iteself!\n", Getattr(new_node, "name"));
+	    Printf(stderr, "Hey-4 * - '%s' is a synonym of itself!\n", Getattr(new_node, "name"));
 	  Setattr(new_node, "allegrocl:synonym-of", match);
 	  // Printf(stderr,"*** 4\n");
 	  add_linked_type(new_node);
diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx
index 68a42a2..76b6455 100644
--- a/Source/Modules/chicken.cxx
+++ b/Source/Modules/chicken.cxx
@@ -547,7 +547,7 @@
   }
   emit_return_variable(n, d, f);
 
-  /* Insert the argumetn output code */
+  /* Insert the argument output code */
   Printv(f->code, argout, NIL);
 
   /* Output cleanup code */
@@ -1456,7 +1456,7 @@
   if (value)
     return value;
   else {
-    Swig_error(input_file, line_number, "Internal Error: attempting to reference non-existant primitive name %s\n", name);
+    Swig_error(input_file, line_number, "Internal Error: attempting to reference non-existent primitive name %s\n", name);
     return NewString("#f");
   }
 }
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index ff73c30..17100b3 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -1533,7 +1533,7 @@
       if (classname_substituted_flag) {
 	if (SwigType_isenum(t)) {
 	  // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
-	  Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
+	  Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
 	} else {
 	  // This handles function pointers using the %constant directive
 	  Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
@@ -1732,7 +1732,7 @@
       Replaceall(cptr_method_name, ".", "_");
       Replaceall(cptr_method_name, "$interfacename", interface_name);
 
-      String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name);
+      String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), cptr_method_name);
       upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
 
       Delete(upcast_method_name);
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index 7b42ff9..461c69e 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -255,7 +255,7 @@
     if (goops) {
       if (linkage != GUILE_LSTYLE_PASSIVE && linkage != GUILE_LSTYLE_MODULE) {
 	Printf(stderr, "guile: GOOPS support requires passive or module linkage\n");
-	exit(1);
+	SWIG_exit(EXIT_FAILURE);
       }
     }
 
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index cb41781..fcc8381 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -1633,7 +1633,7 @@
       if (classname_substituted_flag) {
 	if (SwigType_isenum(t)) {
 	  // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
-	  Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
+	  Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
 	} else {
 	  // This handles function pointers using the %constant directive
 	  Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
@@ -1876,7 +1876,7 @@
       Replaceall(cptr_method_name, ".", "_");
       Replaceall(cptr_method_name, "$interfacename", interface_name);
 
-      String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name);
+      String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), cptr_method_name);
       upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
       Delete(upcast_method_name);
       Delete(cptr_method_name);
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index c6bd148..72b765b 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -23,6 +23,7 @@
 #include "swigwarn.h"
 #include "cparse.h"
 #include <ctype.h>
+#include <errno.h>
 #include <limits.h>		// for INT_MAX
 
 // Global variables
@@ -1376,13 +1377,15 @@
   while (freeze) {
   }
 
-  if ((werror) && (Swig_warn_count())) {
-    return Swig_warn_count();
-  }
-
   delete lang;
 
-  return Swig_error_count();
+  int error_count = werror ? Swig_warn_count() : 0;
+  error_count += Swig_error_count();
+
+  if (error_count != 0)
+    SWIG_exit(error_count);
+
+  return 0;
 }
 
 /* -----------------------------------------------------------------------------
@@ -1394,5 +1397,20 @@
 void SWIG_exit(int exit_code) {
   while (freeze) {
   }
+
+  if (exit_code > 0) {
+    CloseAllOpenFiles();
+
+    /* Remove all generated files */
+    if (all_output_files) {
+      for (int i = 0; i < Len(all_output_files); i++) {
+	String *filename = Getitem(all_output_files, i);
+	int removed = remove(Char(filename));
+	if (removed == -1)
+	  fprintf(stderr, "On exit, could not delete file %s: %s\n", Char(filename), strerror(errno));
+      }
+    }
+  }
+
   exit(exit_code);
 }
diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
index 5438741..7886813 100644
--- a/Source/Modules/mzscheme.cxx
+++ b/Source/Modules/mzscheme.cxx
@@ -221,7 +221,6 @@
 
     Wrapper *f = NewWrapper();
     String *proc_name = NewString("");
-    String *source = NewString("");
     String *target = NewString("");
     String *arg = NewString("");
     String *cleanup = NewString("");
@@ -312,10 +311,9 @@
       String *ln = Getattr(p, "lname");
 
       // Produce names of source and target
-      Clear(source);
       Clear(target);
       Clear(arg);
-      Printf(source, "argv[%d]", i);
+      String *source = NewStringf("argv[%d]", i);
       Printf(target, "%s", ln);
       Printv(arg, Getattr(p, "name"), NIL);
 
@@ -339,6 +337,7 @@
       if (i >= numreq) {
 	Printf(f->code, "}\n");
       }
+      Delete(source);
     }
 
     /* Insert constraint checking code */
@@ -465,7 +464,6 @@
     }
 
     Delete(proc_name);
-    Delete(source);
     Delete(target);
     Delete(arg);
     Delete(outarg);
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 7e59def..6f2a349 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -473,7 +473,6 @@
 
     Wrapper *f = NewWrapper();
     String *proc_name = NewString("");
-    String *source = NewString("");
     String *target = NewString("");
     String *arg = NewString("");
     String *cleanup = NewString("");
@@ -580,10 +579,9 @@
       pt = SwigType_typedef_qualified(pt);
 
       // Produce names of source and target
-      Clear(source);
       Clear(target);
       Clear(arg);
-      Printf(source, "caml_list_nth(args,%d)", i);
+      String *source = NewStringf("caml_list_nth(args,%d)", i);
       Printf(target, "%s", ln);
       Printv(arg, Getattr(p, "name"), NIL);
 
@@ -607,6 +605,7 @@
       if (i >= numreq) {
 	Printf(f->code, "}\n");
       }
+      Delete(source);
     }
 
     /* Insert constraint checking code */
@@ -787,7 +786,6 @@
       Printf(f_mlibody, "val %s : c_obj -> c_obj\n", mangled_name);
 
     Delete(proc_name);
-    Delete(source);
     Delete(target);
     Delete(arg);
     Delete(outarg);
@@ -1866,9 +1864,9 @@
   }
 
   String *runtimeCode() {
-    String *s = Swig_include_sys("ocaml.swg");
+    String *s = Swig_include_sys("ocamlrun.swg");
     if (!s) {
-      Printf(stderr, "*** Unable to open 'ocaml.swg'\n");
+      Printf(stderr, "*** Unable to open 'ocamlrun.swg'\n");
       s = NewString("");
     }
     return s;
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 994fbd7..1edbd87 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -676,7 +676,7 @@
       Delete(s_fakeoowrappers);
       s_fakeoowrappers = NULL;
     }
-    Printf(f_phpcode, "%s\n?>\n", s_phpclasses);
+    Printf(f_phpcode, "%s\n", s_phpclasses);
     Delete(f_phpcode);
 
     return SWIG_OK;
@@ -1223,7 +1223,7 @@
 	/* FIXME: How should this be handled?  The rest of SWIG just seems
 	 * to not bother checking for malloc failing! */
 	fprintf(stderr, "Malloc failed!\n");
-	exit(1);
+	SWIG_exit(EXIT_FAILURE);
       }
       for (i = 0; i < max_num_of_arguments; ++i) {
 	arg_names[i] = NULL;
@@ -1235,7 +1235,7 @@
 	/* FIXME: How should this be handled?  The rest of SWIG just seems
 	 * to not bother checking for malloc failing! */
 	fprintf(stderr, "Malloc failed!\n");
-	exit(1);
+	SWIG_exit(EXIT_FAILURE);
       }
       for (i = 0; i < max_num_of_arguments; ++i) {
 	arg_values[i] = NULL;
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
old mode 100755
new mode 100644
index b849335..ea31af0
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * This file is part of SWIG, which is licensed as a whole under version 3 
+ * This file is part of SWIG, which is licensed as a whole under version 3
  * (or any later version) of the GNU General Public License. Some additional
  * terms also apply to certain portions of SWIG. The full details of the SWIG
  * license and copyrights can be found in the LICENSE and COPYRIGHT files
@@ -16,7 +16,6 @@
 #include "cparse.h"
 #include <ctype.h>
 #include <errno.h>
-#include <stdlib.h>
 #include "pydoc.h"
 
 #include <stdint.h>
@@ -462,12 +461,12 @@
    * ------------------------------------------------------------ */
 
   virtual int top(Node *n) {
-    /* check if directors are enabled for this module.  note: this 
+    /* check if directors are enabled for this module.  note: this
      * is a "master" switch, without which no director code will be
      * emitted.  %feature("director") statements are also required
      * to enable directors for individual classes or methods.
      *
-     * use %module(directors="1") modulename at the start of the 
+     * use %module(directors="1") modulename at the start of the
      * interface file to enable director generation.
      */
     String *mod_docstring = NULL;
@@ -685,13 +684,13 @@
 	 * same package, otherwise load it as a global module.
 	 */
         Printv(default_import_code, "# Import the low-level C/C++ module\n", NULL);
-        Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL);
+        Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL);
         Printv(default_import_code, tab4, "from . import ", module, "\n", NULL);
         Printv(default_import_code, "else:\n", NULL);
         Printv(default_import_code, tab4, "import ", module, "\n", NULL);
       } else {
         Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL);
-        Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL);
+        Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL);
         Printv(default_import_code, tab4, "from .", module, " import *\n", NULL);
         Printv(default_import_code, "else:\n", NULL);
         Printv(default_import_code, tab4, "from ", module, " import *\n", NULL);
@@ -707,40 +706,13 @@
 	Printf(f_shadow, "_swig_new_static_method = %s.SWIG_PyStaticMethod_New\n", module);
       }
 
-      {
-	// Python-2.2 object hack
-	Printv(f_shadow,
-	       "\n", "def _swig_setattr_nondynamic(self, class_type, name, value, static=1):\n",
-	       tab4, "if name == \"thisown\":\n", tab8, "return self.this.own(value)\n",
-	       tab4, "if name == \"this\":\n", tab8, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
-#ifdef USE_THISOWN
-	       tab4, tab8, "if hasattr(value,\"thisown\"):\n", tab8, tab8, "self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
-#endif
-	       tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name, None)\n", tab4, "if method:\n", tab4, tab4, "return method(self, value)\n",
-#ifdef USE_THISOWN
-	       tab4, "if not static or name == \"thisown\":\n",
-#else
-	       tab4, "if not static:\n",
-#endif
-	       NIL);
-	Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL);
-	Printv(f_shadow,
-	       tab4, "else:\n",
-	       tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n",
-	        "\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
-
-	Printv(f_shadow,
-	       "\n", "def _swig_getattr(self, class_type, name):\n",
-	       tab4, "if name == \"thisown\":\n", tab8, "return self.this.own()\n",
-	       tab4, "method = class_type.__swig_getmethods__.get(name, None)\n",
-	       tab4, "if method:\n", tab8, "return method(self)\n",
-	       tab4, "raise AttributeError(\"'%s' object has no attribute '%s'\" % (class_type.__name__, name))\n\n", NIL);
-
-	Printv(f_shadow,
-	        "\n", "def _swig_repr(self):\n",
-	       tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n",
-	       tab4, "except __builtin__.Exception:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
-      }
+      Printv(f_shadow, "\n",
+	     "def _swig_repr(self):\n",
+	     tab4, "try:\n",
+	     tab4, tab4, "strthis = \"proxy of \" + self.this.__repr__()\n",
+	     tab4, "except __builtin__.Exception:\n",
+	     tab4, tab4, "strthis = \"\"\n",
+	     tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
 
       Printv(f_shadow,  "\n",
 	     "def _swig_setattr_nondynamic_instance_variable(set):\n",
@@ -875,7 +847,7 @@
 
       Printv(f_shadow_py, "\nfrom sys import version_info as _swig_python_version_info\n", NULL);
       Printv(f_shadow_py, "if _swig_python_version_info < (2, 7, 0):\n", NULL);
-      Printv(f_shadow_py, tab4, "raise RuntimeError('Python 2.7 or later required')\n\n", NULL);
+      Printv(f_shadow_py, tab4, "raise RuntimeError(\"Python 2.7 or later required\")\n\n", NULL);
 
       if (Len(f_shadow_after_begin) > 0)
 	Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL);
@@ -1633,7 +1605,7 @@
    *
    * For functions that have not had nameless parameters set in the Language class.
    *
-   * Inputs: 
+   * Inputs:
    *   plist - entire parameter list
    *   arg_num - the number to start from when naming arguments
    * Side effects:
@@ -1747,7 +1719,7 @@
       }
       // Write the function annotation
       if (func_annotation)
-	Printf(doc, ": '%s'", type_str);
+	Printf(doc, ": \"%s\"", type_str);
 
       // Write default value
       if (value && !calling) {
@@ -1755,7 +1727,7 @@
 	if (new_value) {
 	  value = new_value;
 	} else {
-	  // Even if the value is not representable in the target language, still use it in the documentaiton, for compatibility with the previous SWIG versions
+	  // Even if the value is not representable in the target language, still use it in the documentation, for compatibility with the previous SWIG versions
 	  // and because it can still be useful to see the C++ expression there.
 	  Node *lookup = Swig_symbol_clookup(value, 0);
 	  if (lookup)
@@ -2038,10 +2010,10 @@
       // This must have been an octal number. This is the only case we
       // cannot use in Python directly, since Python 2 and 3 use non-
       // compatible representations.
-      result = NewString(*s == '-' ? "int('-" : "int('");
+      result = NewString(*s == '-' ? "int(\"-" : "int(\"");
       String *octal_string = NewStringWithSize(p, (int) (end - p));
       Append(result, octal_string);
-      Append(result, "', 8)");
+      Append(result, "\", 8)");
       Delete(octal_string);
       return result;
     }
@@ -2200,7 +2172,7 @@
     while (i) {
       Node *nn = Getattr(i, "defaultargs");
       if (nn != h) {
-	/* Check if overloaded function has defaultargs and 
+	/* Check if overloaded function has defaultargs and
 	 * pointed to the first overloaded. */
 	return true;
       }
@@ -2217,7 +2189,7 @@
    * reuse make_autodocParmList() to do so.
    * ------------------------------------------------------------ */
   String *make_pyParmList(Node *n, bool in_class, bool is_calling, int kw, bool has_self_for_count = false) {
-    /* Get the original function for a defaultargs copy, 
+    /* Get the original function for a defaultargs copy,
      * see default_arguments() in parser.y. */
     Node *nn = Getattr(n, "defaultargs");
     if (nn)
@@ -2999,9 +2971,9 @@
     }
 
     /* if the object is a director, and the method call originated from its
-     * underlying python object, resolve the call by going up the c++ 
-     * inheritance chain.  otherwise try to resolve the method in python.  
-     * without this check an infinite loop is set up between the director and 
+     * underlying python object, resolve the call by going up the c++
+     * inheritance chain.  otherwise try to resolve the method in python.
+     * without this check an infinite loop is set up between the director and
      * shadow class method calls.
      */
 
@@ -3095,7 +3067,7 @@
       //        base class pointers!
 
       /* New addition to unwrap director return values so that the original
-       * python object is returned instead. 
+       * python object is returned instead.
        */
 #if 1
       int unwrap = 0;
@@ -3640,7 +3612,7 @@
   }
 
 
-  /* ------------------------------------------------------------ 
+  /* ------------------------------------------------------------
    * nativeWrapper()
    * ------------------------------------------------------------ */
 
@@ -3675,7 +3647,7 @@
   /* ---------------------------------------------------------------
    * classDirectorMethod()
    *
-   * Emit a virtual director method to pass a method call on to the 
+   * Emit a virtual director method to pass a method call on to the
    * underlying Python object.
    * ** Moved down due to gcc-2.96 internal error **
    * --------------------------------------------------------------- */
@@ -4452,7 +4424,7 @@
 	    Printv(f_shadow, tab4, str, "\n\n", NIL);
 	}
 
-	Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL);
+	Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc=\"The membership flag\")\n", NIL);
 	/* Add static attribute */
 	if (GetFlag(n, "feature:python:nondynamic")) {
 	  Printv(f_shadow_file, tab4, "__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n", NIL);
@@ -4786,7 +4758,7 @@
     int oldshadow = shadow;
     int use_director = Swig_directorclass(n);
 
-    /* 
+    /*
      * If we're wrapping the constructor of a C++ director class, prepend a new parameter
      * to receive the scripting language object (e.g. 'self')
      *
@@ -5115,7 +5087,7 @@
 
   /* ------------------------------------------------------------
    * insertDirective()
-   * 
+   *
    * Hook for %insert directive.   We're going to look for special %shadow inserts
    * as a special case so we can do indenting correctly
    * ------------------------------------------------------------ */
@@ -5198,7 +5170,7 @@
 /* ---------------------------------------------------------------
  * classDirectorMethod()
  *
- * Emit a virtual director method to pass a method call on to the 
+ * Emit a virtual director method to pass a method call on to the
  * underlying Python object.
  *
  * ** Moved it here due to internal error on gcc-2.96 **
@@ -5299,7 +5271,7 @@
   Append(w->def, " {");
   Append(declaration, ";\n");
 
-  /* declare method return value 
+  /* declare method return value
    * if the return value is a reference or const reference, a specialized typemap must
    * handle it, including declaration of c_result ($result).
    */
@@ -5459,7 +5431,7 @@
 	  } else {
 	    Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL);
 	    Printf(wrap_args, "%s = SWIG_InternalNewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle);
-	    //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", 
+	    //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n",
 	    //       source, nonconst, base);
 	    Printv(arglist, source, NIL);
 	  }
diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx
index 4fea0ce..23e45f7 100644
--- a/Source/Modules/scilab.cxx
+++ b/Source/Modules/scilab.cxx
@@ -496,7 +496,7 @@
     /* Add the failure cleanup code */
     /* TODO */
 
-    /* Final substititions if applicable */
+    /* Final substitutions if applicable */
     Replaceall(wrapper->code, "$symname", functionName);
 
     /* Set CheckInputArgument and CheckOutputArgument input arguments */
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index 583cb13..bfb93d1 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -371,7 +371,6 @@
 int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm);
 void emit_parameter_variables(ParmList *l, Wrapper *f);
 void emit_return_variable(Node *n, SwigType *rt, Wrapper *f);
-void SWIG_exit(int);		/* use EXIT_{SUCCESS,FAILURE} */
 void SWIG_config_file(const_String_or_char_ptr );
 const String *SWIG_output_directory();
 void SWIG_config_cppext(const char *ext);
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index 57125fc..8dbf086 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -961,7 +961,7 @@
       if (Getattr(c, "sym:overloaded") != checkoverloaded) {
         Printf(stdout, "sym:overloaded error c:%p checkoverloaded:%p\n", c, checkoverloaded);
         Swig_print_node(c);
-        exit (1);
+        SWIG_exit(EXIT_FAILURE);
       }
 
       String *decl = Strcmp(nodeType(c), "using") == 0 ? NewString("------") : Getattr(c, "decl");
@@ -969,7 +969,7 @@
       if (!Getattr(c, "sym:overloaded")) {
         Printf(stdout, "sym:overloaded error.....%p\n", c);
         Swig_print_node(c);
-        exit (1);
+        SWIG_exit(EXIT_FAILURE);
       }
       c = Getattr(c, "sym:nextSibling");
     }
diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c
index 74076a5..6970dc1 100644
--- a/Source/Swig/getopt.c
+++ b/Source/Swig/getopt.c
@@ -16,7 +16,6 @@
  * sure there are no unmarked options.
  * 
  * TODO: 
- *     - This module needs to be modified so that it doesn't call exit().
  *       Should have cleaner error handling in general.
  * ----------------------------------------------------------------------------- */
 
@@ -88,11 +87,11 @@
   }
   if (error) {
     Printf(stderr, "Use 'swig -help' for available options.\n");
-    exit(1);
+    SWIG_exit(EXIT_FAILURE);
   }
   if (check_input && marked[numargs - 1]) {
     Printf(stderr, "Must specify an input file. Use -help for available options.\n");
-    exit(1);
+    SWIG_exit(EXIT_FAILURE);
   }
 }
 
@@ -105,5 +104,5 @@
 void Swig_arg_error(void) {
   Printf(stderr, "SWIG : Unable to parse command line options.\n");
   Printf(stderr, "Use 'swig -help' for available options.\n");
-  exit(1);
+  SWIG_exit(EXIT_FAILURE);
 }
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index 6b07118..7b81847 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -1177,7 +1177,7 @@
       pclose(fp);
     } else {
       Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s);
-      exit(1);
+      SWIG_exit(EXIT_FAILURE);
     }
   }
 #endif
@@ -1327,7 +1327,8 @@
 
 err_out:
   Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
-  exit(1);
+  SWIG_exit(EXIT_FAILURE);
+  return 0;
 }
 
 /* This function copies len characters from src to dst, possibly applying case conversions to them: if convertCase is 1, to upper case and if it is -1, to lower
@@ -1449,7 +1450,7 @@
     if (!compiled_pat) {
       Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
           pcre_error, Char(pattern), pcre_errorpos);
-      exit(1);
+      SWIG_exit(EXIT_FAILURE);
     }
     rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
     if (rc >= 0) {
@@ -1457,7 +1458,7 @@
     } else if (rc != PCRE_ERROR_NOMATCH) {
       Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
 	rc, Char(pattern), input);
-      exit(1);
+      SWIG_exit(EXIT_FAILURE);
     }
   }
 
@@ -1475,7 +1476,8 @@
 
 String *Swig_string_regex(String *s) {
   Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
-  exit(1);
+  SWIG_exit(EXIT_FAILURE);
+  return 0;
 }
 
 String *Swig_pcre_version(void) {
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 1b6c963..6689ceb 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -1105,7 +1105,7 @@
     Swig_error("SWIG", Getline(n),
                "Invalid regex \"%s\": compilation failed at %d: %s\n",
                Char(pattern), errpos, err);
-    exit(1);
+    SWIG_exit(EXIT_FAILURE);
   }
 
   rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
@@ -1118,7 +1118,7 @@
     Swig_error("SWIG", Getline(n),
                "Matching \"%s\" against regex \"%s\" failed: %d\n",
                Char(s), Char(pattern), rc);
-    exit(1);
+    SWIG_exit(EXIT_FAILURE);
   }
 
   return 1;
@@ -1131,7 +1131,7 @@
   (void)s;
   Swig_error("SWIG", Getline(n),
              "PCRE regex matching is not available in this SWIG build.\n");
-  exit(1);
+  SWIG_exit(EXIT_FAILURE);
 }
 
 #endif /* HAVE_PCRE/!HAVE_PCRE */
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index 908bc74..e5a267a 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -833,7 +833,7 @@
 	return SWIG_TOKEN_MODEQUAL;
       } else if (c == '}') {
 	Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n");
-	exit(1);
+	SWIG_exit(EXIT_FAILURE);
       } else {
 	retract(s, 1);
 	return SWIG_TOKEN_PERCENT;
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 1acd32d..e0783da 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -438,6 +438,7 @@
   extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
   extern void Swig_print(DOH *object, int count);
   extern void Swig_print_with_location(DOH *object, int count);
+  extern void SWIG_exit(int exit_code);
 
 
 /* -- template init -- */
diff --git a/Tools/obs-buildlogs.py b/Tools/obs-buildlogs.py
index b97e7db..1c77e80 100755
--- a/Tools/obs-buildlogs.py
+++ b/Tools/obs-buildlogs.py
@@ -11,9 +11,9 @@
     os.remove(file)
 
 def download():
-  repos = subprocess.Popen(['osc', 'repositories'], stdout=subprocess.PIPE)
+  repos = subprocess.Popen(["osc", "repositories"], stdout=subprocess.PIPE)
   for line in repos.stdout:
-    command = ['osc', 'buildlog', '--last'] + line.split()
+    command = ["osc", "buildlog", "--last"] + line.split()
     filename = "-".join(line.split()) + ".log"
     print("Downloading logs using: {}".format(" ".join(command)))
     buildlog = subprocess.Popen(command, stdout=subprocess.PIPE)
diff --git a/Tools/testflags.py b/Tools/testflags.py
index bf85f56..f3d216b 100755
--- a/Tools/testflags.py
+++ b/Tools/testflags.py
@@ -23,7 +23,7 @@
         "scilab":"-Werror " + c_common,
            "tcl":"-Werror " + c_common,
     }
-    if compiler == 'clang':
+    if compiler == "clang":
         cflags["guile"] += " -Wno-attributes" # -Wno-attributes is for clang LLVM 3.5 and bdw-gc < 7.5 used by guile
 
     if language not in cflags:
@@ -54,7 +54,7 @@
         "scilab":"-Werror " + cxx_common,
            "tcl":"-Werror " + cxx_common,
     }
-    if compiler == 'clang':
+    if compiler == "clang":
         cxxflags["guile"] += " -Wno-attributes" # -Wno-attributes is for clang LLVM 3.5 and bdw-gc < 7.5 used by guile
 
     if language not in cxxflags:
@@ -64,12 +64,12 @@
 
 import argparse
 parser = argparse.ArgumentParser(description="Display CFLAGS or CXXFLAGS to use for testing the SWIG examples and test-suite.")
-parser.add_argument('-l', '--language', required=True, help='set language to show flags for')
+parser.add_argument("-l", "--language", required=True, help="set language to show flags for")
 flags = parser.add_mutually_exclusive_group(required=True)
-flags.add_argument('-c', '--cflags', action='store_true', default=False, help='show CFLAGS')
-flags.add_argument('-x', '--cxxflags', action='store_true', default=False, help='show CXXFLAGS')
-parser.add_argument('-s', '--std', required=False, help='language standard flags for the -std= option')
-parser.add_argument('-C', '--compiler', required=False, help='compiler used (clang or gcc)')
+flags.add_argument("-c", "--cflags", action="store_true", default=False, help="show CFLAGS")
+flags.add_argument("-x", "--cxxflags", action="store_true", default=False, help="show CXXFLAGS")
+parser.add_argument("-s", "--std", required=False, help="language standard flags for the -std= option")
+parser.add_argument("-C", "--compiler", required=False, help="compiler used (clang or gcc)")
 args = parser.parse_args()
 
 if args.cflags:
diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh
index 63a11ef..393d96e 100755
--- a/Tools/travis-osx-install.sh
+++ b/Tools/travis-osx-install.sh
@@ -22,11 +22,11 @@
 	"lua")
 		travis_retry brew install lua
 		;;
+	"octave")
+		travis_retry brew install octave
+		;;
 	"python")
 		WITHLANG=$SWIGLANG$PY3
-		if [[ "$PY3" ]]; then
-			travis_retry brew upgrade python
-		fi
 		;;
 esac
 
diff --git a/appveyor.yml b/appveyor.yml
index 10bf064..42eaa36 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -89,7 +89,7 @@
 - if "%OSVARIANT%"=="" bash -c "cl.exe /? 2>&1 | head -n 1"
 - if "%OSVARIANT%"=="" bash -c "which csc.exe"
 - if "%OSVARIANT%"=="" bash -c "csc.exe /? | head -n 1"
-- if "%OSVARIANT%"=="cygwin" %CYGWINSETUP% --quiet-mode --packages python-devel,libpcre-devel,libboost-devel > cygwin-install.txt || bash -c "cat cygwin-install.txt"
+- if "%OSVARIANT%"=="cygwin" %CYGWINSETUP% --quiet-mode --packages python2-devel,libpcre-devel,libboost-devel > cygwin-install.txt || bash -c "cat cygwin-install.txt"
 - if "%OSVARIANT%"=="mingw" bash -c "pacman --noconfirm --sync mingw%MBITS%/mingw-w64-%MARCH%-pcre mingw%MBITS%/mingw-w64-%MARCH%-boost"
 - if not "%WITHLANG%"=="" set SWIGWITHLANG==%WITHLANG%
 - if not "%WITHLANG%"=="" where %WITHLANG%
diff --git a/configure.ac b/configure.ac
index 133975f..63509cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1058,23 +1058,33 @@
    AS_IF([test "x`${OCTAVE} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/Octave, version/p'`" != x],[
       AC_MSG_RESULT([yes])
    ],[
-      AC_MSG_NOTICE([no, disabling Octave])
+      AC_MSG_NOTICE([no])
       OCTAVE=
    ])
 fi
 
 # Check for required Octave helper program "mkoctfile"
 if test -n "$OCTAVE"; then
-   AC_MSG_CHECKING([for mkoctfile])
-   mkoctfile=["`echo $OCTAVE | sed -e 's|[a-z][a-z-]*$|mkoctfile|;t;s|[a-z][a-z-]*\(-[0-9][0-9.+]*\)$|mkoctfile\1|;t'`"]
-   AC_MSG_RESULT([${mkoctfile}])
-   AC_MSG_CHECKING([if ${mkoctfile} works])
-   AS_IF([test "x`${mkoctfile} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/mkoctfile, version/p'`" != x],[
+  AC_MSG_CHECKING([for mkoctfile])
+  version_suffix=["`echo $OCTAVE | sed -e 's|.*\(-[0-9][0-9.]*\)$|\1|'`"]
+  case $version_suffix in
+    -*) ;;
+    *) version_suffix="" ;;
+  esac
+  octave_directory=`dirname $OCTAVE`
+  if test "$octave_directory" = "." ; then
+    mkoctfile="mkoctfile${version_suffix}"
+  else
+    mkoctfile="${octave_directory}/mkoctfile${version_suffix}"
+  fi
+  AC_MSG_RESULT([${mkoctfile}])
+  AC_MSG_CHECKING([if ${mkoctfile} works])
+  AS_IF([test "x`${mkoctfile} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/mkoctfile, version/p'`" != x],[
       AC_MSG_RESULT([yes])
-   ],[
-      AC_MSG_NOTICE([no, disabling Octave])
+    ],[
+      AC_MSG_RESULT([no])
       OCTAVE=
-   ])
+    ])
 fi
 
 # Check for Octave preprocessor/compiler/linker flags
@@ -1114,7 +1124,10 @@
 
    AC_MSG_CHECKING([for Octave linker flags])
    OCTAVE_LDFLAGS=
-   for var in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do
+   for var in OCTLIBDIR; do
+     OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "-L`env - ${mkoctfile} -p ${var}`
+   done
+   for var in RDYNAMIC_FLAG RLD_FLAG OCTAVE_LIBS LIBS; do
      OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`env - ${mkoctfile} -p ${var}`
    done
    AC_MSG_RESULT([$OCTAVE_LDFLAGS])
@@ -2357,11 +2370,6 @@
 if test x"${GOBIN}" = xno; then
   AC_MSG_NOTICE([Disabling Go])
   GO=
-  GOC=
-  GO1=false
-  GO12=false
-  GO13=false
-  GO15=false
   GOGCC=false
   GCCGO=
   GOOPT=
@@ -2377,30 +2385,17 @@
 
   GOGCC=false
   GCCGO=
-  GO1=false
-  GO12=false
-  GO13=false
-  GO15=false
   GOOPT=
   GCCGOOPT=
   GOVERSIONOPTION=
 
   if test -n "$GO" ; then
-    GO1=true
     GOVERSIONOPTION=version
     go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //')
-    case "$go_version" in
-    go1 | go1.[[01234]] | go1.[[01234]].*)
-      GOC=$(sh -c "$(go env) && echo \$GOCHAR")c
-      ;;
-    *)
-      GOC=compile
-      ;;
-    esac
     AC_MSG_CHECKING([whether go version is too old])
     case $go_version in
-    go1.1.* | go1.1 | go1.0 | go1.0.* | go1 )
-      AC_MSG_RESULT([yes - minimum version is 1.2])
+    go1.[012]*)
+      AC_MSG_RESULT([yes - minimum version is 1.3])
       GO=
       GOOPT="-intgosize 32"
       ;;
@@ -2416,20 +2411,6 @@
       esac
       ;;
     esac
-    case $go_version in
-    go1.0 | go1.0.* | go1 | go1.1 | go1.1.*)
-      GOOPT="$GOOPT -use-shlib"
-      ;;
-    go1.2 | go1.2.*)
-      GO12=true
-      ;;
-    go1.3 | go1.3.* | go1.4 | go1.4.*)
-      GO13=true
-      ;;
-    *)
-      GO15=true
-      ;;
-    esac
   fi
 
   AC_CHECK_PROGS(GCCGO, gccgo)