Index: modules/core/tools/container_templates/swig.i
===================================================================
--- modules/core/tools/container_templates/swig.i	(revision 1001)
+++ modules/core/tools/container_templates/swig.i	(working copy)
@@ -4,10 +4,10 @@
     /* this creates a memory leak.
        We need to check if the object inherits from ref counted or
        object first */
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(GroupnamesRestraint)
-    IMPCORE_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(GroupnamesScoreState)
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(MinimumGroupnameScoreRestraint)
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(MaximumGroupnameScoreRestraint)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(GroupnamesRestraint)
+    IMP_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(GroupnamesScoreState)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(MinimumGroupnameScoreRestraint)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(MaximumGroupnameScoreRestraint)
     IMPCORE_CONTAINER_SWIG(FilteredListGroupnameContainer, GroupnameContainer, groupname_container)
     IMP_SET_OBJECT(GroupnamesRestraint, set_groupname_container)
     IMP_SET_OBJECT(GroupnamesScoreState, set_before_evaluate_modifier)
Index: modules/core/pyext/core.i
===================================================================
--- modules/core/pyext/core.i	(revision 1001)
+++ modules/core/pyext/core.i	(working copy)
@@ -35,24 +35,7 @@
 IMP_ADD_OBJECTS(type, add_##lcname##s)
 %enddef
 
-/** This should go back into IMP_macros.i */
-%define IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(Ucname)
-%pythonprepend Ucname::Ucname %{
-        if len(args) >= 1 and args[0] is not None: args[0].thisown=0
-        if len(args) >= 2 and args[1] is not None: args[1].thisown=0
-%}
-%enddef
 
-/** This should go back into IMP_macros.i */
-%define IMPCORE_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(Ucname)
-%pythonprepend Ucname::Ucname %{
-        if len(args) >= 1 and args[0] is not None: args[0].thisown=0
-        if len(args) >= 2 and args[1] is not None: args[1].thisown=0
-        if len(args) >= 3 and args[2] is not None: args[2].thisown=0
-%}
-%enddef
-
-
 /* Get definitions of kernel base classes (but do not wrap) */
 %import "kernel/pyext/IMP.i"
 %import "kernel/pyext/IMP_keys.i"
@@ -95,8 +78,8 @@
     IMP_OWN_FIRST_CONSTRUCTOR(VRMLLogOptimizerState)
     IMP_CONTAINER_SWIG(VRMLLogOptimizerState,
     ParticleRefiner, particle_refiner)
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(ClosePairsScoreState)
-    IMPCORE_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(CloseBipartitePairsScoreState)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(ClosePairsScoreState)
+    IMP_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(CloseBipartitePairsScoreState)
     IMP_CONTAINER_SWIG(RestraintSet, Restraint, restraint)
     IMPCORE_CONTAINER_SWIG(MonteCarlo, Mover, mover)
 
Index: modules/core/pyext/pair_containers.i
===================================================================
--- modules/core/pyext/pair_containers.i	(revision 1001)
+++ modules/core/pyext/pair_containers.i	(working copy)
@@ -4,10 +4,10 @@
     /* this creates a memory leak.
        We need to check if the object inherits from ref counted or
        object first */
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(PairsRestraint)
-    IMPCORE_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(PairsScoreState)
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(MinimumPairScoreRestraint)
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(MaximumPairScoreRestraint)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(PairsRestraint)
+    IMP_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(PairsScoreState)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(MinimumPairScoreRestraint)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(MaximumPairScoreRestraint)
     IMPCORE_CONTAINER_SWIG(FilteredListPairContainer, PairContainer, pair_container)
     IMP_SET_OBJECT(PairsRestraint, set_pair_container)
     IMP_SET_OBJECT(PairsScoreState, set_before_evaluate_modifier)
Index: modules/core/pyext/singleton_containers.i
===================================================================
--- modules/core/pyext/singleton_containers.i	(revision 1001)
+++ modules/core/pyext/singleton_containers.i	(working copy)
@@ -4,10 +4,10 @@
     /* this creates a memory leak.
        We need to check if the object inherits from ref counted or
        object first */
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(SingletonsRestraint)
-    IMPCORE_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(SingletonsScoreState)
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(MinimumSingletonScoreRestraint)
-    IMPCORE_OWN_FIRST_SECOND_CONSTRUCTOR(MaximumSingletonScoreRestraint)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(SingletonsRestraint)
+    IMP_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(SingletonsScoreState)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(MinimumSingletonScoreRestraint)
+    IMP_OWN_FIRST_SECOND_CONSTRUCTOR(MaximumSingletonScoreRestraint)
     IMPCORE_CONTAINER_SWIG(FilteredListSingletonContainer, SingletonContainer, singleton_container)
     IMP_SET_OBJECT(SingletonsRestraint, set_singleton_container)
     IMP_SET_OBJECT(SingletonsScoreState, set_before_evaluate_modifier)
Index: kernel/pyext/IMP_macros.i
===================================================================
--- kernel/pyext/IMP_macros.i	(revision 1001)
+++ kernel/pyext/IMP_macros.i	(working copy)
@@ -10,17 +10,25 @@
 
 %define IMP_OWN_FIRST_CONSTRUCTOR(Ucname)
 %pythonprepend Ucname::Ucname %{
-        args[0].thisown=0
+        if len(args) >= 1 and args[0] is not None: args[0].thisown=0
 %}
 %enddef
 
 %define IMP_OWN_FIRST_SECOND_CONSTRUCTOR(Ucname)
 %pythonprepend Ucname::Ucname %{
-        args[0].thisown=0
-        args[1].thisown=0
+        if len(args) >= 1 and args[0] is not None: args[0].thisown=0
+        if len(args) >= 2 and args[1] is not None: args[1].thisown=0
 %}
 %enddef
 
+%define IMP_OWN_FIRST_SECOND_THIRD_CONSTRUCTOR(Ucname)
+%pythonprepend Ucname::Ucname %{
+        if len(args) >= 1 and args[0] is not None: args[0].thisown=0
+        if len(args) >= 2 and args[1] is not None: args[1].thisown=0
+        if len(args) >= 3 and args[2] is not None: args[2].thisown=0
+%}
+%enddef
+
 %define IMP_SET_OBJECT(Ucname, methodname)
 %pythonprepend Ucname::methodname %{
         args[1].thisown=0