diff --git a/niflib.cpp b/niflib.cpp
index a906b6d394addbe047fd851ee52d7e7af6e9cd72..4bb3a4d552f9d906cd4d6a834a4dfd8ee7a5b123 100644
--- a/niflib.cpp
+++ b/niflib.cpp
@@ -25,6 +25,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "obj/NiKeyframeData.h"
 #include "obj/NiStringExtraData.h"
 #include "obj/NiExtraData.h"
+#include "obj/bhkRigidBody.h"
 #include "gen/header.h"
 #include "gen/footer.h"
 
@@ -319,6 +320,7 @@ void WriteNifTree( ostream & out, NiObjectRef const & root, unsigned int version
 	Header header;
 	header.version = version;
 	header.userVersion = user_version;
+   header.userVersion2 = user_version;
 	
 	//Set Type Names
 	header.blockTypes.resize( types.size() );
@@ -374,9 +376,6 @@ void EnumerateObjects( NiObjectRef const & root, map<Type*,uint> & type_map, map
 		return;
 	}
 
-	//Add object to link map
-	link_map[root] = uint(link_map.size());
-
 	//Add this object type to the map if it isn't there already
 	if ( type_map.find( (Type*)&(root->GetType()) ) == type_map.end() ) {
 		//The type has not yet been registered, so register it
@@ -384,14 +383,35 @@ void EnumerateObjects( NiObjectRef const & root, map<Type*,uint> & type_map, map
 		type_map[ (Type*)&(root->GetType()) ] = uint(type_map.size());
 	}
 
-	//Call this function on all links of this object
-	
-	list<NiObjectRef> links = root->GetRefs();
-	for ( list<NiObjectRef>::iterator it = links.begin(); it != links.end(); ++it ) {
-		if ( *it != NULL ) {
-			EnumerateObjects( *it, type_map, link_map );
-		}
-	}
+   // Oblivion has very rigid requirements about block ordering and the bhkRigidBody 
+   //   must be after its children. Hopefully this can be removed and replaced with 
+   //   a more generic mechanism in the future.
+	Type *t = (Type*)&(root->GetType());
+   if (t->IsDerivedType(bhkRigidBody::TypeConst()))
+   {
+      //Call this function on all links of this object
+      list<NiObjectRef> links = root->GetRefs();
+      for ( list<NiObjectRef>::iterator it = links.begin(); it != links.end(); ++it ) {
+         if ( *it != NULL ) {
+            EnumerateObjects( *it, type_map, link_map );
+         }
+      }
+      //Add object to link map
+      link_map[root] = uint(link_map.size());
+   } 
+   else
+   {
+      //Add object to link map
+      link_map[root] = uint(link_map.size());
+
+      //Call this function on all links of this object	
+      list<NiObjectRef> links = root->GetRefs();
+      for ( list<NiObjectRef>::iterator it = links.begin(); it != links.end(); ++it ) {
+         if ( *it != NULL ) {
+            EnumerateObjects( *it, type_map, link_map );
+         }
+      }
+   }
 }
 
 //void BuildUpBindPositions( const NiAVObjectRef & root ) {
diff --git a/obj/NiAlphaProperty.cpp b/obj/NiAlphaProperty.cpp
index b8b3c7215c0a426725c8f034555c119d0a89ad4c..baec44a25f1b7ba08bf1c89a13820e2dc5735852 100644
--- a/obj/NiAlphaProperty.cpp
+++ b/obj/NiAlphaProperty.cpp
@@ -55,7 +55,7 @@ void NiAlphaProperty::SetAlphaTestThreshold( byte n ) {
    (( value >> shift ) & mask)
 
 #define NIFLIB_MASK_FLAG(flag, value, shift, mask) \
-   ((flag ^ ~(mask << shift)) | ((value & mask) << shift))
+   ((flag & ~(mask << shift)) | ((value & mask) << shift))
 
 NiAlphaProperty::BlendMode NiAlphaProperty::GetSourceBlendMode() const {
    return (NiAlphaProperty::BlendMode)NIFLIB_GET_FLAG(flags, 1, 0x0f);
diff --git a/obj/bhkNiTriStripsShape.cpp b/obj/bhkNiTriStripsShape.cpp
index 6077a69fa283c77f8040f447d623e42faf3da1d9..ac3334e012eac3798dd95a84e5f273a5776b55b9 100644
--- a/obj/bhkNiTriStripsShape.cpp
+++ b/obj/bhkNiTriStripsShape.cpp
@@ -40,6 +40,11 @@ void bhkNiTriStripsShape::SetNumStripsData(int n)
 {
 	numStripsData = n;
 	stripsData.resize(n);
+
+   // This is currently a kludge for compatibility with the max NifExporter as we dont know what this 
+   //   does but its always same number of strips and usually 1 or 4
+   numUnknownInts2 = n;
+   unknownInts2.assign(n, 1);
 }
 
 void bhkNiTriStripsShape::SetStripsData(int i, Ref<NiTriStripsData> &strips)