diff --git a/swig/pyniflib.h b/swig/pyniflib.h
index 3dbd281b3c16d912a84edccc5d452de3f562cec9..4ebb00d5d7ea710e2c5ddfb018b4085b0fb5ca78 100644
--- a/swig/pyniflib.h
+++ b/swig/pyniflib.h
@@ -11,10 +11,6 @@ using namespace std;
 
 Niflib::NiNodeRef CreateNiNode() { return Niflib::NiNodeRef(new Niflib::NiNode); }
 
-// SWIG does not like ReadNifTree; so far I have no idea why.
-// As a workaround, you can use this wrapper function.
-Niflib::NiObjectRef ReadNifFile( string name, Niflib::NifInfo * nifinfo) { return Niflib::ReadNifTree(name, nifinfo);}
-
 };
 
 #endif
diff --git a/swig/pyniflib.i b/swig/pyniflib.i
index 0f7a60a3e4dd65ec09e8943033b7899a60474f9d..c9b7b2f9ac7ded2e923929417325370ef574c85f 100644
--- a/swig/pyniflib.i
+++ b/swig/pyniflib.i
@@ -355,8 +355,14 @@ POSSIBILITY OF SUCH DAMAGE. */
 
 // Headers exposed to the Python interface
 
-%include "../include/niflib.h"
+// NOTE: It is mandatory that Ref.h is included before niflib.h, and actually,
+// before any header that uses Ref types.
+// Otherwise, swig will not recognize Ref<> to be part of the Niflib namespace
+// and consequently all functions in niflib.h returning Ref<> types will not 
+// return correctly wrapped python types.
+// Briefly, it is safest to include Ref.h first.
 %include "../include/Ref.h"
+%include "../include/niflib.h"
 %include "../include/Type.h"
 %include "../include/nif_math.h"
 
diff --git a/test/niflib_test.py b/test/niflib_test.py
index 30fb606dd8e746f4c3363bf92a9a2441f7fdaa69..c0262e385b726dbaf0d0dace786ec08291681488 100644
--- a/test/niflib_test.py
+++ b/test/niflib_test.py
@@ -20,7 +20,7 @@ class TestNiNode(unittest.TestCase):
 
         # read nif file
         self.nifinfo_in = NifInfo()
-        root_obj = ReadNifFile("test.nif", self.nifinfo_in)
+        root_obj = ReadNifTree("test.nif", self.nifinfo_in)
         root_in = DynamicCastToNiNode(root_obj.Ptr())
 
         self.x_in = root_in.GetLocalTransform()