diff --git a/NIF_IO.cpp b/NIF_IO.cpp
index 4b5d22d98fe34d372b5d0af4f496b349a735184a..4088396490595f805d79196072f995730396d3f8 100644
--- a/NIF_IO.cpp
+++ b/NIF_IO.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NIF_IO.h"
+namespace NifLib {
 
 int BlockSearch( istream& in ) {
 
@@ -654,4 +655,6 @@ void NifStream( Key<Quaternion> const & key, ostream& file, uint version,  KeyTy
 		WriteFloat( key.bias, file);
 		WriteFloat( key.continuity, file);
 	}
-}
\ No newline at end of file
+}
+
+}
diff --git a/NIF_IO.h b/NIF_IO.h
index bb3ae1ee6bafb2ef3c3cd438663eb86ebe002b36..1eab830c556436585e6f399d0fd84a3e3d1f49af 100644
--- a/NIF_IO.h
+++ b/NIF_IO.h
@@ -11,6 +11,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include <sstream>
 #include <vector>
 #include "nif_math.h"
+namespace NifLib {
 using namespace std;
 
 #ifndef NULL
@@ -70,18 +71,150 @@ struct Key {
 	float continuity; /*!< The amount of continuity to use in tension, bias, continuity interpolation.  Ignored if key type is something else.*/
 };
 
-/*! Used to enable static arrays to be members of vectors */
-template<class T, int size>
-struct array {
-	T data[size];
-	T & operator[]( uint index ) {
-		return data[index];
-	}
-	T operator[]( uint index ) const {
-		return data[index];
-	}
+
+//! NVector Traits:  Class overridable alloc/release methods
+template<typename T>
+class array_Traits
+{
+public:	
+   //! Default Initialization method
+   //! @param[in] v Vector of types to initialize
+   //! @param[in] length  Length in bytes of memory to allocate
+   static void Initialize( T* v, int length )   { 
+      memset(v, 0, sizeof(v[0]) * length);
+   }
+   //! Default Finalization method
+   //! @param[in] v Vector of types to initialize
+   //! @param[in] length  Length in bytes of memory to allocate
+   static void Finalize( T* v, int length )   { 
+      memset(v, 0, sizeof(v[0]) * length);
+   }
+   //! Default Initialization method
+   //! @param[in] s Vector of types to copy from
+   //! @param[in/out] d Vector of types to copy to
+   //! @param[in] length  Length in bytes of memory to allocate
+   static void Copy(T const* s, T* d, int length )   { 
+      for (int i=0; i<length; ++i)
+         d[i] = s[i];
+   }
 };
 
+//! A fixed length vector of type T.
+//!  Data is allocated into a vector portion and the data section.
+//!  The vector simply points to appropriate places in the data section.
+//! @param  T   Type of Vector
+template<typename T, size_t len_>
+class array
+{
+   typedef typename T * RawData;
+   typedef typename T const* ConstRawData;
+public:
+   //! Default Constructor:  Allocates empty vector
+   array() {
+      array_Traits<T>::Initialize(v_, len_);
+   }
+
+   //! Copy Constructor
+   array(const array& other) {
+      array_Traits<T>::Copy(other.v_, v_, len_);
+   }
+
+   //! Copy Constructor
+   array(const RawData& other) {
+      array_Traits<T>::Copy(other, v_, len_);
+   }
+
+   //! Copy Constructor
+   array(RawData& other) {
+      array_Traits<T>::Copy(other, v_, len_);
+   }
+
+   //! Default Destructor
+   ~array() { 
+      array_Traits<T>::Finalize(v_, len_);
+   }
+
+   //! Copy Assignment
+   array& operator=(const array& other) {
+      array tmp( other );
+      swap( tmp );
+      return *this;
+   }
+
+   //! Copy Assignment
+   array& operator=(const ConstRawData& other) {
+      array tmp( other );
+      swap( tmp );
+      return *this;
+   }
+
+   T& operator[](int index) {
+      // assert( index >= 0 && index < len_ )
+      return v_[index];
+   } 
+
+   const T& operator[](int index) const {
+      // assert( index >= 0 && index < len_ )
+      return v_[index];
+   } 
+
+   T& operator[](uint index) {
+      // assert( index >= 0 && index < len_ )
+      return v_[index];
+   } 
+
+   const T& operator[](uint index) const {
+      // assert( index >= 0 && index < len_ )
+      return v_[index];
+   } 
+
+   operator T*() const {
+      return v_;
+   }
+
+   //! Number of items in the vector.
+   size_t size() const { return len_; }
+   size_t count() const { return len_; }
+
+   T* begin() { 
+      return v_; 
+   }
+
+   T* end() { 
+      return v_ + len_; 
+   }
+
+   const T* begin() const { 
+      return v_; 
+   }
+
+   const T* end() const { 
+      return v_ + len_; 
+   }
+
+   //! Assign an element to vector at specified index
+   //! @param[in]   index  Index in array to assign
+   //! @param[in]   value  Value to copy into string
+   void assign(int index, T value) {
+      v_[index] = value;
+   }
+
+   //! Reset vector back to zero size
+   void clear() {
+      array_Traits<T>::Finalize(v_, len_);
+   }
+
+   //! Swap contents with another array
+   //! @param[in,out]   other  Other vector to swap with
+   void swap( array &other ) {
+      array tmp(other);
+      array_Traits<T>::Copy(v_, other.v_, len_);
+      array_Traits<T>::Copy(tmp.v_, v_, len_);
+   }
+
+private:
+   T v_[len_]; //! Vector data
+};
 
 struct HeaderString {
 	string header;
@@ -465,4 +598,5 @@ string HexString( const byte * src, uint len );
 //Byte
 ostream & operator<<( ostream & out, byte const & val );
 
+}
 #endif
diff --git a/Ref.h b/Ref.h
index b6090912bf7bec3d1726874689b3fe5dd12010a7..369f48dc03bd1531481d72d7edecd38e2b795bd4 100644
--- a/Ref.h
+++ b/Ref.h
@@ -3,171 +3,171 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #ifndef _REF_H_
 #define _REF_H_
+#include <ostream>
+#include "dll_export.h"
+namespace NifLib {
 
 /**
  * Smart Pointer Template
  */
 
 template<class T> class Ref;
-template<class T> ostream & operator<<(ostream &, const Ref<T> &);
+template<class T> std::ostream & operator<<(std::ostream &, const Ref<T> &);
 
-template <class T> class Ref {
+
+/**
+* Ref Traits:  Class overridable behavior methods
+*/
+template<typename T>
+class RefTraits
+{
+public:	
+   static void AddRef( T* p )   { if (p) p->AddRef(); }
+   static void Release( T* p )  { if (p) p->SubtractRef(); }
+   static bool Less( T*l, T*r ) { return ( l < r ); }
+   static ::std::ostream & ToStream(::std::ostream &os, T* p) { 
+      if (p) os << p->GetIDString();
+      else   os << "NULL";
+      return os; 
+   }
+#ifdef USE_NIFLIB_TEMPLATE_HELPERS
+   template<typename U> static T* StaticCast(U* p) { return static_cast<T*>(p); }
+   template<typename U> static T* DynamicCast(U* p) {
+      if ( (NULL != p) && p->IsDerivedType(T::TypeConst()) ) {
+         return static_cast<T*>(p);
+      } else {
+         return NULL;
+      }
+   }
+#endif
+};
+
+
+/**
+* Smart reference
+*/
+template<class T>
+class Ref
+{
 public:
-	Ref( T * object = NULL );
-	Ref(const Ref & ref_to_copy );
-	~Ref();
+   Ref( T* p = 0 ) 
+      : p_( ShallowCopy( p ) )
+   {
+   }	
+
+   ~Ref() { Release( ); }
+
+   Ref& Attach( T* p = 0 )
+   {
+      Reset();
+      p_ = p;
+      return (*this);
+   }
 
-	operator T*() const;
-	T& operator*() const;
-	T* operator->() const;
-	T* Ptr() const;
+   // Normally I'd disable this and force you to use safe/explicit conversions
+   operator T*() const { return p_; }
 
-	Ref & operator=( T * object );
-	Ref & operator=( const Ref & ref );
+   T& operator*() const { return *p_; }
 
-	bool operator<(const Ref & ref) const;
+   T* operator->() const { return p_; }
 
-	bool operator==(T * object) const;
-	bool operator!=(T * object) const;
-	bool operator==(const Ref & ref) const;
-	bool operator!=(const Ref & ref) const;
+   T* ToPointer() const { return p_; }
 
-        friend ostream & operator<< <T>(ostream & os, const Ref & ref);
-protected:
-	//The shared object
-	T* _object;
-};
+   void Swap( Ref& other ) { std::swap( p_, other.p_); }
 
-template <class T>
-Ref<T>::Ref( T * object ) : _object(object) {
-   //If object isn't null, increment reference count
-   if ( _object != NULL ) {
-      _object->AddRef();
-   }
-}
+   bool isEmpty() const
+   { return (p_ == 0); }
 
-template <class T>
-Ref<T>::Ref(const Ref & ref_to_copy ) {
-	_object = ref_to_copy._object;
-	//If object isn't null, increment reference count
-	if ( _object != NULL ) {
-		_object->AddRef();
-	}
-}
+   bool isSet() const
+   { return (p_ != 0); }
 
-template <class T>
-Ref<T>::~Ref() {
-	//if object insn't null, decrement reference count
-	if ( _object != NULL ) {
-		_object->SubtractRef();
-	}
-}
+   /**
+   * overload all potential null test comparison operators
+   */
+   operator bool() const // Enables "if (sp) ..."
+   { return (p_ != 0); }
 
-template <class T>
-Ref<T>::operator T*() const {
-	return _object;
-}
+   bool operator!() const // Enables "if (!sp) ..."
+   { return (p_ == 0); }
 
-template <class T>
-T& Ref<T>::operator*() const {
-	return *_object;
-}
+   inline friend bool operator==(const Ref& lhs, const Ref& rhs)
+   { return (lhs.p_ == rhs.p_); }
 
-template <class T>
-T* Ref<T>::operator->() const {
-	return _object;
-}
+   inline friend bool operator!=(const Ref& lhs, const Ref& rhs)
+   { return (lhs.p_ != rhs.p_); }
 
-template <class T>
-T* Ref<T>::Ptr() const {
-	return _object;
-}
+   inline friend bool operator==(const Ref& lhs, const T* rhs)
+   { return (lhs.p_ == rhs); }
 
-template <class T>
-Ref<T> & Ref<T>::operator=( T * object ) {
-	//Check if referenced objects are already the same
-	if ( _object == object ) {
-		return *this; //Do nothing
-	}
+   inline friend bool operator==(const T* lhs, const Ref& rhs)
+   { return (lhs == rhs.p_); }
 
-	//Decriment reference count on previously referenced object, if any
-	if ( _object != NULL ) {
-		_object->SubtractRef();
-	}
+   inline friend bool operator==(const Ref& lhs, intptr_t rhs)
+   { return (lhs.p_ == reinterpret_cast<T*>(rhs)); }
 
-	//Change reference to new object
-	_object = object;
+   inline friend bool operator==(intptr_t rhs, const Ref& lhs)
+   { return (reinterpret_cast<T*>(lhs) == rhs.p_); }
 
-	//Increment reference count on new object if it is not NULL
-	if ( _object != NULL ) {
-		_object->AddRef();
-	}
+   inline friend bool operator!=(const Ref& lhs, const T* rhs)
+   { return (lhs.p_ != rhs); }
 
-	return *this;
-}
+   inline friend bool operator!=(const T* lhs, const Ref& rhs)
+   { return (lhs != rhs.p_); }
 
-template <class T>
-Ref<T> & Ref<T>::operator=( const Ref & ref ) {
-	//Check if referenced objects are already the same
-	if ( _object == ref._object ) {
-		return *this; //Do nothing
-	}
+   inline friend bool operator!=(const Ref& lhs, intptr_t rhs)
+   { return (lhs.p_ != reinterpret_cast<T*>(rhs)); }
 
-	//Decriment reference count on previously referenced object, if any
-	if ( _object != NULL ) {
-		_object->SubtractRef();
-	}
+   inline friend bool operator!=(intptr_t rhs, const Ref& lhs)
+   { return (reinterpret_cast<T*>(lhs) != rhs.p_); }
 
-	//Change reference to new object
-	_object = ref._object;
+   inline friend bool operator<(const Ref& lhs, const Ref& rhs)
+   { return RefTraits<T>::Less(lhs.p_, rhs.p_); }
 
-	//Increment reference count on new object if it is not NULL
-	if ( _object != NULL ) {
-		_object->AddRef();
-	}
+   inline friend std::ostream & operator<<(std::ostream &os, const Ref& rhs)
+   { return RefTraits<T>::ToStream(os, rhs.p_); }
 
-	return *this;
-}
+   Ref( const Ref& other )
+      : p_( ShallowCopy( other.p_ ) )
+   { }
 
-//Template functions must be in the header file
+#ifdef USE_NIFLIB_TEMPLATE_HELPERS
+   template<typename U>
+   Ref( const Ref<U>& other ) 
+      : p_( ShallowCopy(RefTraits<T>::DynamicCast(other.p_)) )
+   { }
+#endif
 
-template <class T>
-bool Ref<T>::operator<(const Ref & ref) const {
-	return (_object < ref._object);
-}
+   Ref& operator=( T * other )
+   {
+      Ref temp(other);
+      Swap(temp);
+      return *this;
+   }
 
-template <class T>
-bool Ref<T>::operator==(T * object) const {
-	//Compare pointer values of referenced objects
-	return ( _object == object );
-}
+   Ref& operator=( const Ref& other )
+   {
+      Ref temp(other);
+      Swap(temp);
+      return *this;
+   }
 
-template <class T>
-bool Ref<T>::operator!=(T * object) const {
-	//Compare pointer values of referenced objects
-	return ( _object != object );
-}
+private:
+   template<typename U> friend class Ref;
 
-template <class T>
-bool Ref<T>::operator==(const Ref & ref) const {
-	//Compare pointer values of referenced objects
-	return ( _object == ref._object );
-}
+   T* ShallowCopy( T* p ) 
+   {
+      RefTraits<T>::AddRef( p );
+      return p;
+   }
 
-template <class T>
-bool Ref<T>::operator!=(const Ref & ref) const {
-	//Compare pointer values of referenced objects
-	return ( _object != ref._object );
-}
+   void Release( )
+   {
+      RefTraits<T>::Release( p_ );
+      p_ = 0;
+   }
 
+   T* p_;
+};
 
-template <class T>
-ostream & operator<<(ostream & os, const Ref<T> & ref) {
-	if (ref._object)
-		os << ref->GetIDString();
-	else
-		os << "NULL";
-	return os;
 }
-
 #endif
diff --git a/Type.cpp b/Type.cpp
index 4545a6eacd42e655f3eb6c70bd19f35df36faed2..2124249af757caaae50c49abc44958280db22fe6 100644
--- a/Type.cpp
+++ b/Type.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "Type.h"
+using namespace NifLib;
 
 Type::Type (const string & type_name, const Type * par_type ) : name(type_name), base_type(par_type) {} 
 
@@ -29,4 +30,4 @@ bool Type::IsDerivedType( const Type & compare_to ) const {
 
 string Type::GetTypeName() const {
 	return name;
-}
+}
\ No newline at end of file
diff --git a/Type.h b/Type.h
index 2902cc72dac483aae5063262538ea6cc9cbbce8e..f473438253f633e2c46e6e6ea03feda63aba4046 100644
--- a/Type.h
+++ b/Type.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "dll_export.h"
 
 using namespace std;
+namespace NifLib {
 
 /**
  * Run Time Type Inforamtion Class
@@ -27,4 +28,5 @@ private:
 	const Type * base_type;
 };
 
+}
 #endif
diff --git a/gen/AVObject.cpp b/gen/AVObject.cpp
index c0fc28e03e9c1b1b27bc0befc28cd64a8ef7bb9d..06eae544a88798b0b25e2fc7bb1490558ce0cdcc 100644
--- a/gen/AVObject.cpp
+++ b/gen/AVObject.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "AVObject.h"
 #include "../obj/NiAVObject.h"
+using namespace NifLib;
 
 //Constructor
 AVObject::AVObject() : object(NULL) {};
diff --git a/gen/AVObject.h b/gen/AVObject.h
index 08231cdc0c97d18d06890a617b761f943171a48f..dffed0354a1d3187bb59392a268b251b44c94a3f 100644
--- a/gen/AVObject.h
+++ b/gen/AVObject.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 // Forward define of referenced blocks
 class NiAVObject;
 
@@ -27,4 +29,5 @@ struct NIFLIB_API AVObject {
 	NiAVObject * object;
 };
 
+}
 #endif
diff --git a/gen/BoundingBox.cpp b/gen/BoundingBox.cpp
index b3608db77fb6b75d18053ce2fab441027e7b5166..96545cd149b88436c1f7cba834bf4b756fa5ea45 100644
--- a/gen/BoundingBox.cpp
+++ b/gen/BoundingBox.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "BoundingBox.h"
+using namespace NifLib;
 
 //Constructor
 BoundingBox::BoundingBox() : unknownInt((uint)1) {};
diff --git a/gen/BoundingBox.h b/gen/BoundingBox.h
index 697c7465a1fcf6119963ef17aef07692de7686b6..d50f3cdfd468baa1ab25b1e53c2d67cd8d4761df 100644
--- a/gen/BoundingBox.h
+++ b/gen/BoundingBox.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Bounding box.
@@ -33,4 +35,5 @@ struct NIFLIB_API BoundingBox {
 	Vector3 radius;
 };
 
+}
 #endif
diff --git a/gen/ByteArray.cpp b/gen/ByteArray.cpp
index 8b1dc522344099877bcf50f07420d014f7824c17..abb07411da02560d4b7dbe55fc623ba13266653b 100644
--- a/gen/ByteArray.cpp
+++ b/gen/ByteArray.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "ByteArray.h"
+using namespace NifLib;
 
 //Constructor
 ByteArray::ByteArray() : dataSize((uint)0) {};
diff --git a/gen/ByteArray.h b/gen/ByteArray.h
index 173ec6925a9302fc6e6b49fa9f596c74f2735dca..79cb83de4625fb814d4b92401e508f8185564942 100644
--- a/gen/ByteArray.h
+++ b/gen/ByteArray.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * An array of bytes.
@@ -18,11 +20,12 @@ struct NIFLIB_API ByteArray {
 	/*!
 	 * The number of bytes in this array
 	 */
-	uint dataSize;
+	mutable uint dataSize;
 	/*!
 	 * The bytes which make up the array
 	 */
 	vector<byte > data;
 };
 
+}
 #endif
diff --git a/gen/ControllerLink.cpp b/gen/ControllerLink.cpp
index 9c2fa65d8a91d038079085f426c8b6aff9124c9b..805b1c909b1351a2b970eb3f7bb4f7bf14ff754d 100644
--- a/gen/ControllerLink.cpp
+++ b/gen/ControllerLink.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../obj/NiInterpolator.h"
 #include "../obj/NiObject.h"
 #include "../obj/NiStringPalette.h"
+using namespace NifLib;
 
 //Constructor
 ControllerLink::ControllerLink() : interpolator(NULL), unknownLink1(NULL), unknownLink2(NULL), unknownShort0((ushort)0), priority_((byte)0), stringPalette(NULL), nodeNameOffset((uint)0), propertyTypeOffset((uint)0), controllerTypeOffset((uint)0), variableOffset1((uint)0), variableOffset2((uint)0) {};
diff --git a/gen/ControllerLink.h b/gen/ControllerLink.h
index ce949b5dad54dc9c76e752684145a612de230749..c34d015d47defdaf8ee2e39bc2a4459a6098f630 100644
--- a/gen/ControllerLink.h
+++ b/gen/ControllerLink.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
 class NiInterpolator;
@@ -113,4 +114,5 @@ struct NIFLIB_API ControllerLink {
 	uint variableOffset2;
 };
 
+}
 #endif
diff --git a/gen/Footer.cpp b/gen/Footer.cpp
index 041e9c19aca602d6f6f3babc268549cc379d41b5..9082395c087788b30c3496efedfd98c8f64d3aba 100644
--- a/gen/Footer.cpp
+++ b/gen/Footer.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "Footer.h"
 #include "../obj/NiAVObject.h"
+using namespace NifLib;
 
 //Constructor
 Footer::Footer() : numRoots((uint)0) {};
@@ -21,6 +22,7 @@ void Footer::Read( istream& in, list<uint> & link_stack, unsigned int version, u
 }
 
 void Footer::Write( ostream& out, map<NiObjectRef,uint> link_map, unsigned int version, unsigned int user_version ) const {
+	numRoots = uint(roots.size());
 	NifStream( numRoots, out, version );
 	for (uint i1 = 0; i1 < roots.size(); i1++) {
 		if ( roots[i1] != NULL )
@@ -32,6 +34,7 @@ void Footer::Write( ostream& out, map<NiObjectRef,uint> link_map, unsigned int v
 
 string Footer::asString( bool verbose ) const {
 	stringstream out;
+	numRoots = uint(roots.size());
 	out << "  Num Roots:  " << numRoots << endl;
 	for (uint i1 = 0; i1 < roots.size(); i1++) {
 		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) {
diff --git a/gen/Footer.h b/gen/Footer.h
index 0537e040b1a80bbc8766aa699f6af733c3b75959..66c1d8244ae89f0dd4b138b5d788852dfb5858ef 100644
--- a/gen/Footer.h
+++ b/gen/Footer.h
@@ -5,13 +5,14 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _FOOTER_H_
 
 #include "../NIF_IO.h"
+#include "../obj/NiObject.h"
 
 // Include structures
 #include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
 class NiAVObject;
-#include "../obj/NiObject.h"
 
 /*!
  * The NIF file footer.
@@ -24,7 +25,7 @@ struct NIFLIB_API Footer {
 	/*!
 	 * The number of root references.
 	 */
-	uint numRoots;
+	mutable uint numRoots;
 	/*!
 	 * List of root blocks. If there is a camera, for 1st person view, then
 	 * this block is referred to as well in this list, even if it is not a
@@ -37,4 +38,5 @@ struct NIFLIB_API Footer {
 	string asString( bool verbose = false ) const;
 };
 
+}
 #endif
diff --git a/gen/FurniturePosition.cpp b/gen/FurniturePosition.cpp
index 702464e380ae002ae81549554a4b871b9acd38a4..356e5bc7c6c671511a9ba49787fb0b680fcfca61 100644
--- a/gen/FurniturePosition.cpp
+++ b/gen/FurniturePosition.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "FurniturePosition.h"
+using namespace NifLib;
 
 //Constructor
 FurniturePosition::FurniturePosition() : orientation((ushort)0), positionRef1((byte)0), positionRef2((byte)0) {};
diff --git a/gen/FurniturePosition.h b/gen/FurniturePosition.h
index d70ea88db4ebd176ac3e6b6c47c085972cfb5c38..10d9c6f8698f39742ef1fe5e2de869a006264f2f 100644
--- a/gen/FurniturePosition.h
+++ b/gen/FurniturePosition.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Describes a furniture position?
@@ -35,4 +37,5 @@ struct NIFLIB_API FurniturePosition {
 	byte positionRef2;
 };
 
+}
 #endif
diff --git a/gen/Header.cpp b/gen/Header.cpp
index 2362ff7fb3e8f5bf316b3bc0ed0a919ba9c748cf..0ff4ed5af0e3e3756688d5031ae8419ad0fca8eb 100644
--- a/gen/Header.cpp
+++ b/gen/Header.cpp
@@ -5,13 +5,13 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "ShortString.h"
 #include "ShortString.h"
 #include "ShortString.h"
+using namespace NifLib;
 
 //Constructor
 Header::Header() : version((uint)0x04000002), endianType((byte)1), userVersion((uint)0), numBlocks((uint)0), unknownInt1((uint)0), unknownInt3((uint)0), numBlockTypes((ushort)0), unknownInt2((uint)0) {};
 
 //Destructor
 Header::~Header() {};
-
 void Header::Read( istream& in ) {
 	NifStream( headerString, in, version );
 	NifStream( version, in, version );
@@ -64,6 +64,8 @@ void Header::Read( istream& in ) {
 }
 
 void Header::Write( ostream& out ) const {
+	numBlockTypes = ushort(blockTypes.size());
+	numBlocks = uint(blockTypeIndex.size());
 	NifStream( headerString, out, version );
 	NifStream( version, out, version );
 	if ( version >= 0x14000004 ) {
@@ -83,14 +85,17 @@ void Header::Write( ostream& out ) const {
 	};
 	if ( version >= 0x0A000102 ) {
 		if ( (userVersion != 0) ) {
+			creator_.length = byte(creator_.value.size());
 			NifStream( creator_.length, out, version );
 			for (uint i3 = 0; i3 < creator_.value.size(); i3++) {
 				NifStream( creator_.value[i3], out, version );
 			};
+			exportType_.length = byte(exportType_.value.size());
 			NifStream( exportType_.length, out, version );
 			for (uint i3 = 0; i3 < exportType_.value.size(); i3++) {
 				NifStream( exportType_.value[i3], out, version );
 			};
+			exportScript_.length = byte(exportScript_.value.size());
 			NifStream( exportScript_.length, out, version );
 			for (uint i3 = 0; i3 < exportScript_.value.size(); i3++) {
 				NifStream( exportScript_.value[i3], out, version );
@@ -111,6 +116,8 @@ void Header::Write( ostream& out ) const {
 
 string Header::asString( bool verbose ) const {
 	stringstream out;
+	numBlockTypes = ushort(blockTypes.size());
+	numBlocks = uint(blockTypeIndex.size());
 	out << "  Header String:  " << headerString << endl;
 	out << "  Version:  " << version << endl;
 	out << "  Endian Type:  " << endianType << endl;
@@ -119,6 +126,7 @@ string Header::asString( bool verbose ) const {
 	out << "  Unknown Int 1:  " << unknownInt1 << endl;
 	if ( (userVersion != 0) ) {
 		out << "    Unknown Int 3:  " << unknownInt3 << endl;
+		creator_.length = byte(creator_.value.size());
 		out << "    Length:  " << creator_.length << endl;
 		for (uint i2 = 0; i2 < creator_.value.size(); i2++) {
 			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) {
@@ -127,6 +135,7 @@ string Header::asString( bool verbose ) const {
 			};
 			out << "      Value[" << i2 << "]:  " << creator_.value[i2] << endl;
 		};
+		exportType_.length = byte(exportType_.value.size());
 		out << "    Length:  " << exportType_.length << endl;
 		for (uint i2 = 0; i2 < exportType_.value.size(); i2++) {
 			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) {
@@ -135,6 +144,7 @@ string Header::asString( bool verbose ) const {
 			};
 			out << "      Value[" << i2 << "]:  " << exportType_.value[i2] << endl;
 		};
+		exportScript_.length = byte(exportScript_.value.size());
 		out << "    Length:  " << exportScript_.length << endl;
 		for (uint i2 = 0; i2 < exportScript_.value.size(); i2++) {
 			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) {
diff --git a/gen/Header.h b/gen/Header.h
index 478edf28b04765cae433b6e17d7cde2f9372cdb6..3811853d2a5b16f8d549ea8b4c1a8651297eb701 100644
--- a/gen/Header.h
+++ b/gen/Header.h
@@ -5,10 +5,12 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _HEADER_H_
 
 #include "../NIF_IO.h"
+#include "../obj/NiObject.h"
 
 // Include structures
 #include "ShortString.h"
-#include "../obj/NiObject.h"
+namespace NifLib {
+
 
 /*!
  * The NIF file header.
@@ -43,7 +45,7 @@ struct NIFLIB_API Header {
 	/*!
 	 * Number of file blocks.
 	 */
-	uint numBlocks;
+	mutable uint numBlocks;
 	/*!
 	 * Unknown.
 	 */
@@ -68,7 +70,7 @@ struct NIFLIB_API Header {
 	/*!
 	 * Number of block types in this NIF file.
 	 */
-	ushort numBlockTypes;
+	mutable ushort numBlockTypes;
 	/*!
 	 * List of all block types used in this NIF file.
 	 */
@@ -88,4 +90,5 @@ struct NIFLIB_API Header {
 	string asString( bool verbose = false ) const;
 };
 
+}
 #endif
diff --git a/gen/KeyGroup.h b/gen/KeyGroup.h
index e1f9cfa972790315a21aec5bc43c47c78f27a235..6d32ecde2581eb802c1b5a9f535f0379003a0d7d 100644
--- a/gen/KeyGroup.h
+++ b/gen/KeyGroup.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Array of vector keys (anything that can be interpolated, except
@@ -16,7 +18,7 @@ struct NIFLIB_API KeyGroup {
 	/*!
 	 * Number of keys in the array.
 	 */
-	uint numKeys;
+	mutable uint numKeys;
 	/*!
 	 * The key type.
 	 */
@@ -27,4 +29,5 @@ struct NIFLIB_API KeyGroup {
 	vector<Key<T > > keys;
 };
 
+}
 #endif
diff --git a/gen/LODRange.cpp b/gen/LODRange.cpp
index 2e6d9101f00364201c1f8213a2551c6a75767ef9..c3b3b69547ccbfac4cb84c5a581fb6f3fedc251e 100644
--- a/gen/LODRange.cpp
+++ b/gen/LODRange.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "LODRange.h"
+using namespace NifLib;
 
 //Constructor
 LODRange::LODRange() : near(0.0f), far(0.0f) {};
diff --git a/gen/LODRange.h b/gen/LODRange.h
index caf580d72fcd4e0ba9e9aa1a9a7b6b04a45cb021..678ccf7bf4c16311dd87fbac0a97c6523dc7771e 100644
--- a/gen/LODRange.h
+++ b/gen/LODRange.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * The distance range where a specific level of detail applies.
@@ -25,4 +27,5 @@ struct NIFLIB_API LODRange {
 	float far;
 };
 
+}
 #endif
diff --git a/gen/LimitedHingeDescriptor.cpp b/gen/LimitedHingeDescriptor.cpp
index 0f3bf91a3eb7436ba4d37f41199a94f37e190c4b..9c42628f387ba4c7a6267e89a13629d8e8c16718 100644
--- a/gen/LimitedHingeDescriptor.cpp
+++ b/gen/LimitedHingeDescriptor.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "LimitedHingeDescriptor.h"
+using namespace NifLib;
 
 //Constructor
 LimitedHingeDescriptor::LimitedHingeDescriptor() : minAngle(0.0f), maxAngle(0.0f), maxFriction(0.0f) {};
diff --git a/gen/LimitedHingeDescriptor.h b/gen/LimitedHingeDescriptor.h
index 0e24fd01d1069c57f1b3ee391b26bb475c78fe08..1302f8aa05fbaee3c84f706f1301aac79519dbf8 100644
--- a/gen/LimitedHingeDescriptor.h
+++ b/gen/LimitedHingeDescriptor.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * 
@@ -57,4 +59,5 @@ struct NIFLIB_API LimitedHingeDescriptor {
 	float maxFriction;
 };
 
+}
 #endif
diff --git a/gen/MatchGroup.cpp b/gen/MatchGroup.cpp
index 58b46937723cb9e855db86790632dce6d0a53d4b..d6d46bb96daa2e370e0b981c6182ae33a4674f45 100644
--- a/gen/MatchGroup.cpp
+++ b/gen/MatchGroup.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "MatchGroup.h"
+using namespace NifLib;
 
 //Constructor
 MatchGroup::MatchGroup() : numVertices((ushort)0) {};
diff --git a/gen/MatchGroup.h b/gen/MatchGroup.h
index 88a156af062ff95c37e01f5be606083bb64dd79a..5564c30eb8985b7ea8641d9de178b52704770d76 100644
--- a/gen/MatchGroup.h
+++ b/gen/MatchGroup.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Group of vertex indices of vertices that match.
@@ -18,11 +20,12 @@ struct NIFLIB_API MatchGroup {
 	/*!
 	 * Number of vertices in this group.
 	 */
-	ushort numVertices;
+	mutable ushort numVertices;
 	/*!
 	 * The vertex indices.
 	 */
 	vector<ushort > vertexIndices;
 };
 
+}
 #endif
diff --git a/gen/MipMap.cpp b/gen/MipMap.cpp
index cd673a5669f9e41c91e0385a41ac0798d3fc1639..d028fa89083f3055b492a3d017bc16c19ebd26fb 100644
--- a/gen/MipMap.cpp
+++ b/gen/MipMap.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "MipMap.h"
+using namespace NifLib;
 
 //Constructor
 MipMap::MipMap() : width((uint)0), height((uint)0), offset((uint)0) {};
diff --git a/gen/MipMap.h b/gen/MipMap.h
index 067cd6bcb3e9bab8ba1a55413d6d1a5ddfedf572..3076bb8e8fce9db2c8742a2f48d227f4ea5a05d9 100644
--- a/gen/MipMap.h
+++ b/gen/MipMap.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Description of a MipMap within a NiPixelData block.
@@ -29,4 +31,5 @@ struct NIFLIB_API MipMap {
 	uint offset;
 };
 
+}
 #endif
diff --git a/gen/Morph.cpp b/gen/Morph.cpp
index ef314ed6a70e286b4a159494def7d0f5077d49ed..ffd64610ed4e8fdef7a1b8e77b7fe8f4d5088800 100644
--- a/gen/Morph.cpp
+++ b/gen/Morph.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "Morph.h"
+using namespace NifLib;
 
 //Constructor
 Morph::Morph() : numMorphKeys((uint)0), morphInterpolation((KeyType)0), unknownInt((uint)0) {};
diff --git a/gen/Morph.h b/gen/Morph.h
index 2ab605323bc599400811df5fcfb72048586a8100..7b024dcd1900e84054ee204c72aac08029b7fe1e 100644
--- a/gen/Morph.h
+++ b/gen/Morph.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Geometry morphing data component.
@@ -22,7 +24,7 @@ struct NIFLIB_API Morph {
 	/*!
 	 * The number of morph keys that follow.
 	 */
-	uint numMorphKeys;
+	mutable uint numMorphKeys;
 	/*!
 	 * Unlike most blocks, the presense of this value is not conditional on
 	 * there being keys.
@@ -42,4 +44,5 @@ struct NIFLIB_API Morph {
 	vector<Vector3 > vectors;
 };
 
+}
 #endif
diff --git a/gen/NodeGroup.cpp b/gen/NodeGroup.cpp
index 699d6d6bb0558d1ed5b649371be7285959f1652b..13f75fa4ec2651d6d74fbc325d0cb45e71476ec7 100644
--- a/gen/NodeGroup.cpp
+++ b/gen/NodeGroup.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NodeGroup.h"
 #include "../obj/NiNode.h"
+using namespace NifLib;
 
 //Constructor
 NodeGroup::NodeGroup() : numNodes((uint)0) {};
diff --git a/gen/NodeGroup.h b/gen/NodeGroup.h
index 12354302ab36c1255fc974c9a9098f0ef17212fd..c001ca36ac6a43cb68a101c483ef8b93f1eaddcb 100644
--- a/gen/NodeGroup.h
+++ b/gen/NodeGroup.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
 class NiNode;
@@ -23,11 +24,12 @@ struct NIFLIB_API NodeGroup {
 	/*!
 	 * Number of node references that follow.
 	 */
-	uint numNodes;
+	mutable uint numNodes;
 	/*!
 	 * The list of NiNode references.
 	 */
 	vector<Ref<NiNode > > nodes;
 };
 
+}
 #endif
diff --git a/gen/Particle.cpp b/gen/Particle.cpp
index 5ba5c4579f28245733d43d21dcfacf04ff080259..74f4e7998c26236df1ad3e2f1ce866a4ebe513f4 100644
--- a/gen/Particle.cpp
+++ b/gen/Particle.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "Particle.h"
+using namespace NifLib;
 
 //Constructor
 Particle::Particle() : lifetime(0.0f), lifespan(0.0f), timestamp(0.0f), unknownShort((ushort)0), vertexId((ushort)0) {};
diff --git a/gen/Particle.h b/gen/Particle.h
index e44c2e742a0402b9268914bcc5ea4f0b6e651114..f17e0b9f0a084de950d012eeb385ff6051b2b7df 100644
--- a/gen/Particle.h
+++ b/gen/Particle.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * particle array entry
@@ -45,4 +47,5 @@ struct NIFLIB_API Particle {
 	ushort vertexId;
 };
 
+}
 #endif
diff --git a/gen/QuaternionXYZW.cpp b/gen/QuaternionXYZW.cpp
index 36b23acb780c9a6b500075603279d3e768ea19a5..aa3c6f9ff92da7388e97fabda4cfdc66148ddb90 100644
--- a/gen/QuaternionXYZW.cpp
+++ b/gen/QuaternionXYZW.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "QuaternionXYZW.h"
+using namespace NifLib;
 
 //Constructor
 QuaternionXYZW::QuaternionXYZW() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {};
diff --git a/gen/QuaternionXYZW.h b/gen/QuaternionXYZW.h
index 55684223856ab116f1656337a0281055878af17b..85a25daa06bc505d663392b1c99b8e78cd4ddced 100644
--- a/gen/QuaternionXYZW.h
+++ b/gen/QuaternionXYZW.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * A quaternion as it appears in the havok blocks.
@@ -33,4 +35,5 @@ struct NIFLIB_API QuaternionXYZW {
 	float w;
 };
 
+}
 #endif
diff --git a/gen/RagDollDescriptor.cpp b/gen/RagDollDescriptor.cpp
index caa89a77bf0f34a32a993294c161bd9509ada687..67d101636f842652ae5c48c5ad2ec5331c4706d3 100644
--- a/gen/RagDollDescriptor.cpp
+++ b/gen/RagDollDescriptor.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "RagDollDescriptor.h"
+using namespace NifLib;
 
 //Constructor
 RagDollDescriptor::RagDollDescriptor() : coneMinAngle(0.0f), planeMinAngle(0.0f), planeMaxAngle(0.0f), twistMinAngle(0.0f), twistMaxAngle(0.0f), maxFriction(0.0f) {};
diff --git a/gen/RagDollDescriptor.h b/gen/RagDollDescriptor.h
index 9e83ec5bc8005d9dcc95acdf7f4d69170cc57b34..829bd3aa825dfa6b598ea636da4f341439894f97 100644
--- a/gen/RagDollDescriptor.h
+++ b/gen/RagDollDescriptor.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * 
@@ -65,4 +67,5 @@ struct NIFLIB_API RagDollDescriptor {
 	float maxFriction;
 };
 
+}
 #endif
diff --git a/gen/RotationKeyArray.h b/gen/RotationKeyArray.h
index c07c0269850da22d112aafc6ed0be78826e8ddd5..7ca915ef309145f39aa16b454f3bca522080517b 100644
--- a/gen/RotationKeyArray.h
+++ b/gen/RotationKeyArray.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Rotation key array.
@@ -15,7 +17,7 @@ struct NIFLIB_API RotationKeyArray {
 	/*!
 	 * Number of keys.
 	 */
-	uint numKeys;
+	mutable uint numKeys;
 	/*!
 	 * Key type (1, 2, 3, or 4).
 	 */
@@ -26,4 +28,5 @@ struct NIFLIB_API RotationKeyArray {
 	vector<Key<T > > keys;
 };
 
+}
 #endif
diff --git a/gen/ShaderTexDesc.cpp b/gen/ShaderTexDesc.cpp
index 32c5a37acc5fba7025afd55e5f6c0965d4576e61..213c583ae9603633a0dee13a1cf9f86620dc3420 100644
--- a/gen/ShaderTexDesc.cpp
+++ b/gen/ShaderTexDesc.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "ShaderTexDesc.h"
 #include "TexDesc.h"
 #include "../obj/NiSourceTexture.h"
+using namespace NifLib;
 
 //Constructor
 ShaderTexDesc::ShaderTexDesc() : isUsed(false), unknownInt((uint)0) {};
diff --git a/gen/ShaderTexDesc.h b/gen/ShaderTexDesc.h
index 4b7388184fd7addd17ae3e838393af805b037467..ff9ac0a896826c548c755e5643d43b79dbc0a0cc 100644
--- a/gen/ShaderTexDesc.h
+++ b/gen/ShaderTexDesc.h
@@ -8,6 +8,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "TexDesc.h"
+namespace NifLib {
+
 
 /*!
  * An extended texture description for shader textures.
@@ -31,4 +33,5 @@ struct NIFLIB_API ShaderTexDesc {
 	uint unknownInt;
 };
 
+}
 #endif
diff --git a/gen/ShortString.cpp b/gen/ShortString.cpp
index 79d345964d9ce9fb44d1b2d8cac0b62019e14a10..d0370af2407b35d4d35a20b19ad1420055398576 100644
--- a/gen/ShortString.cpp
+++ b/gen/ShortString.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "ShortString.h"
+using namespace NifLib;
 
 //Constructor
 ShortString::ShortString() : length((byte)0) {};
diff --git a/gen/ShortString.h b/gen/ShortString.h
index 66f9502528fea7ae8263cad39c3941145d8aaa7a..107b9e34d23614ab1e2ccbe197fb9d4416ff34f0 100644
--- a/gen/ShortString.h
+++ b/gen/ShortString.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Another string format, for short strings.  Specific to Bethesda-
@@ -19,7 +21,7 @@ struct NIFLIB_API ShortString {
 	/*!
 	 * The string length.
 	 */
-	byte length;
+	mutable byte length;
 	/*!
 	 * The string itself, null terminated (the null terminator is taken into
 	 * account in the length byte).
@@ -27,4 +29,5 @@ struct NIFLIB_API ShortString {
 	vector<byte > value;
 };
 
+}
 #endif
diff --git a/gen/SkinData.cpp b/gen/SkinData.cpp
index d9e9d17d6d43894429e522acbd5c4c8811ad9c0f..ae0368ad06953a3d0ef799c79c85d4b25a8b3f04 100644
--- a/gen/SkinData.cpp
+++ b/gen/SkinData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "SkinData.h"
 #include "SkinWeight.h"
+using namespace NifLib;
 
 //Constructor
 SkinData::SkinData() : scale(0.0f), numVertices((ushort)0) {};
diff --git a/gen/SkinData.h b/gen/SkinData.h
index 8e4e78fca10c584e3a2b9d11d098cbb432c8481b..fa6f542c0b0e16c43576b66f7e4d392d3428ad45 100644
--- a/gen/SkinData.h
+++ b/gen/SkinData.h
@@ -8,6 +8,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "SkinWeight.h"
+namespace NifLib {
+
 
 /*!
  * Skinning data component.
@@ -35,15 +37,16 @@ struct NIFLIB_API SkinData {
 	 * may not be related to each other so their specification as an array of
 	 * 4 floats may be misleading.
 	 */
-	float unknown4Floats[4];
+	array<float,4> unknown4Floats;
 	/*!
 	 * Number of weighted vertices.
 	 */
-	ushort numVertices;
+	mutable ushort numVertices;
 	/*!
 	 * The vertex weights.
 	 */
 	vector<SkinWeight > vertexWeights;
 };
 
+}
 #endif
diff --git a/gen/SkinPartition.cpp b/gen/SkinPartition.cpp
index 7ac08c81325590c4240f92cae57740314fefb9e6..b93d183390a2e51239b1b47f5b169440d4815260 100644
--- a/gen/SkinPartition.cpp
+++ b/gen/SkinPartition.cpp
@@ -2,9 +2,23 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "SkinPartition.h"
+using namespace NifLib;
 
 //Constructor
 SkinPartition::SkinPartition() : numVertices((ushort)0), numTriangles((ushort)0), numBones((ushort)0), numStrips((ushort)0), numWeightsPerVertex((ushort)0), hasVertexMap(false), hasVertexWeights(false), hasStrips(false), hasBoneIndices(false) {};
 
 //Destructor
 SkinPartition::~SkinPartition() {};
+
+// needs to be moved elsewhere but this will work for now
+ushort SkinPartition::CalcNumTriangles() const {
+   ushort size = 0;
+   if (stripLengths.empty()) {
+      size = (ushort)triangles.size();
+   } else {
+      for (size_t i=0; i<stripLengths.size(); ++i)
+         size += (ushort)stripLengths[i];
+      size -= 2;
+   }
+   return size;
+}
\ No newline at end of file
diff --git a/gen/SkinPartition.h b/gen/SkinPartition.h
index a321ca4e26bd04bcf86b4d0af77bc16f6bc95cf7..e51926bba6043be185cbe946f574cbe5cff14cc0 100644
--- a/gen/SkinPartition.h
+++ b/gen/SkinPartition.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Skinning data for a submesh, optimized for hardware skinning. Part of
@@ -19,23 +21,27 @@ struct NIFLIB_API SkinPartition {
 	/*!
 	 * Number of vertices in this submesh.
 	 */
-	ushort numVertices;
+	mutable ushort numVertices;
+	/*!
+	 * Number of triangles in this submesh.
+	 */
+	mutable ushort numTriangles;
 	/*!
 	 * Number of triangles in this submesh.
 	 */
-	ushort numTriangles;
+	ushort CalcNumTriangles() const;
 	/*!
 	 * Number of bones influencing this submesh.
 	 */
-	ushort numBones;
+	mutable ushort numBones;
 	/*!
 	 * Number of strips in this submesh (zero if not stripped).
 	 */
-	ushort numStrips;
+	mutable ushort numStrips;
 	/*!
 	 * Number of weight coefficients per vertex.
 	 */
-	ushort numWeightsPerVertex;
+	mutable ushort numWeightsPerVertex;
 	/*!
 	 * List of bones.
 	 */
@@ -60,7 +66,7 @@ struct NIFLIB_API SkinPartition {
 	/*!
 	 * The strip lengths.
 	 */
-	vector<ushort > stripLengths;
+	mutable vector<ushort > stripLengths;
 	/*!
 	 * Do we have strip data?
 	 */
@@ -83,4 +89,5 @@ struct NIFLIB_API SkinPartition {
 	vector<vector<byte > > boneIndices;
 };
 
+}
 #endif
diff --git a/gen/SkinShape.cpp b/gen/SkinShape.cpp
index 905d0e8f320479b72edfce19f3d85074c2966e0b..663d9ba6af5ae2ab16bb5da7b1b7a7f388bfabe2 100644
--- a/gen/SkinShape.cpp
+++ b/gen/SkinShape.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "SkinShape.h"
 #include "../obj/NiTriShape.h"
 #include "../obj/NiSkinInstance.h"
+using namespace NifLib;
 
 //Constructor
 SkinShape::SkinShape() : shape(NULL), skinInstance(NULL) {};
diff --git a/gen/SkinShape.h b/gen/SkinShape.h
index 51fab5277e95e8d0b48a41adfa846d360f707c4a..4f00d9d9cb59e127eb05e74bbb411271a3634139 100644
--- a/gen/SkinShape.h
+++ b/gen/SkinShape.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
 class NiTriShape;
@@ -31,4 +32,5 @@ struct NIFLIB_API SkinShape {
 	Ref<NiSkinInstance > skinInstance;
 };
 
+}
 #endif
diff --git a/gen/SkinShapeGroup.cpp b/gen/SkinShapeGroup.cpp
index 893c737064bc5501af05b7396d1088c7aa36ace1..cbddd7ab2c5af79a38f0f4bb67fa49904c63bbff 100644
--- a/gen/SkinShapeGroup.cpp
+++ b/gen/SkinShapeGroup.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "SkinShape.h"
 #include "../obj/NiTriShape.h"
 #include "../obj/NiSkinInstance.h"
+using namespace NifLib;
 
 //Constructor
 SkinShapeGroup::SkinShapeGroup() : numLinkPairs((uint)0) {};
diff --git a/gen/SkinShapeGroup.h b/gen/SkinShapeGroup.h
index 6cf484431344182402d921b1dbd5a1285b7cb36d..6108f0dfc9950d9a846ef566be6a87d2b1bc879b 100644
--- a/gen/SkinShapeGroup.h
+++ b/gen/SkinShapeGroup.h
@@ -8,6 +8,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "SkinShape.h"
+namespace NifLib {
+
 
 /*!
  * Unknown.
@@ -20,7 +22,7 @@ struct NIFLIB_API SkinShapeGroup {
 	/*!
 	 * Counts unknown.
 	 */
-	uint numLinkPairs;
+	mutable uint numLinkPairs;
 	/*!
 	 * First link is a NiTriShape block. Second link is a NiSkinInstance
 	 * block.
@@ -28,4 +30,5 @@ struct NIFLIB_API SkinShapeGroup {
 	vector<SkinShape > linkPairs;
 };
 
+}
 #endif
diff --git a/gen/SkinWeight.cpp b/gen/SkinWeight.cpp
index bb35f75dbf7bd4ad10eaa5cefcd561ef981743fa..2cd6a05a8cff9c5c1787f76252ef967454871b2d 100644
--- a/gen/SkinWeight.cpp
+++ b/gen/SkinWeight.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "SkinWeight.h"
+using namespace NifLib;
 
 //Constructor
 SkinWeight::SkinWeight() : index((ushort)0), weight(0.0f) {};
diff --git a/gen/SkinWeight.h b/gen/SkinWeight.h
index 2dfafae96a210a8f42af8cc75252505525056ca8..9dc0a2fe0a368759da9ff96bb35781f17ae96838 100644
--- a/gen/SkinWeight.h
+++ b/gen/SkinWeight.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * A weighted vertex.
@@ -25,4 +27,5 @@ struct NIFLIB_API SkinWeight {
 	float weight;
 };
 
+}
 #endif
diff --git a/gen/StringPalette.cpp b/gen/StringPalette.cpp
index 4eeee30ed9746f320c20419f0e000f8c88673d4e..eb2005c69a926bd32f1b560d65939ba9cf10827f 100644
--- a/gen/StringPalette.cpp
+++ b/gen/StringPalette.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "StringPalette.h"
+using namespace NifLib;
 
 //Constructor
 StringPalette::StringPalette() : length((uint)0) {};
diff --git a/gen/StringPalette.h b/gen/StringPalette.h
index 9f3a9c6ac7bdbbc42a1eb535e463de36c7fc453f..18b616f2782f484ac5c2bc5d5295c3b335e05dce 100644
--- a/gen/StringPalette.h
+++ b/gen/StringPalette.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * A list of \\0 terminated strings.
@@ -25,4 +27,5 @@ struct NIFLIB_API StringPalette {
 	uint length;
 };
 
+}
 #endif
diff --git a/gen/TBC.cpp b/gen/TBC.cpp
index b11f4c33ee8644219802690b152481d1b5d1b30d..79bbdf72ff08a29e63c3f6ba90b922253e297f81 100644
--- a/gen/TBC.cpp
+++ b/gen/TBC.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "TBC.h"
+using namespace NifLib;
 
 //Constructor
 TBC::TBC() : t(0.0f), b(0.0f), c(0.0f) {};
diff --git a/gen/TBC.h b/gen/TBC.h
index fa972d7524f66e1c53feb80e20b4f065aa91969a..634e7a8dc6c3b4bb58dec5bf000a12fdb9c35afd 100644
--- a/gen/TBC.h
+++ b/gen/TBC.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * Tension, bias, continuity.
@@ -29,4 +31,5 @@ struct NIFLIB_API TBC {
 	float c;
 };
 
+}
 #endif
diff --git a/gen/TexDesc.cpp b/gen/TexDesc.cpp
index 66cf1cb346c3bb7bc1ea1f442ecfee977fc89ec8..d7cf5fc9db08a02161f7adcf8e9086212cd7ef1b 100644
--- a/gen/TexDesc.cpp
+++ b/gen/TexDesc.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "TexDesc.h"
 #include "../obj/NiSourceTexture.h"
+using namespace NifLib;
 
 //Constructor
 TexDesc::TexDesc() : source(NULL), clampMode((TexClampMode)WRAP_S_WRAP_T), filterMode((TexFilterMode)FILTER_TRILERP), textureSet((uint)0), ps2L((ushort)0), ps2K((ushort)0xFFB5), unknown1((ushort)0), hasTextureTransform(false), wRotation(0.0f), transformType_((uint)0) {};
diff --git a/gen/TexDesc.h b/gen/TexDesc.h
index e3291f34d305cd35d88fcb80dc5652fae1151925..9ae45c6d8217a9b68c16b26468c4660985ebbf71 100644
--- a/gen/TexDesc.h
+++ b/gen/TexDesc.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
 class NiSourceTexture;
@@ -74,4 +75,5 @@ struct NIFLIB_API TexDesc {
 	TexCoord centerOffset;
 };
 
+}
 #endif
diff --git a/gen/TexSource.cpp b/gen/TexSource.cpp
index e3e35db7d5b6aeed081e498c4ab823154ddcabca..b16cc28f081e55365595b637b027c1d93c102460 100644
--- a/gen/TexSource.cpp
+++ b/gen/TexSource.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "TexSource.h"
 #include "../obj/NiObject.h"
 #include "../obj/NiPixelData.h"
+using namespace NifLib;
 
 //Constructor
 TexSource::TexSource() : useExternal((byte)0), unknownLink(NULL), unknownByte((byte)0), pixelData(NULL) {};
diff --git a/gen/TexSource.h b/gen/TexSource.h
index 0dd4faa2513488677873ea75709b2f4c44107be3..1476e8c72e91f9a4daa43c700a428249a09d7251 100644
--- a/gen/TexSource.h
+++ b/gen/TexSource.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Include structures
 #include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
 class NiObject;
@@ -52,4 +53,5 @@ struct NIFLIB_API TexSource {
 	Ref<NiPixelData > pixelData;
 };
 
+}
 #endif
diff --git a/gen/hkTriangle.cpp b/gen/hkTriangle.cpp
index e6c99c45bdcfed6e0bf333a2d64eeb6e18dbcb8b..aea75ad15ece81655136e61064aed544989b1e19 100644
--- a/gen/hkTriangle.cpp
+++ b/gen/hkTriangle.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "hkTriangle.h"
+using namespace NifLib;
 
 //Constructor
 hkTriangle::hkTriangle() : unknownShort((ushort)0) {};
diff --git a/gen/hkTriangle.h b/gen/hkTriangle.h
index b897b8ad9d9dacc5708ed9fb4bbabc2207ac30a3..cf42c433c63d697511e4a1affe1d9f04c1640b45 100644
--- a/gen/hkTriangle.h
+++ b/gen/hkTriangle.h
@@ -6,6 +6,8 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "../NIF_IO.h"
 
+namespace NifLib {
+
 
 /*!
  * A triangle with extra data used for physics.
@@ -30,4 +32,5 @@ struct NIFLIB_API hkTriangle {
 	Vector3 normal;
 };
 
+}
 #endif
diff --git a/gen/obj_defines.h b/gen/obj_defines.h
index 7572b1f36a3ba8e6fbd5467f8d4ba31eb6d70185..af9f61924a0613f558f127061a72760f0bcdfaf0 100644
--- a/gen/obj_defines.h
+++ b/gen/obj_defines.h
@@ -6,6 +6,13 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #define MAXARRAYDUMP 20
 
+#define STANDARD_INTERNAL_METHODS \
+private:\
+  void InternalRead( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );\
+  void InternalWrite( ostream& out, map<NiObjectRef,uint> link_map, unsigned int version, unsigned int user_version ) const;\
+  string InternalAsString( bool verbose ) const;\
+  void InternalFixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );\
+  list<NiObjectRef> InternalGetRefs() const;
 #define NI_OBJECT_MEMBERS \
 
 #define NI_OBJECT_INCLUDE ".h" \
@@ -15,18 +22,19 @@ All rights reserved.  Please see niflib.h for licence. */
 #define NI_OBJECT_CONSTRUCT \
 
 #define NI_OBJECT_READ \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_OBJECT_WRITE \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_OBJECT_STRING \
-stringstream out; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_OBJECT_FIXLINKS \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-return refs; \
+return InternalGetRefs(); \
 
 #define A_KEYED_DATA_MEMBERS \
 
@@ -37,23 +45,19 @@ return refs; \
 #define A_KEYED_DATA_CONSTRUCT \
 
 #define A_KEYED_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define A_KEYED_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define A_KEYED_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define A_KEYED_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define A_KEYED_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define A_PARTICLE_MODIFIER_MEMBERS \
 Ref<AParticleModifier > nextModifier; \
@@ -67,58 +71,19 @@ NiParticleSystemController * controller; \
  : nextModifier(NULL), controller(NULL) \
 
 #define A_PARTICLE_MODIFIER_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define A_PARTICLE_MODIFIER_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-if ( nextModifier != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(nextModifier)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( controller != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(controller)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define A_PARTICLE_MODIFIER_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Next Modifier:  " << nextModifier << endl; \
-out << "Controller:  " << controller << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define A_PARTICLE_MODIFIER_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	nextModifier = DynamicCast<AParticleModifier>(objects[link_stack.front()]); \
-	if ( nextModifier == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	nextModifier = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	controller = DynamicCast<NiParticleSystemController>(objects[link_stack.front()]); \
-	if ( controller == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	controller = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define A_PARTICLE_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( nextModifier != NULL ) \
-	refs.push_back(StaticCast<NiObject>(nextModifier)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_REF_OBJECT_MEMBERS \
 
@@ -129,23 +94,19 @@ return refs; \
 #define BHK_REF_OBJECT_CONSTRUCT \
 
 #define BHK_REF_OBJECT_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_REF_OBJECT_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_REF_OBJECT_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_REF_OBJECT_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_REF_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_SERIALIZABLE_MEMBERS \
 
@@ -156,26 +117,22 @@ return refs; \
 #define BHK_SERIALIZABLE_CONSTRUCT \
 
 #define BHK_SERIALIZABLE_READ \
-bhkRefObject::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_SERIALIZABLE_WRITE \
-bhkRefObject::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_SERIALIZABLE_STRING \
-stringstream out; \
-out << bhkRefObject::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_SERIALIZABLE_FIXLINKS \
-bhkRefObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_SERIALIZABLE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkRefObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define ABHK_CONSTRAINT_MEMBERS \
-uint numBodies; \
+mutable uint numBodies; \
 vector<bhkShape * > bodies; \
 uint priority; \
 
@@ -187,61 +144,19 @@ uint priority; \
  : numBodies((uint)0), priority((uint)1) \
 
 #define ABHK_CONSTRAINT_READ \
-uint block_num; \
-bhkSerializable::Read( in, link_stack, version, user_version ); \
-NifStream( numBodies, in, version ); \
-bodies.resize(numBodies); \
-for (uint i0 = 0; i0 < bodies.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( priority, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define ABHK_CONSTRAINT_WRITE \
-bhkSerializable::Write( out, link_map, version, user_version ); \
-NifStream( numBodies, out, version ); \
-for (uint i0 = 0; i0 < bodies.size(); i0++) { \
-	if ( bodies[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(bodies[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-NifStream( priority, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define ABHK_CONSTRAINT_STRING \
-stringstream out; \
-out << bhkSerializable::asString(); \
-out << "Num Bodies:  " << numBodies << endl; \
-for (uint i0 = 0; i0 < bodies.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Bodies[" << i0 << "]:  " << bodies[i0] << endl; \
-}; \
-out << "Priority:  " << priority << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define ABHK_CONSTRAINT_FIXLINKS \
-bhkSerializable::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < bodies.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		bodies[i0] = DynamicCast<bhkShape>(objects[link_stack.front()]); \
-		if ( bodies[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		bodies[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define ABHK_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkSerializable::GetRefs(); \
-for (uint i0 = 0; i0 < bodies.size(); i0++) { \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define ABHK_RAGDOLL_CONSTRAINT_MEMBERS \
 Float4 pivotA; \
@@ -265,59 +180,19 @@ float maxFriction; \
  : coneMinAngle(0.0f), planeMinAngle(0.0f), planeMaxAngle(0.0f), twistMinAngle(0.0f), twistMaxAngle(0.0f), maxFriction(0.0f) \
 
 #define ABHK_RAGDOLL_CONSTRAINT_READ \
-AbhkConstraint::Read( in, link_stack, version, user_version ); \
-NifStream( pivotA, in, version ); \
-NifStream( planeA, in, version ); \
-NifStream( twistA, in, version ); \
-NifStream( pivotB, in, version ); \
-NifStream( planeB, in, version ); \
-NifStream( twistB, in, version ); \
-NifStream( coneMinAngle, in, version ); \
-NifStream( planeMinAngle, in, version ); \
-NifStream( planeMaxAngle, in, version ); \
-NifStream( twistMinAngle, in, version ); \
-NifStream( twistMaxAngle, in, version ); \
-NifStream( maxFriction, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define ABHK_RAGDOLL_CONSTRAINT_WRITE \
-AbhkConstraint::Write( out, link_map, version, user_version ); \
-NifStream( pivotA, out, version ); \
-NifStream( planeA, out, version ); \
-NifStream( twistA, out, version ); \
-NifStream( pivotB, out, version ); \
-NifStream( planeB, out, version ); \
-NifStream( twistB, out, version ); \
-NifStream( coneMinAngle, out, version ); \
-NifStream( planeMinAngle, out, version ); \
-NifStream( planeMaxAngle, out, version ); \
-NifStream( twistMinAngle, out, version ); \
-NifStream( twistMaxAngle, out, version ); \
-NifStream( maxFriction, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define ABHK_RAGDOLL_CONSTRAINT_STRING \
-stringstream out; \
-out << AbhkConstraint::asString(); \
-out << "Pivot A:  " << pivotA << endl; \
-out << "Plane A:  " << planeA << endl; \
-out << "Twist A:  " << twistA << endl; \
-out << "Pivot B:  " << pivotB << endl; \
-out << "Plane B:  " << planeB << endl; \
-out << "Twist B:  " << twistB << endl; \
-out << "Cone Min Angle:  " << coneMinAngle << endl; \
-out << "Plane Min Angle:  " << planeMinAngle << endl; \
-out << "Plane Max Angle:  " << planeMaxAngle << endl; \
-out << "Twist Min Angle:  " << twistMinAngle << endl; \
-out << "Twist Max Angle:  " << twistMaxAngle << endl; \
-out << "Max Friction:  " << maxFriction << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define ABHK_RAGDOLL_CONSTRAINT_FIXLINKS \
-AbhkConstraint::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define ABHK_RAGDOLL_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkConstraint::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_SHAPE_MEMBERS \
 
@@ -328,23 +203,19 @@ return refs; \
 #define BHK_SHAPE_CONSTRUCT \
 
 #define BHK_SHAPE_READ \
-bhkSerializable::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_SHAPE_WRITE \
-bhkSerializable::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_SHAPE_STRING \
-stringstream out; \
-out << bhkSerializable::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_SHAPE_FIXLINKS \
-bhkSerializable::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkSerializable::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define ABHK_SHAPE_COLLECTION_MEMBERS \
 
@@ -355,23 +226,19 @@ return refs; \
 #define ABHK_SHAPE_COLLECTION_CONSTRUCT \
 
 #define ABHK_SHAPE_COLLECTION_READ \
-bhkShape::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define ABHK_SHAPE_COLLECTION_WRITE \
-bhkShape::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define ABHK_SHAPE_COLLECTION_STRING \
-stringstream out; \
-out << bhkShape::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define ABHK_SHAPE_COLLECTION_FIXLINKS \
-bhkShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define ABHK_SHAPE_COLLECTION_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_SPHERE_REP_SHAPE_MEMBERS \
 uint material; \
@@ -384,26 +251,19 @@ uint material; \
  : material((uint)0) \
 
 #define BHK_SPHERE_REP_SHAPE_READ \
-bhkShape::Read( in, link_stack, version, user_version ); \
-NifStream( material, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_SPHERE_REP_SHAPE_WRITE \
-bhkShape::Write( out, link_map, version, user_version ); \
-NifStream( material, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_SPHERE_REP_SHAPE_STRING \
-stringstream out; \
-out << bhkShape::asString(); \
-out << "Material:  " << material << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_SPHERE_REP_SHAPE_FIXLINKS \
-bhkShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_SPHERE_REP_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_CONVEX_SHAPE_MEMBERS \
 
@@ -414,23 +274,19 @@ return refs; \
 #define BHK_CONVEX_SHAPE_CONSTRUCT \
 
 #define BHK_CONVEX_SHAPE_READ \
-bhkSphereRepShape::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_CONVEX_SHAPE_WRITE \
-bhkSphereRepShape::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_CONVEX_SHAPE_STRING \
-stringstream out; \
-out << bhkSphereRepShape::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_CONVEX_SHAPE_FIXLINKS \
-bhkSphereRepShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_CONVEX_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkSphereRepShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_WORLD_OBJECT_MEMBERS \
 
@@ -441,23 +297,19 @@ return refs; \
 #define BHK_WORLD_OBJECT_CONSTRUCT \
 
 #define BHK_WORLD_OBJECT_READ \
-bhkShape::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_WORLD_OBJECT_WRITE \
-bhkShape::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_WORLD_OBJECT_STRING \
-stringstream out; \
-out << bhkShape::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_WORLD_OBJECT_FIXLINKS \
-bhkShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_WORLD_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_ENTITY_MEMBERS \
 Ref<bhkShape > shape; \
@@ -471,45 +323,19 @@ uint layer; \
  : shape(NULL), layer((uint)0) \
 
 #define BHK_ENTITY_READ \
-uint block_num; \
-bhkWorldObject::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( layer, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_ENTITY_WRITE \
-bhkWorldObject::Write( out, link_map, version, user_version ); \
-if ( shape != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(shape)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( layer, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_ENTITY_STRING \
-stringstream out; \
-out << bhkWorldObject::asString(); \
-out << "Shape:  " << shape << endl; \
-out << "Layer:  " << layer << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_ENTITY_FIXLINKS \
-bhkWorldObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	shape = DynamicCast<bhkShape>(objects[link_stack.front()]); \
-	if ( shape == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	shape = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_ENTITY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkWorldObject::GetRefs(); \
-if ( shape != NULL ) \
-	refs.push_back(StaticCast<NiObject>(shape)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_COLLISION_OBJECT_MEMBERS \
 NiAVObject * parent; \
@@ -524,61 +350,19 @@ Ref<NiObject > body; \
  : parent(NULL), unknownShort((ushort)0), body(NULL) \
 
 #define NI_COLLISION_OBJECT_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( unknownShort, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_COLLISION_OBJECT_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-if ( parent != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(parent)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( unknownShort, out, version ); \
-if ( body != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(body)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_COLLISION_OBJECT_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Parent:  " << parent << endl; \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Body:  " << body << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_COLLISION_OBJECT_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	parent = DynamicCast<NiAVObject>(objects[link_stack.front()]); \
-	if ( parent == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	parent = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	body = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( body == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	body = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_COLLISION_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( body != NULL ) \
-	refs.push_back(StaticCast<NiObject>(body)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_EXTRA_DATA_MEMBERS \
 string name; \
@@ -592,55 +376,19 @@ Ref<NiExtraData > nextExtraData; \
  : nextExtraData(NULL) \
 
 #define NI_EXTRA_DATA_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A000100 ) { \
-	NifStream( name, in, version ); \
-}; \
-if ( version <= 0x04020200 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_EXTRA_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A000100 ) { \
-	NifStream( name, out, version ); \
-}; \
-if ( version <= 0x04020200 ) { \
-	if ( nextExtraData != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(nextExtraData)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Name:  " << name << endl; \
-out << "Next Extra Data:  " << nextExtraData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_EXTRA_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x04020200 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		nextExtraData = DynamicCast<NiExtraData>(objects[link_stack.front()]); \
-		if ( nextExtraData == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		nextExtraData = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( nextExtraData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(nextExtraData)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_INTERPOLATOR_MEMBERS \
 
@@ -651,23 +399,19 @@ return refs; \
 #define NI_INTERPOLATOR_CONSTRUCT \
 
 #define NI_INTERPOLATOR_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_INTERPOLATOR_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_INTERPOLATOR_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BLEND_INTERPOLATOR_MEMBERS \
 ushort unknownShort; \
@@ -681,29 +425,19 @@ uint unknownInt; \
  : unknownShort((ushort)0), unknownInt((uint)0) \
 
 #define NI_BLEND_INTERPOLATOR_READ \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( unknownShort, in, version ); \
-NifStream( unknownInt, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BLEND_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( unknownShort, out, version ); \
-NifStream( unknownInt, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BLEND_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Unknown Int:  " << unknownInt << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BLEND_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BLEND_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_SPLINE_INTERPOLATOR_MEMBERS \
 float startTime; \
@@ -717,34 +451,24 @@ float stopTime; \
  : startTime(0.0f), stopTime(0.0f) \
 
 #define NI_B_SPLINE_INTERPOLATOR_READ \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( startTime, in, version ); \
-NifStream( stopTime, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( startTime, out, version ); \
-NifStream( stopTime, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_SPLINE_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Start Time:  " << startTime << endl; \
-out << "Stop Time:  " << stopTime << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_SPLINE_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_OBJECT_N_E_T_MEMBERS \
 string name; \
 Ref<NiExtraData > extraData; \
-uint numExtraDataList; \
+mutable uint numExtraDataList; \
 vector<Ref<NiExtraData > > extraDataList; \
 Ref<NiTimeController > controller; \
 
@@ -756,111 +480,19 @@ Ref<NiTimeController > controller; \
  : extraData(NULL), numExtraDataList((uint)0), controller(NULL) \
 
 #define NI_OBJECT_N_E_T_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( name, in, version ); \
-if ( version <= 0x04020200 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-if ( version >= 0x0A000100 ) { \
-	NifStream( numExtraDataList, in, version ); \
-	extraDataList.resize(numExtraDataList); \
-	for (uint i1 = 0; i1 < extraDataList.size(); i1++) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_OBJECT_N_E_T_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( name, out, version ); \
-if ( version <= 0x04020200 ) { \
-	if ( extraData != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(extraData)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( version >= 0x0A000100 ) { \
-	NifStream( numExtraDataList, out, version ); \
-	for (uint i1 = 0; i1 < extraDataList.size(); i1++) { \
-		if ( extraDataList[i1] != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(extraDataList[i1])], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
-if ( controller != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(controller)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_OBJECT_N_E_T_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Name:  " << name << endl; \
-out << "Extra Data:  " << extraData << endl; \
-out << "Num Extra Data List:  " << numExtraDataList << endl; \
-for (uint i0 = 0; i0 < extraDataList.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Extra Data List[" << i0 << "]:  " << extraDataList[i0] << endl; \
-}; \
-out << "Controller:  " << controller << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_OBJECT_N_E_T_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x04020200 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		extraData = DynamicCast<NiExtraData>(objects[link_stack.front()]); \
-		if ( extraData == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		extraData = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( version >= 0x0A000100 ) { \
-	for (uint i1 = 0; i1 < extraDataList.size(); i1++) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			extraDataList[i1] = DynamicCast<NiExtraData>(objects[link_stack.front()]); \
-			if ( extraDataList[i1] == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			extraDataList[i1] = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	controller = DynamicCast<NiTimeController>(objects[link_stack.front()]); \
-	if ( controller == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	controller = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_OBJECT_N_E_T_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( extraData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(extraData)); \
-for (uint i0 = 0; i0 < extraDataList.size(); i0++) { \
-	if ( extraDataList[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(extraDataList[i0])); \
-}; \
-if ( controller != NULL ) \
-	refs.push_back(StaticCast<NiObject>(controller)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_A_V_OBJECT_MEMBERS \
 ushort flags; \
@@ -868,7 +500,7 @@ Vector3 translation; \
 Matrix33 rotation; \
 float scale; \
 Vector3 velocity; \
-uint numProperties; \
+mutable uint numProperties; \
 vector<Ref<NiProperty > > properties; \
 bool hasBoundingBox; \
 BoundingBox boundingBox; \
@@ -883,158 +515,25 @@ Ref<NiCollisionObject > collisionObject; \
  : flags((ushort)0), scale(1.0f), numProperties((uint)0), hasBoundingBox(false), collisionData(NULL), collisionObject(NULL) \
 
 #define NI_A_V_OBJECT_READ \
-uint block_num; \
-NiObjectNET::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
-NifStream( translation, in, version ); \
-NifStream( rotation, in, version ); \
-NifStream( scale, in, version ); \
-if ( version <= 0x04020200 ) { \
-	NifStream( velocity, in, version ); \
-}; \
-NifStream( numProperties, in, version ); \
-properties.resize(numProperties); \
-for (uint i0 = 0; i0 < properties.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-if ( version <= 0x04020200 ) { \
-	NifStream( hasBoundingBox, in, version ); \
-	if ( (hasBoundingBox != 0) ) { \
-		NifStream( boundingBox.unknownInt, in, version ); \
-		NifStream( boundingBox.translation, in, version ); \
-		NifStream( boundingBox.rotation, in, version ); \
-		NifStream( boundingBox.radius, in, version ); \
-	}; \
-}; \
-if ( ( version >= 0x0A000100 ) && ( version <= 0x0A020000 ) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_A_V_OBJECT_WRITE \
-NiObjectNET::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
-NifStream( translation, out, version ); \
-NifStream( rotation, out, version ); \
-NifStream( scale, out, version ); \
-if ( version <= 0x04020200 ) { \
-	NifStream( velocity, out, version ); \
-}; \
-NifStream( numProperties, out, version ); \
-for (uint i0 = 0; i0 < properties.size(); i0++) { \
-	if ( properties[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(properties[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( version <= 0x04020200 ) { \
-	NifStream( hasBoundingBox, out, version ); \
-	if ( (hasBoundingBox != 0) ) { \
-		NifStream( boundingBox.unknownInt, out, version ); \
-		NifStream( boundingBox.translation, out, version ); \
-		NifStream( boundingBox.rotation, out, version ); \
-		NifStream( boundingBox.radius, out, version ); \
-	}; \
-}; \
-if ( ( version >= 0x0A000100 ) && ( version <= 0x0A020000 ) ) { \
-	if ( collisionData != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(collisionData)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	if ( collisionObject != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(collisionObject)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_A_V_OBJECT_STRING \
-stringstream out; \
-out << NiObjectNET::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Translation:  " << translation << endl; \
-out << "Rotation:  " << rotation << endl; \
-out << "Scale:  " << scale << endl; \
-out << "Velocity:  " << velocity << endl; \
-out << "Num Properties:  " << numProperties << endl; \
-for (uint i0 = 0; i0 < properties.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Properties[" << i0 << "]:  " << properties[i0] << endl; \
-}; \
-out << "Has Bounding Box:  " << hasBoundingBox << endl; \
-if ( (hasBoundingBox != 0) ) { \
-	out << "  Unknown Int:  " << boundingBox.unknownInt << endl; \
-	out << "  Translation:  " << boundingBox.translation << endl; \
-	out << "  Rotation:  " << boundingBox.rotation << endl; \
-	out << "  Radius:  " << boundingBox.radius << endl; \
-}; \
-out << "Collision Data:  " << collisionData << endl; \
-out << "Collision Object:  " << collisionObject << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_A_V_OBJECT_FIXLINKS \
-NiObjectNET::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < properties.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		properties[i0] = DynamicCast<NiProperty>(objects[link_stack.front()]); \
-		if ( properties[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		properties[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( ( version >= 0x0A000100 ) && ( version <= 0x0A020000 ) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		collisionData = DynamicCast<NiCollisionData>(objects[link_stack.front()]); \
-		if ( collisionData == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		collisionData = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( version >= 0x14000004 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		collisionObject = DynamicCast<NiCollisionObject>(objects[link_stack.front()]); \
-		if ( collisionObject == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		collisionObject = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_A_V_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObjectNET::GetRefs(); \
-for (uint i0 = 0; i0 < properties.size(); i0++) { \
-	if ( properties[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(properties[i0])); \
-}; \
-if ( collisionData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(collisionData)); \
-if ( collisionObject != NULL ) \
-	refs.push_back(StaticCast<NiObject>(collisionObject)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_DYNAMIC_EFFECT_MEMBERS \
 bool hasAffectedNodeList_; \
 uint affectedNodeList_; \
 bool switchState; \
-uint numAffectedNodes; \
+mutable uint numAffectedNodes; \
 vector<Ref<NiAVObject > > affectedNodes; \
 
 #define NI_DYNAMIC_EFFECT_INCLUDE "NiAVObject.h" \
@@ -1045,89 +544,19 @@ vector<Ref<NiAVObject > > affectedNodes; \
  : hasAffectedNodeList_(false), affectedNodeList_((uint)0), switchState(false), numAffectedNodes((uint)0) \
 
 #define NI_DYNAMIC_EFFECT_READ \
-uint block_num; \
-NiAVObject::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x04000002 ) { \
-	NifStream( hasAffectedNodeList_, in, version ); \
-	if ( (hasAffectedNodeList_ != 0) ) { \
-		NifStream( affectedNodeList_, in, version ); \
-	}; \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( switchState, in, version ); \
-}; \
-if ( version >= 0x0A010000 ) { \
-	NifStream( numAffectedNodes, in, version ); \
-	affectedNodes.resize(numAffectedNodes); \
-	for (uint i1 = 0; i1 < affectedNodes.size(); i1++) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_DYNAMIC_EFFECT_WRITE \
-NiAVObject::Write( out, link_map, version, user_version ); \
-if ( version <= 0x04000002 ) { \
-	NifStream( hasAffectedNodeList_, out, version ); \
-	if ( (hasAffectedNodeList_ != 0) ) { \
-		NifStream( affectedNodeList_, out, version ); \
-	}; \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( switchState, out, version ); \
-}; \
-if ( version >= 0x0A010000 ) { \
-	NifStream( numAffectedNodes, out, version ); \
-	for (uint i1 = 0; i1 < affectedNodes.size(); i1++) { \
-		if ( affectedNodes[i1] != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(affectedNodes[i1])], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_DYNAMIC_EFFECT_STRING \
-stringstream out; \
-out << NiAVObject::asString(); \
-out << "Has Affected Node List?:  " << hasAffectedNodeList_ << endl; \
-if ( (hasAffectedNodeList_ != 0) ) { \
-	out << "  Affected Node List?:  " << affectedNodeList_ << endl; \
-}; \
-out << "Switch State:  " << switchState << endl; \
-out << "Num Affected Nodes:  " << numAffectedNodes << endl; \
-for (uint i0 = 0; i0 < affectedNodes.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Affected Nodes[" << i0 << "]:  " << affectedNodes[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_DYNAMIC_EFFECT_FIXLINKS \
-NiAVObject::FixLinks( objects, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	for (uint i1 = 0; i1 < affectedNodes.size(); i1++) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			affectedNodes[i1] = DynamicCast<NiAVObject>(objects[link_stack.front()]); \
-			if ( affectedNodes[i1] == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			affectedNodes[i1] = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_DYNAMIC_EFFECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiAVObject::GetRefs(); \
-for (uint i0 = 0; i0 < affectedNodes.size(); i0++) { \
-	if ( affectedNodes[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(affectedNodes[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_LIGHT_MEMBERS \
 float dimmer; \
@@ -1143,35 +572,19 @@ Color3 specularColor; \
  : dimmer(0.0f) \
 
 #define NI_LIGHT_READ \
-NiDynamicEffect::Read( in, link_stack, version, user_version ); \
-NifStream( dimmer, in, version ); \
-NifStream( ambientColor, in, version ); \
-NifStream( diffuseColor, in, version ); \
-NifStream( specularColor, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_LIGHT_WRITE \
-NiDynamicEffect::Write( out, link_map, version, user_version ); \
-NifStream( dimmer, out, version ); \
-NifStream( ambientColor, out, version ); \
-NifStream( diffuseColor, out, version ); \
-NifStream( specularColor, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_LIGHT_STRING \
-stringstream out; \
-out << NiDynamicEffect::asString(); \
-out << "Dimmer:  " << dimmer << endl; \
-out << "Ambient Color:  " << ambientColor << endl; \
-out << "Diffuse Color:  " << diffuseColor << endl; \
-out << "Specular Color:  " << specularColor << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_LIGHT_FIXLINKS \
-NiDynamicEffect::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_LIGHT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiDynamicEffect::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PROPERTY_MEMBERS \
 
@@ -1182,23 +595,19 @@ return refs; \
 #define NI_PROPERTY_CONSTRUCT \
 
 #define NI_PROPERTY_READ \
-NiObjectNET::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PROPERTY_WRITE \
-NiObjectNET::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PROPERTY_STRING \
-stringstream out; \
-out << NiObjectNET::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PROPERTY_FIXLINKS \
-NiObjectNET::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObjectNET::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_MODIFIER_MEMBERS \
 string name; \
@@ -1214,49 +623,19 @@ bool active; \
  : order((uint)0), target(NULL), active(false) \
 
 #define NI_P_SYS_MODIFIER_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( name, in, version ); \
-NifStream( order, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( active, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MODIFIER_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( name, out, version ); \
-NifStream( order, out, version ); \
-if ( target != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(target)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( active, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_MODIFIER_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Name:  " << name << endl; \
-out << "Order:  " << order << endl; \
-out << "Target:  " << target << endl; \
-out << "Active:  " << active << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_MODIFIER_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	target = DynamicCast<NiParticleSystem>(objects[link_stack.front()]); \
-	if ( target == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	target = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_MEMBERS \
 float speed; \
@@ -1279,56 +658,19 @@ float lifeSpanVariation; \
  : speed(0.0f), speedVariation(0.0f), declination(0.0f), declinationVariation(0.0f), planarAngle(0.0f), planarAngleVariation(0.0f), initialRadius(0.0f), radiusVariation(0.0f), lifeSpan(0.0f), lifeSpanVariation(0.0f) \
 
 #define NI_P_SYS_EMITTER_READ \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( speed, in, version ); \
-NifStream( speedVariation, in, version ); \
-NifStream( declination, in, version ); \
-NifStream( declinationVariation, in, version ); \
-NifStream( planarAngle, in, version ); \
-NifStream( planarAngleVariation, in, version ); \
-NifStream( initialColor, in, version ); \
-NifStream( initialRadius, in, version ); \
-NifStream( radiusVariation, in, version ); \
-NifStream( lifeSpan, in, version ); \
-NifStream( lifeSpanVariation, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( speed, out, version ); \
-NifStream( speedVariation, out, version ); \
-NifStream( declination, out, version ); \
-NifStream( declinationVariation, out, version ); \
-NifStream( planarAngle, out, version ); \
-NifStream( planarAngleVariation, out, version ); \
-NifStream( initialColor, out, version ); \
-NifStream( initialRadius, out, version ); \
-NifStream( radiusVariation, out, version ); \
-NifStream( lifeSpan, out, version ); \
-NifStream( lifeSpanVariation, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Speed:  " << speed << endl; \
-out << "Speed Variation:  " << speedVariation << endl; \
-out << "Declination:  " << declination << endl; \
-out << "Declination Variation:  " << declinationVariation << endl; \
-out << "Planar Angle:  " << planarAngle << endl; \
-out << "Planar Angle Variation:  " << planarAngleVariation << endl; \
-out << "Initial Color:  " << initialColor << endl; \
-out << "Initial Radius:  " << initialRadius << endl; \
-out << "Radius Variation:  " << radiusVariation << endl; \
-out << "Life Span:  " << lifeSpan << endl; \
-out << "Life Span Variation:  " << lifeSpanVariation << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_VOLUME_EMITTER_MEMBERS \
 NiNode * emitterObject; \
@@ -1341,46 +683,19 @@ NiNode * emitterObject; \
  : emitterObject(NULL) \
 
 #define NI_P_SYS_VOLUME_EMITTER_READ \
-uint block_num; \
-NiPSysEmitter::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x14000004 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_VOLUME_EMITTER_WRITE \
-NiPSysEmitter::Write( out, link_map, version, user_version ); \
-if ( version >= 0x14000004 ) { \
-	if ( emitterObject != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(emitterObject)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_VOLUME_EMITTER_STRING \
-stringstream out; \
-out << NiPSysEmitter::asString(); \
-out << "Emitter Object:  " << emitterObject << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_VOLUME_EMITTER_FIXLINKS \
-NiPSysEmitter::FixLinks( objects, link_stack, version, user_version ); \
-if ( version >= 0x14000004 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		emitterObject = DynamicCast<NiNode>(objects[link_stack.front()]); \
-		if ( emitterObject == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		emitterObject = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_VOLUME_EMITTER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysEmitter::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TIME_CONTROLLER_MEMBERS \
 Ref<NiTimeController > nextController; \
@@ -1399,77 +714,23 @@ NiObjectNET * target; \
  : nextController(NULL), flags((ushort)0), frequency(0.0f), phase(0.0f), startTime(0.0f), stopTime(0.0f), target(NULL) \
 
 #define NI_TIME_CONTROLLER_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( flags, in, version ); \
-NifStream( frequency, in, version ); \
-NifStream( phase, in, version ); \
-NifStream( startTime, in, version ); \
-NifStream( stopTime, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TIME_CONTROLLER_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-if ( nextController != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(nextController)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( flags, out, version ); \
-NifStream( frequency, out, version ); \
-NifStream( phase, out, version ); \
-NifStream( startTime, out, version ); \
-NifStream( stopTime, out, version ); \
-if ( target != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(target)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TIME_CONTROLLER_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Next Controller:  " << nextController << endl; \
-out << "Flags:  " << flags << endl; \
-out << "Frequency:  " << frequency << endl; \
-out << "Phase:  " << phase << endl; \
-out << "Start Time:  " << startTime << endl; \
-out << "Stop Time:  " << stopTime << endl; \
-out << "Target:  " << target << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TIME_CONTROLLER_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	nextController = DynamicCast<NiTimeController>(objects[link_stack.front()]); \
-	if ( nextController == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	nextController = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	target = DynamicCast<NiObjectNET>(objects[link_stack.front()]); \
-	if ( target == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	target = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TIME_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( nextController != NULL ) \
-	refs.push_back(StaticCast<NiObject>(nextController)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define A_BONE_L_O_D_CONTROLLER_MEMBERS \
 uint unknownInt1; \
-uint numNodeGroups; \
+mutable uint numNodeGroups; \
 uint unknownInt2; \
 vector<NodeGroup > nodeGroups; \
 
@@ -1481,80 +742,19 @@ vector<NodeGroup > nodeGroups; \
  : unknownInt1((uint)0), numNodeGroups((uint)0), unknownInt2((uint)0) \
 
 #define A_BONE_L_O_D_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( unknownInt1, in, version ); \
-NifStream( numNodeGroups, in, version ); \
-NifStream( unknownInt2, in, version ); \
-nodeGroups.resize(numNodeGroups); \
-for (uint i0 = 0; i0 < nodeGroups.size(); i0++) { \
-	NifStream( nodeGroups[i0].numNodes, in, version ); \
-	nodeGroups[i0].nodes.resize(nodeGroups[i0].numNodes); \
-	for (uint i1 = 0; i1 < nodeGroups[i0].nodes.size(); i1++) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define A_BONE_L_O_D_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-NifStream( unknownInt1, out, version ); \
-NifStream( numNodeGroups, out, version ); \
-NifStream( unknownInt2, out, version ); \
-for (uint i0 = 0; i0 < nodeGroups.size(); i0++) { \
-	NifStream( nodeGroups[i0].numNodes, out, version ); \
-	for (uint i1 = 0; i1 < nodeGroups[i0].nodes.size(); i1++) { \
-		if ( nodeGroups[i0].nodes[i1] != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(nodeGroups[i0].nodes[i1])], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define A_BONE_L_O_D_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-out << "Num Node Groups:  " << numNodeGroups << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-for (uint i0 = 0; i0 < nodeGroups.size(); i0++) { \
-	out << "  Num Nodes:  " << nodeGroups[i0].numNodes << endl; \
-	for (uint i1 = 0; i1 < nodeGroups[i0].nodes.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Nodes[" << i1 << "]:  " << nodeGroups[i0].nodes[i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define A_BONE_L_O_D_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < nodeGroups.size(); i0++) { \
-	for (uint i1 = 0; i1 < nodeGroups[i0].nodes.size(); i1++) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			nodeGroups[i0].nodes[i1] = DynamicCast<NiNode>(objects[link_stack.front()]); \
-			if ( nodeGroups[i0].nodes[i1] == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			nodeGroups[i0].nodes[i1] = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define A_BONE_L_O_D_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-for (uint i0 = 0; i0 < nodeGroups.size(); i0++) { \
-	for (uint i1 = 0; i1 < nodeGroups[i0].nodes.size(); i1++) { \
-		if ( nodeGroups[i0].nodes[i1] != NULL ) \
-			refs.push_back(StaticCast<NiObject>(nodeGroups[i0].nodes[i1])); \
-	}; \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SINGLE_INTERPOLATOR_CONTROLLER_MEMBERS \
 Ref<NiInterpolator > interpolator; \
@@ -1567,48 +767,19 @@ Ref<NiInterpolator > interpolator; \
  : interpolator(NULL) \
 
 #define NI_SINGLE_INTERPOLATOR_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A020000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SINGLE_INTERPOLATOR_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A020000 ) { \
-	if ( interpolator != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(interpolator)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SINGLE_INTERPOLATOR_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Interpolator:  " << interpolator << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SINGLE_INTERPOLATOR_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if ( version >= 0x0A020000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		interpolator = DynamicCast<NiInterpolator>(objects[link_stack.front()]); \
-		if ( interpolator == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		interpolator = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SINGLE_INTERPOLATOR_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( interpolator != NULL ) \
-	refs.push_back(StaticCast<NiObject>(interpolator)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define A_P_SYS_CTLR_MEMBERS \
 string modifierName; \
@@ -1620,26 +791,19 @@ string modifierName; \
 #define A_P_SYS_CTLR_CONSTRUCT \
 
 #define A_P_SYS_CTLR_READ \
-NiSingleInterpolatorController::Read( in, link_stack, version, user_version ); \
-NifStream( modifierName, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define A_P_SYS_CTLR_WRITE \
-NiSingleInterpolatorController::Write( out, link_map, version, user_version ); \
-NifStream( modifierName, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define A_P_SYS_CTLR_STRING \
-stringstream out; \
-out << NiSingleInterpolatorController::asString(); \
-out << "Modifier Name:  " << modifierName << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define A_P_SYS_CTLR_FIXLINKS \
-NiSingleInterpolatorController::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define A_P_SYS_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiSingleInterpolatorController::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRI_BASED_GEOM_MEMBERS \
 Ref<NiTriBasedGeomData > data; \
@@ -1656,106 +820,27 @@ Ref<NiObject > unknownLink; \
  : data(NULL), skinInstance(NULL), hasShader(false), unknownLink(NULL) \
 
 #define NI_TRI_BASED_GEOM_READ \
-uint block_num; \
-NiAVObject::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-if ( version >= 0x0A000100 ) { \
-	NifStream( hasShader, in, version ); \
-	if ( (hasShader != 0) ) { \
-		NifStream( shaderName, in, version ); \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRI_BASED_GEOM_WRITE \
-NiAVObject::Write( out, link_map, version, user_version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( skinInstance != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(skinInstance)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( version >= 0x0A000100 ) { \
-	NifStream( hasShader, out, version ); \
-	if ( (hasShader != 0) ) { \
-		NifStream( shaderName, out, version ); \
-		if ( unknownLink != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRI_BASED_GEOM_STRING \
-stringstream out; \
-out << NiAVObject::asString(); \
-out << "Data:  " << data << endl; \
-out << "Skin Instance:  " << skinInstance << endl; \
-out << "Has Shader:  " << hasShader << endl; \
-if ( (hasShader != 0) ) { \
-	out << "  Shader Name:  " << shaderName << endl; \
-	out << "  Unknown Link:  " << unknownLink << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRI_BASED_GEOM_FIXLINKS \
-NiAVObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiTriBasedGeomData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	skinInstance = DynamicCast<NiSkinInstance>(objects[link_stack.front()]); \
-	if ( skinInstance == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	skinInstance = NULL; \
-link_stack.pop_front(); \
-if ( version >= 0x0A000100 ) { \
-	if ( (hasShader != 0) ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			unknownLink = DynamicCast<NiObject>(objects[link_stack.front()]); \
-			if ( unknownLink == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			unknownLink = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRI_BASED_GEOM_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiAVObject::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-if ( skinInstance != NULL ) \
-	refs.push_back(StaticCast<NiObject>(skinInstance)); \
-if ( unknownLink != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRI_BASED_GEOM_DATA_MEMBERS \
 string name; \
-ushort numVertices; \
+mutable ushort numVertices; \
 ushort unknownShort1; \
 bool hasVertices; \
 vector<Vector3 > vertices; \
-byte numUvSets2; \
+mutable byte numUvSets2; \
 byte unknownByte; \
 bool hasNormals; \
 vector<Vector3 > normals; \
@@ -1765,7 +850,7 @@ Vector3 center; \
 float radius; \
 bool hasVertexColors; \
 vector<Color4 > vertexColors; \
-ushort numUvSets; \
+mutable ushort numUvSets; \
 bool hasUv; \
 vector<vector<TexCoord > > uvSets; \
 ushort unknownShort2; \
@@ -1779,246 +864,19 @@ Ref<NiObject > unknownLink; \
  : numVertices((ushort)0), unknownShort1((ushort)0), hasVertices(false), numUvSets2((byte)0), unknownByte((byte)0), hasNormals(false), radius(0.0f), hasVertexColors(false), numUvSets((ushort)0), hasUv(false), unknownShort2((ushort)0), unknownLink(NULL) \
 
 #define NI_TRI_BASED_GEOM_DATA_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A020000 ) { \
-	NifStream( name, in, version ); \
-}; \
-NifStream( numVertices, in, version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownShort1, in, version ); \
-}; \
-NifStream( hasVertices, in, version ); \
-if ( (hasVertices != 0) ) { \
-	vertices.resize(numVertices); \
-	for (uint i1 = 0; i1 < vertices.size(); i1++) { \
-		NifStream( vertices[i1], in, version ); \
-	}; \
-}; \
-if ( version >= 0x0A000100 ) { \
-	NifStream( numUvSets2, in, version ); \
-	NifStream( unknownByte, in, version ); \
-}; \
-NifStream( hasNormals, in, version ); \
-if ( (hasNormals != 0) ) { \
-	normals.resize(numVertices); \
-	for (uint i1 = 0; i1 < normals.size(); i1++) { \
-		NifStream( normals[i1], in, version ); \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (((hasNormals != 0)) && ((unknownByte & 16))) ) { \
-		unknownVectors1.resize(numVertices); \
-		for (uint i2 = 0; i2 < unknownVectors1.size(); i2++) { \
-			NifStream( unknownVectors1[i2], in, version ); \
-		}; \
-		unknownVectors2.resize(numVertices); \
-		for (uint i2 = 0; i2 < unknownVectors2.size(); i2++) { \
-			NifStream( unknownVectors2[i2], in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( center, in, version ); \
-NifStream( radius, in, version ); \
-NifStream( hasVertexColors, in, version ); \
-if ( (hasVertexColors != 0) ) { \
-	vertexColors.resize(numVertices); \
-	for (uint i1 = 0; i1 < vertexColors.size(); i1++) { \
-		NifStream( vertexColors[i1], in, version ); \
-	}; \
-}; \
-if ( version <= 0x04020200 ) { \
-	NifStream( numUvSets, in, version ); \
-}; \
-if ( version <= 0x04000002 ) { \
-	NifStream( hasUv, in, version ); \
-}; \
-if ( version <= 0x04020200 ) { \
-	uvSets.resize(numUvSets); \
-	for (uint i1 = 0; i1 < uvSets.size(); i1++) { \
-		uvSets[i1].resize(numVertices); \
-		for (uint i2 = 0; i2 < uvSets[i1].size(); i2++) { \
-			NifStream( uvSets[i1][i2], in, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x0A000100 ) { \
-	uvSets.resize((numUvSets2 & 63)); \
-	for (uint i1 = 0; i1 < uvSets.size(); i1++) { \
-		uvSets[i1].resize(numVertices); \
-		for (uint i2 = 0; i2 < uvSets[i1].size(); i2++) { \
-			NifStream( uvSets[i1][i2], in, version ); \
-		}; \
-	}; \
-	NifStream( unknownShort2, in, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRI_BASED_GEOM_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A020000 ) { \
-	NifStream( name, out, version ); \
-}; \
-NifStream( numVertices, out, version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownShort1, out, version ); \
-}; \
-NifStream( hasVertices, out, version ); \
-if ( (hasVertices != 0) ) { \
-	for (uint i1 = 0; i1 < vertices.size(); i1++) { \
-		NifStream( vertices[i1], out, version ); \
-	}; \
-}; \
-if ( version >= 0x0A000100 ) { \
-	NifStream( numUvSets2, out, version ); \
-	NifStream( unknownByte, out, version ); \
-}; \
-NifStream( hasNormals, out, version ); \
-if ( (hasNormals != 0) ) { \
-	for (uint i1 = 0; i1 < normals.size(); i1++) { \
-		NifStream( normals[i1], out, version ); \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (((hasNormals != 0)) && ((unknownByte & 16))) ) { \
-		for (uint i2 = 0; i2 < unknownVectors1.size(); i2++) { \
-			NifStream( unknownVectors1[i2], out, version ); \
-		}; \
-		for (uint i2 = 0; i2 < unknownVectors2.size(); i2++) { \
-			NifStream( unknownVectors2[i2], out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( center, out, version ); \
-NifStream( radius, out, version ); \
-NifStream( hasVertexColors, out, version ); \
-if ( (hasVertexColors != 0) ) { \
-	for (uint i1 = 0; i1 < vertexColors.size(); i1++) { \
-		NifStream( vertexColors[i1], out, version ); \
-	}; \
-}; \
-if ( version <= 0x04020200 ) { \
-	NifStream( numUvSets, out, version ); \
-}; \
-if ( version <= 0x04000002 ) { \
-	NifStream( hasUv, out, version ); \
-}; \
-if ( version <= 0x04020200 ) { \
-	for (uint i1 = 0; i1 < uvSets.size(); i1++) { \
-		for (uint i2 = 0; i2 < uvSets[i1].size(); i2++) { \
-			NifStream( uvSets[i1][i2], out, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x0A000100 ) { \
-	for (uint i1 = 0; i1 < uvSets.size(); i1++) { \
-		for (uint i2 = 0; i2 < uvSets[i1].size(); i2++) { \
-			NifStream( uvSets[i1][i2], out, version ); \
-		}; \
-	}; \
-	NifStream( unknownShort2, out, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	if ( unknownLink != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRI_BASED_GEOM_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Name:  " << name << endl; \
-out << "Num Vertices:  " << numVertices << endl; \
-out << "Unknown Short 1:  " << unknownShort1 << endl; \
-out << "Has Vertices:  " << hasVertices << endl; \
-if ( (hasVertices != 0) ) { \
-	for (uint i1 = 0; i1 < vertices.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Vertices[" << i1 << "]:  " << vertices[i1] << endl; \
-	}; \
-}; \
-out << "Num UV Sets 2:  " << numUvSets2 << endl; \
-out << "Unknown Byte:  " << unknownByte << endl; \
-out << "Has Normals:  " << hasNormals << endl; \
-if ( (hasNormals != 0) ) { \
-	for (uint i1 = 0; i1 < normals.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Normals[" << i1 << "]:  " << normals[i1] << endl; \
-	}; \
-}; \
-if ( (((hasNormals != 0)) && ((unknownByte & 16))) ) { \
-	for (uint i1 = 0; i1 < unknownVectors1.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Vectors 1[" << i1 << "]:  " << unknownVectors1[i1] << endl; \
-	}; \
-	for (uint i1 = 0; i1 < unknownVectors2.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Vectors 2[" << i1 << "]:  " << unknownVectors2[i1] << endl; \
-	}; \
-}; \
-out << "Center:  " << center << endl; \
-out << "Radius:  " << radius << endl; \
-out << "Has Vertex Colors:  " << hasVertexColors << endl; \
-if ( (hasVertexColors != 0) ) { \
-	for (uint i1 = 0; i1 < vertexColors.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Vertex Colors[" << i1 << "]:  " << vertexColors[i1] << endl; \
-	}; \
-}; \
-out << "Num UV Sets:  " << numUvSets << endl; \
-out << "Has UV:  " << hasUv << endl; \
-for (uint i0 = 0; i0 < uvSets.size(); i0++) { \
-	for (uint i1 = 0; i1 < uvSets[i0].size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    UV Sets[" << i0 << "][" << i1 << "]:  " << uvSets[i0][i1] << endl; \
-	}; \
-}; \
-out << "Unknown Short 2:  " << unknownShort2 << endl; \
-out << "Unknown Link:  " << unknownLink << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRI_BASED_GEOM_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if ( version >= 0x14000004 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		unknownLink = DynamicCast<NiObject>(objects[link_stack.front()]); \
-		if ( unknownLink == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		unknownLink = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRI_BASED_GEOM_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( unknownLink != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define A_P_SYS_DATA_MEMBERS \
 bool hasUnknownFloats1; \
@@ -2036,75 +894,19 @@ byte unknownByte1; \
  : hasUnknownFloats1(false), unknownShort3((ushort)0), hasUnknownFloats2(false), unknownByte1((byte)0) \
 
 #define A_P_SYS_DATA_READ \
-NiTriBasedGeomData::Read( in, link_stack, version, user_version ); \
-NifStream( hasUnknownFloats1, in, version ); \
-if ( (hasUnknownFloats1 != 0) ) { \
-	unknownFloats1.resize(numVertices); \
-	for (uint i1 = 0; i1 < unknownFloats1.size(); i1++) { \
-		NifStream( unknownFloats1[i1], in, version ); \
-	}; \
-}; \
-NifStream( unknownShort3, in, version ); \
-NifStream( hasUnknownFloats2, in, version ); \
-if ( (hasUnknownFloats2 != 0) ) { \
-	unknownFloats2.resize(numVertices); \
-	for (uint i1 = 0; i1 < unknownFloats2.size(); i1++) { \
-		NifStream( unknownFloats2[i1], in, version ); \
-	}; \
-}; \
-NifStream( unknownByte1, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define A_P_SYS_DATA_WRITE \
-NiTriBasedGeomData::Write( out, link_map, version, user_version ); \
-NifStream( hasUnknownFloats1, out, version ); \
-if ( (hasUnknownFloats1 != 0) ) { \
-	for (uint i1 = 0; i1 < unknownFloats1.size(); i1++) { \
-		NifStream( unknownFloats1[i1], out, version ); \
-	}; \
-}; \
-NifStream( unknownShort3, out, version ); \
-NifStream( hasUnknownFloats2, out, version ); \
-if ( (hasUnknownFloats2 != 0) ) { \
-	for (uint i1 = 0; i1 < unknownFloats2.size(); i1++) { \
-		NifStream( unknownFloats2[i1], out, version ); \
-	}; \
-}; \
-NifStream( unknownByte1, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define A_P_SYS_DATA_STRING \
-stringstream out; \
-out << NiTriBasedGeomData::asString(); \
-out << "Has Unknown Floats 1:  " << hasUnknownFloats1 << endl; \
-if ( (hasUnknownFloats1 != 0) ) { \
-	for (uint i1 = 0; i1 < unknownFloats1.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats 1[" << i1 << "]:  " << unknownFloats1[i1] << endl; \
-	}; \
-}; \
-out << "Unknown Short 3:  " << unknownShort3 << endl; \
-out << "Has Unknown Floats 2:  " << hasUnknownFloats2 << endl; \
-if ( (hasUnknownFloats2 != 0) ) { \
-	for (uint i1 = 0; i1 < unknownFloats2.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats 2[" << i1 << "]:  " << unknownFloats2[i1] << endl; \
-	}; \
-}; \
-out << "Unknown Byte 1:  " << unknownByte1 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define A_P_SYS_DATA_FIXLINKS \
-NiTriBasedGeomData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define A_P_SYS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTriBasedGeomData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_BLEND_COLLISION_OBJECT_MEMBERS \
 float unknownFloat1; \
@@ -2118,29 +920,19 @@ float unknownFloat2; \
  : unknownFloat1(0.0f), unknownFloat2(0.0f) \
 
 #define BHK_BLEND_COLLISION_OBJECT_READ \
-NiCollisionObject::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownFloat2, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_BLEND_COLLISION_OBJECT_WRITE \
-NiCollisionObject::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownFloat2, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_BLEND_COLLISION_OBJECT_STRING \
-stringstream out; \
-out << NiCollisionObject::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_BLEND_COLLISION_OBJECT_FIXLINKS \
-NiCollisionObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_BLEND_COLLISION_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiCollisionObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_BLEND_CONTROLLER_MEMBERS \
 uint unknownInt; \
@@ -2153,26 +945,19 @@ uint unknownInt; \
  : unknownInt((uint)0) \
 
 #define BHK_BLEND_CONTROLLER_READ \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( unknownInt, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_BLEND_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-NifStream( unknownInt, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_BLEND_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown Int:  " << unknownInt << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_BLEND_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_BLEND_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_BOX_SHAPE_MEMBERS \
 float unknownFloat1; \
@@ -2191,44 +976,19 @@ float unknownFloat2; \
  : unknownFloat1(0.0f), unknownShort1((ushort)0), unknownShort2((ushort)0), unknownShort3((ushort)0), unknownShort4((ushort)0), unknownFloat2(0.0f) \
 
 #define BHK_BOX_SHAPE_READ \
-bhkConvexShape::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownShort1, in, version ); \
-NifStream( unknownShort2, in, version ); \
-NifStream( unknownShort3, in, version ); \
-NifStream( unknownShort4, in, version ); \
-NifStream( dimensions, in, version ); \
-NifStream( unknownFloat2, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_BOX_SHAPE_WRITE \
-bhkConvexShape::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownShort1, out, version ); \
-NifStream( unknownShort2, out, version ); \
-NifStream( unknownShort3, out, version ); \
-NifStream( unknownShort4, out, version ); \
-NifStream( dimensions, out, version ); \
-NifStream( unknownFloat2, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_BOX_SHAPE_STRING \
-stringstream out; \
-out << bhkConvexShape::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Short 1:  " << unknownShort1 << endl; \
-out << "Unknown Short 2:  " << unknownShort2 << endl; \
-out << "Unknown Short 3:  " << unknownShort3 << endl; \
-out << "Unknown Short 4:  " << unknownShort4 << endl; \
-out << "Dimensions:  " << dimensions << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_BOX_SHAPE_FIXLINKS \
-bhkConvexShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_BOX_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkConvexShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_CAPSULE_SHAPE_MEMBERS \
 float radius; \
@@ -2249,50 +1009,19 @@ float radius2; \
  : radius(0.0f), unknownShort1((ushort)0), unknownShort2((ushort)0), unknownShort3((ushort)0), unknownShort4((ushort)0), radius1(0.0f), radius2(0.0f) \
 
 #define BHK_CAPSULE_SHAPE_READ \
-bhkConvexShape::Read( in, link_stack, version, user_version ); \
-NifStream( radius, in, version ); \
-NifStream( unknownShort1, in, version ); \
-NifStream( unknownShort2, in, version ); \
-NifStream( unknownShort3, in, version ); \
-NifStream( unknownShort4, in, version ); \
-NifStream( firstPoint, in, version ); \
-NifStream( radius1, in, version ); \
-NifStream( secondPoint, in, version ); \
-NifStream( radius2, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_CAPSULE_SHAPE_WRITE \
-bhkConvexShape::Write( out, link_map, version, user_version ); \
-NifStream( radius, out, version ); \
-NifStream( unknownShort1, out, version ); \
-NifStream( unknownShort2, out, version ); \
-NifStream( unknownShort3, out, version ); \
-NifStream( unknownShort4, out, version ); \
-NifStream( firstPoint, out, version ); \
-NifStream( radius1, out, version ); \
-NifStream( secondPoint, out, version ); \
-NifStream( radius2, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_CAPSULE_SHAPE_STRING \
-stringstream out; \
-out << bhkConvexShape::asString(); \
-out << "Radius:  " << radius << endl; \
-out << "Unknown Short 1:  " << unknownShort1 << endl; \
-out << "Unknown Short 2:  " << unknownShort2 << endl; \
-out << "Unknown Short 3:  " << unknownShort3 << endl; \
-out << "Unknown Short 4:  " << unknownShort4 << endl; \
-out << "First Point:  " << firstPoint << endl; \
-out << "Radius 1:  " << radius1 << endl; \
-out << "Second Point:  " << secondPoint << endl; \
-out << "Radius 2:  " << radius2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_CAPSULE_SHAPE_FIXLINKS \
-bhkConvexShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_CAPSULE_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkConvexShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_COLLISION_OBJECT_MEMBERS \
 
@@ -2303,29 +1032,25 @@ return refs; \
 #define BHK_COLLISION_OBJECT_CONSTRUCT \
 
 #define BHK_COLLISION_OBJECT_READ \
-NiCollisionObject::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_COLLISION_OBJECT_WRITE \
-NiCollisionObject::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_COLLISION_OBJECT_STRING \
-stringstream out; \
-out << NiCollisionObject::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_COLLISION_OBJECT_FIXLINKS \
-NiCollisionObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_COLLISION_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiCollisionObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_CONVEX_VERTICES_SHAPE_MEMBERS \
-float unknownFloats1[7]; \
-uint num1; \
+array<float,7> unknownFloats1; \
+mutable uint num1; \
 vector<Float4 > unknownVectors1; \
-uint num2; \
+mutable uint num2; \
 vector<Float4 > unknownVectors2; \
 
 #define BHK_CONVEX_VERTICES_SHAPE_INCLUDE "bhkSphereRepShape.h" \
@@ -2336,73 +1061,22 @@ vector<Float4 > unknownVectors2; \
  : num1((uint)0), num2((uint)0) \
 
 #define BHK_CONVEX_VERTICES_SHAPE_READ \
-bhkSphereRepShape::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 7; i0++) { \
-	NifStream( unknownFloats1[i0], in, version ); \
-}; \
-NifStream( num1, in, version ); \
-unknownVectors1.resize(num1); \
-for (uint i0 = 0; i0 < unknownVectors1.size(); i0++) { \
-	NifStream( unknownVectors1[i0], in, version ); \
-}; \
-NifStream( num2, in, version ); \
-unknownVectors2.resize(num2); \
-for (uint i0 = 0; i0 < unknownVectors2.size(); i0++) { \
-	NifStream( unknownVectors2[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_CONVEX_VERTICES_SHAPE_WRITE \
-bhkSphereRepShape::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 7; i0++) { \
-	NifStream( unknownFloats1[i0], out, version ); \
-}; \
-NifStream( num1, out, version ); \
-for (uint i0 = 0; i0 < unknownVectors1.size(); i0++) { \
-	NifStream( unknownVectors1[i0], out, version ); \
-}; \
-NifStream( num2, out, version ); \
-for (uint i0 = 0; i0 < unknownVectors2.size(); i0++) { \
-	NifStream( unknownVectors2[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_CONVEX_VERTICES_SHAPE_STRING \
-stringstream out; \
-out << bhkSphereRepShape::asString(); \
-for (uint i0 = 0; i0 < 7; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats 1[" << i0 << "]:  " << unknownFloats1[i0] << endl; \
-}; \
-out << "Num 1:  " << num1 << endl; \
-for (uint i0 = 0; i0 < unknownVectors1.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Vectors 1[" << i0 << "]:  " << unknownVectors1[i0] << endl; \
-}; \
-out << "Num 2:  " << num2 << endl; \
-for (uint i0 = 0; i0 < unknownVectors2.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Vectors 2[" << i0 << "]:  " << unknownVectors2[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_CONVEX_VERTICES_SHAPE_FIXLINKS \
-bhkSphereRepShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_CONVEX_VERTICES_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkSphereRepShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_HINGE_CONSTRAINT_MEMBERS \
-float unknownFloats[5][4]; \
+array<array<float,5>,4> unknownFloats; \
 
 #define BHK_HINGE_CONSTRAINT_INCLUDE "AbhkConstraint.h" \
 
@@ -2411,42 +1085,19 @@ float unknownFloats[5][4]; \
 #define BHK_HINGE_CONSTRAINT_CONSTRUCT \
 
 #define BHK_HINGE_CONSTRAINT_READ \
-AbhkConstraint::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( unknownFloats[i0][i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_HINGE_CONSTRAINT_WRITE \
-AbhkConstraint::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( unknownFloats[i0][i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_HINGE_CONSTRAINT_STRING \
-stringstream out; \
-out << AbhkConstraint::asString(); \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats[" << i0 << "][" << i1 << "]:  " << unknownFloats[i0][i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_HINGE_CONSTRAINT_FIXLINKS \
-AbhkConstraint::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_HINGE_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkConstraint::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_LIMITED_HINGE_CONSTRAINT_MEMBERS \
 LimitedHingeDescriptor limitedHinge; \
@@ -2458,60 +1109,26 @@ LimitedHingeDescriptor limitedHinge; \
 #define BHK_LIMITED_HINGE_CONSTRAINT_CONSTRUCT \
 
 #define BHK_LIMITED_HINGE_CONSTRAINT_READ \
-AbhkConstraint::Read( in, link_stack, version, user_version ); \
-NifStream( limitedHinge.pivotA, in, version ); \
-NifStream( limitedHinge.axleA_, in, version ); \
-NifStream( limitedHinge.perp2axleina1, in, version ); \
-NifStream( limitedHinge.perp2axleina2, in, version ); \
-NifStream( limitedHinge.pivotB, in, version ); \
-NifStream( limitedHinge.axleB, in, version ); \
-NifStream( limitedHinge.unknownVector, in, version ); \
-NifStream( limitedHinge.minAngle, in, version ); \
-NifStream( limitedHinge.maxAngle, in, version ); \
-NifStream( limitedHinge.maxFriction, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_LIMITED_HINGE_CONSTRAINT_WRITE \
-AbhkConstraint::Write( out, link_map, version, user_version ); \
-NifStream( limitedHinge.pivotA, out, version ); \
-NifStream( limitedHinge.axleA_, out, version ); \
-NifStream( limitedHinge.perp2axleina1, out, version ); \
-NifStream( limitedHinge.perp2axleina2, out, version ); \
-NifStream( limitedHinge.pivotB, out, version ); \
-NifStream( limitedHinge.axleB, out, version ); \
-NifStream( limitedHinge.unknownVector, out, version ); \
-NifStream( limitedHinge.minAngle, out, version ); \
-NifStream( limitedHinge.maxAngle, out, version ); \
-NifStream( limitedHinge.maxFriction, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_LIMITED_HINGE_CONSTRAINT_STRING \
-stringstream out; \
-out << AbhkConstraint::asString(); \
-out << "Pivot A:  " << limitedHinge.pivotA << endl; \
-out << "Axle A ?:  " << limitedHinge.axleA_ << endl; \
-out << "Perp2AxleInA1:  " << limitedHinge.perp2axleina1 << endl; \
-out << "Perp2AxleInA2:  " << limitedHinge.perp2axleina2 << endl; \
-out << "Pivot B:  " << limitedHinge.pivotB << endl; \
-out << "Axle B:  " << limitedHinge.axleB << endl; \
-out << "Unknown Vector:  " << limitedHinge.unknownVector << endl; \
-out << "Min Angle:  " << limitedHinge.minAngle << endl; \
-out << "Max Angle:  " << limitedHinge.maxAngle << endl; \
-out << "Max Friction:  " << limitedHinge.maxFriction << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_LIMITED_HINGE_CONSTRAINT_FIXLINKS \
-AbhkConstraint::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_LIMITED_HINGE_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkConstraint::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_LIST_SHAPE_MEMBERS \
-uint numSubShapes; \
+mutable uint numSubShapes; \
 vector<Ref<bhkShape > > subShapes; \
 uint material; \
-float unknownFloats[6]; \
-uint numUnknownInts; \
+array<float,6> unknownFloats; \
+mutable uint numUnknownInts; \
 vector<uint > unknownInts; \
 
 #define BHK_LIST_SHAPE_INCLUDE "AbhkShapeCollection.h" \
@@ -2522,93 +1139,19 @@ vector<uint > unknownInts; \
  : numSubShapes((uint)0), material((uint)0), numUnknownInts((uint)0) \
 
 #define BHK_LIST_SHAPE_READ \
-uint block_num; \
-AbhkShapeCollection::Read( in, link_stack, version, user_version ); \
-NifStream( numSubShapes, in, version ); \
-subShapes.resize(numSubShapes); \
-for (uint i0 = 0; i0 < subShapes.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( material, in, version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
-NifStream( numUnknownInts, in, version ); \
-unknownInts.resize(numUnknownInts); \
-for (uint i0 = 0; i0 < unknownInts.size(); i0++) { \
-	NifStream( unknownInts[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_LIST_SHAPE_WRITE \
-AbhkShapeCollection::Write( out, link_map, version, user_version ); \
-NifStream( numSubShapes, out, version ); \
-for (uint i0 = 0; i0 < subShapes.size(); i0++) { \
-	if ( subShapes[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(subShapes[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-NifStream( material, out, version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
-NifStream( numUnknownInts, out, version ); \
-for (uint i0 = 0; i0 < unknownInts.size(); i0++) { \
-	NifStream( unknownInts[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_LIST_SHAPE_STRING \
-stringstream out; \
-out << AbhkShapeCollection::asString(); \
-out << "Num Sub Shapes:  " << numSubShapes << endl; \
-for (uint i0 = 0; i0 < subShapes.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Sub Shapes[" << i0 << "]:  " << subShapes[i0] << endl; \
-}; \
-out << "Material:  " << material << endl; \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-out << "Num Unknown Ints:  " << numUnknownInts << endl; \
-for (uint i0 = 0; i0 < unknownInts.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Ints[" << i0 << "]:  " << unknownInts[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_LIST_SHAPE_FIXLINKS \
-AbhkShapeCollection::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < subShapes.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		subShapes[i0] = DynamicCast<bhkShape>(objects[link_stack.front()]); \
-		if ( subShapes[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		subShapes[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_LIST_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkShapeCollection::GetRefs(); \
-for (uint i0 = 0; i0 < subShapes.size(); i0++) { \
-	if ( subShapes[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(subShapes[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_MALLEABLE_CONSTRAINT_MEMBERS \
 uint type; \
@@ -2629,160 +1172,26 @@ float damping; \
  : type((uint)0), unknownInt2((uint)0), unknownLink1(NULL), unknownLink2(NULL), unknownInt3((uint)0), tau(0.0f), damping(0.0f) \
 
 #define BHK_MALLEABLE_CONSTRAINT_READ \
-uint block_num; \
-AbhkConstraint::Read( in, link_stack, version, user_version ); \
-NifStream( type, in, version ); \
-NifStream( unknownInt2, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( unknownInt3, in, version ); \
-if ( (type == 7) ) { \
-	NifStream( ragdoll.pivotA, in, version ); \
-	NifStream( ragdoll.planeA, in, version ); \
-	NifStream( ragdoll.twistA, in, version ); \
-	NifStream( ragdoll.pivotB, in, version ); \
-	NifStream( ragdoll.planeB, in, version ); \
-	NifStream( ragdoll.twistB, in, version ); \
-	NifStream( ragdoll.coneMinAngle, in, version ); \
-	NifStream( ragdoll.planeMinAngle, in, version ); \
-	NifStream( ragdoll.planeMaxAngle, in, version ); \
-	NifStream( ragdoll.twistMinAngle, in, version ); \
-	NifStream( ragdoll.twistMaxAngle, in, version ); \
-	NifStream( ragdoll.maxFriction, in, version ); \
-}; \
-if ( (type == 2) ) { \
-	NifStream( limitedHinge.pivotA, in, version ); \
-	NifStream( limitedHinge.axleA_, in, version ); \
-	NifStream( limitedHinge.perp2axleina1, in, version ); \
-	NifStream( limitedHinge.perp2axleina2, in, version ); \
-	NifStream( limitedHinge.pivotB, in, version ); \
-	NifStream( limitedHinge.axleB, in, version ); \
-	NifStream( limitedHinge.unknownVector, in, version ); \
-	NifStream( limitedHinge.minAngle, in, version ); \
-	NifStream( limitedHinge.maxAngle, in, version ); \
-	NifStream( limitedHinge.maxFriction, in, version ); \
-}; \
-NifStream( tau, in, version ); \
-NifStream( damping, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_MALLEABLE_CONSTRAINT_WRITE \
-AbhkConstraint::Write( out, link_map, version, user_version ); \
-NifStream( type, out, version ); \
-NifStream( unknownInt2, out, version ); \
-if ( unknownLink1 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink1)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( unknownLink2 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink2)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( unknownInt3, out, version ); \
-if ( (type == 7) ) { \
-	NifStream( ragdoll.pivotA, out, version ); \
-	NifStream( ragdoll.planeA, out, version ); \
-	NifStream( ragdoll.twistA, out, version ); \
-	NifStream( ragdoll.pivotB, out, version ); \
-	NifStream( ragdoll.planeB, out, version ); \
-	NifStream( ragdoll.twistB, out, version ); \
-	NifStream( ragdoll.coneMinAngle, out, version ); \
-	NifStream( ragdoll.planeMinAngle, out, version ); \
-	NifStream( ragdoll.planeMaxAngle, out, version ); \
-	NifStream( ragdoll.twistMinAngle, out, version ); \
-	NifStream( ragdoll.twistMaxAngle, out, version ); \
-	NifStream( ragdoll.maxFriction, out, version ); \
-}; \
-if ( (type == 2) ) { \
-	NifStream( limitedHinge.pivotA, out, version ); \
-	NifStream( limitedHinge.axleA_, out, version ); \
-	NifStream( limitedHinge.perp2axleina1, out, version ); \
-	NifStream( limitedHinge.perp2axleina2, out, version ); \
-	NifStream( limitedHinge.pivotB, out, version ); \
-	NifStream( limitedHinge.axleB, out, version ); \
-	NifStream( limitedHinge.unknownVector, out, version ); \
-	NifStream( limitedHinge.minAngle, out, version ); \
-	NifStream( limitedHinge.maxAngle, out, version ); \
-	NifStream( limitedHinge.maxFriction, out, version ); \
-}; \
-NifStream( tau, out, version ); \
-NifStream( damping, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_MALLEABLE_CONSTRAINT_STRING \
-stringstream out; \
-out << AbhkConstraint::asString(); \
-out << "Type:  " << type << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-out << "Unknown Link 1:  " << unknownLink1 << endl; \
-out << "Unknown Link 2:  " << unknownLink2 << endl; \
-out << "Unknown Int 3:  " << unknownInt3 << endl; \
-if ( (type == 7) ) { \
-	out << "  Pivot A:  " << ragdoll.pivotA << endl; \
-	out << "  Plane A:  " << ragdoll.planeA << endl; \
-	out << "  Twist A:  " << ragdoll.twistA << endl; \
-	out << "  Pivot B:  " << ragdoll.pivotB << endl; \
-	out << "  Plane B:  " << ragdoll.planeB << endl; \
-	out << "  Twist B:  " << ragdoll.twistB << endl; \
-	out << "  Cone Min Angle:  " << ragdoll.coneMinAngle << endl; \
-	out << "  Plane Min Angle:  " << ragdoll.planeMinAngle << endl; \
-	out << "  Plane Max Angle:  " << ragdoll.planeMaxAngle << endl; \
-	out << "  Twist Min Angle:  " << ragdoll.twistMinAngle << endl; \
-	out << "  Twist Max Angle:  " << ragdoll.twistMaxAngle << endl; \
-	out << "  Max Friction:  " << ragdoll.maxFriction << endl; \
-}; \
-if ( (type == 2) ) { \
-	out << "  Pivot A:  " << limitedHinge.pivotA << endl; \
-	out << "  Axle A ?:  " << limitedHinge.axleA_ << endl; \
-	out << "  Perp2AxleInA1:  " << limitedHinge.perp2axleina1 << endl; \
-	out << "  Perp2AxleInA2:  " << limitedHinge.perp2axleina2 << endl; \
-	out << "  Pivot B:  " << limitedHinge.pivotB << endl; \
-	out << "  Axle B:  " << limitedHinge.axleB << endl; \
-	out << "  Unknown Vector:  " << limitedHinge.unknownVector << endl; \
-	out << "  Min Angle:  " << limitedHinge.minAngle << endl; \
-	out << "  Max Angle:  " << limitedHinge.maxAngle << endl; \
-	out << "  Max Friction:  " << limitedHinge.maxFriction << endl; \
-}; \
-out << "Tau:  " << tau << endl; \
-out << "Damping:  " << damping << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_MALLEABLE_CONSTRAINT_FIXLINKS \
-AbhkConstraint::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink1 = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( unknownLink1 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink1 = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink2 = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( unknownLink2 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink2 = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_MALLEABLE_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkConstraint::GetRefs(); \
-if ( unknownLink1 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink1)); \
-if ( unknownLink2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink2)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_MOPP_BV_TREE_SHAPE_MEMBERS \
 Ref<bhkShape > shape; \
 uint material; \
-byte unknownBytes1[8]; \
+array<byte,8> unknownBytes1; \
 float unknownFloat; \
-uint numUnknownBytes2; \
+mutable uint numUnknownBytes2; \
 vector<byte > unknownBytes2; \
 Vector3 unknownVector; \
 float unknownFloat2; \
@@ -2795,91 +1204,26 @@ float unknownFloat2; \
  : shape(NULL), material((uint)0), unknownFloat(0.0f), numUnknownBytes2((uint)0), unknownFloat2(0.0f) \
 
 #define BHK_MOPP_BV_TREE_SHAPE_READ \
-uint block_num; \
-bhkShape::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( material, in, version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownBytes1[i0], in, version ); \
-}; \
-NifStream( unknownFloat, in, version ); \
-NifStream( numUnknownBytes2, in, version ); \
-unknownBytes2.resize(numUnknownBytes2); \
-for (uint i0 = 0; i0 < unknownBytes2.size(); i0++) { \
-	NifStream( unknownBytes2[i0], in, version ); \
-}; \
-NifStream( unknownVector, in, version ); \
-NifStream( unknownFloat2, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_MOPP_BV_TREE_SHAPE_WRITE \
-bhkShape::Write( out, link_map, version, user_version ); \
-if ( shape != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(shape)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( material, out, version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownBytes1[i0], out, version ); \
-}; \
-NifStream( unknownFloat, out, version ); \
-NifStream( numUnknownBytes2, out, version ); \
-for (uint i0 = 0; i0 < unknownBytes2.size(); i0++) { \
-	NifStream( unknownBytes2[i0], out, version ); \
-}; \
-NifStream( unknownVector, out, version ); \
-NifStream( unknownFloat2, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_MOPP_BV_TREE_SHAPE_STRING \
-stringstream out; \
-out << bhkShape::asString(); \
-out << "Shape:  " << shape << endl; \
-out << "Material:  " << material << endl; \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Bytes 1[" << i0 << "]:  " << unknownBytes1[i0] << endl; \
-}; \
-out << "Unknown Float:  " << unknownFloat << endl; \
-out << "Num Unknown Bytes 2:  " << numUnknownBytes2 << endl; \
-for (uint i0 = 0; i0 < unknownBytes2.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Bytes 2[" << i0 << "]:  " << unknownBytes2[i0] << endl; \
-}; \
-out << "Unknown Vector:  " << unknownVector << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_MOPP_BV_TREE_SHAPE_FIXLINKS \
-bhkShape::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	shape = DynamicCast<bhkShape>(objects[link_stack.front()]); \
-	if ( shape == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	shape = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_MOPP_BV_TREE_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkShape::GetRefs(); \
-if ( shape != NULL ) \
-	refs.push_back(StaticCast<NiObject>(shape)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_MULTI_SPHERE_SHAPE_MEMBERS \
 float unknownFloat1; \
 float unknownFloat2; \
 float unknownFloat3; \
 uint unknownInt2; \
-float unknownFloats[8]; \
+array<float,8> unknownFloats; \
 
 #define BHK_MULTI_SPHERE_SHAPE_INCLUDE "bhkSphereRepShape.h" \
 
@@ -2889,57 +1233,28 @@ float unknownFloats[8]; \
  : unknownFloat1(0.0f), unknownFloat2(0.0f), unknownFloat3(0.0f), unknownInt2((uint)0) \
 
 #define BHK_MULTI_SPHERE_SHAPE_READ \
-bhkSphereRepShape::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownFloat2, in, version ); \
-NifStream( unknownFloat3, in, version ); \
-NifStream( unknownInt2, in, version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_MULTI_SPHERE_SHAPE_WRITE \
-bhkSphereRepShape::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownFloat2, out, version ); \
-NifStream( unknownFloat3, out, version ); \
-NifStream( unknownInt2, out, version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_MULTI_SPHERE_SHAPE_STRING \
-stringstream out; \
-out << bhkSphereRepShape::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Float 3:  " << unknownFloat3 << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_MULTI_SPHERE_SHAPE_FIXLINKS \
-bhkSphereRepShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_MULTI_SPHERE_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkSphereRepShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_MEMBERS \
-float unknownFloats1[2]; \
-uint unknownInts1[5]; \
-float unknownFloats2[3]; \
+array<float,2> unknownFloats1; \
+array<uint,5> unknownInts1; \
+array<float,3> unknownFloats2; \
 uint unknownInt2; \
-uint numStripsData; \
+mutable uint numStripsData; \
 vector<Ref<NiTriStripsData > > stripsData; \
-uint numUnknownInts3; \
+mutable uint numUnknownInts3; \
 vector<uint > unknownInts3; \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_INCLUDE "bhkSphereRepShape.h" \
@@ -2950,126 +1265,26 @@ vector<uint > unknownInts3; \
  : unknownInt2((uint)0), numStripsData((uint)0), numUnknownInts3((uint)0) \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_READ \
-uint block_num; \
-bhkSphereRepShape::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	NifStream( unknownFloats1[i0], in, version ); \
-}; \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	NifStream( unknownInts1[i0], in, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats2[i0], in, version ); \
-}; \
-NifStream( unknownInt2, in, version ); \
-NifStream( numStripsData, in, version ); \
-stripsData.resize(numStripsData); \
-for (uint i0 = 0; i0 < stripsData.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( numUnknownInts3, in, version ); \
-unknownInts3.resize(numUnknownInts3); \
-for (uint i0 = 0; i0 < unknownInts3.size(); i0++) { \
-	NifStream( unknownInts3[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_WRITE \
-bhkSphereRepShape::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	NifStream( unknownFloats1[i0], out, version ); \
-}; \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	NifStream( unknownInts1[i0], out, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats2[i0], out, version ); \
-}; \
-NifStream( unknownInt2, out, version ); \
-NifStream( numStripsData, out, version ); \
-for (uint i0 = 0; i0 < stripsData.size(); i0++) { \
-	if ( stripsData[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(stripsData[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-NifStream( numUnknownInts3, out, version ); \
-for (uint i0 = 0; i0 < unknownInts3.size(); i0++) { \
-	NifStream( unknownInts3[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_STRING \
-stringstream out; \
-out << bhkSphereRepShape::asString(); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats 1[" << i0 << "]:  " << unknownFloats1[i0] << endl; \
-}; \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Ints 1[" << i0 << "]:  " << unknownInts1[i0] << endl; \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats 2[" << i0 << "]:  " << unknownFloats2[i0] << endl; \
-}; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-out << "Num Strips Data:  " << numStripsData << endl; \
-for (uint i0 = 0; i0 < stripsData.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Strips Data[" << i0 << "]:  " << stripsData[i0] << endl; \
-}; \
-out << "Num Unknown Ints 3:  " << numUnknownInts3 << endl; \
-for (uint i0 = 0; i0 < unknownInts3.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Ints 3[" << i0 << "]:  " << unknownInts3[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_FIXLINKS \
-bhkSphereRepShape::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < stripsData.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		stripsData[i0] = DynamicCast<NiTriStripsData>(objects[link_stack.front()]); \
-		if ( stripsData[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		stripsData[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_NI_TRI_STRIPS_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkSphereRepShape::GetRefs(); \
-for (uint i0 = 0; i0 < stripsData.size(); i0++) { \
-	if ( stripsData[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(stripsData[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_MEMBERS \
-ushort numSubparts; \
+mutable ushort numSubparts; \
 vector< array<uint,3> > subparts; \
-float unknownFloats[9]; \
+array<float,9> unknownFloats; \
 float scale; \
-float unknownFloats2[3]; \
+array<float,3> unknownFloats2; \
 Ref<hkPackedNiTriStripsData > data; \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_INCLUDE "AbhkShapeCollection.h" \
@@ -3080,98 +1295,23 @@ Ref<hkPackedNiTriStripsData > data; \
  : numSubparts((ushort)0), scale(1.0f), data(NULL) \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_READ \
-uint block_num; \
-AbhkShapeCollection::Read( in, link_stack, version, user_version ); \
-NifStream( numSubparts, in, version ); \
-subparts.resize(numSubparts); \
-for (uint i0 = 0; i0 < subparts.size(); i0++) { \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		NifStream( subparts[i0][i1], in, version ); \
-	}; \
-}; \
-for (uint i0 = 0; i0 < 9; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
-NifStream( scale, in, version ); \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats2[i0], in, version ); \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_WRITE \
-AbhkShapeCollection::Write( out, link_map, version, user_version ); \
-NifStream( numSubparts, out, version ); \
-for (uint i0 = 0; i0 < subparts.size(); i0++) { \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		NifStream( subparts[i0][i1], out, version ); \
-	}; \
-}; \
-for (uint i0 = 0; i0 < 9; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
-NifStream( scale, out, version ); \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats2[i0], out, version ); \
-}; \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_STRING \
-stringstream out; \
-out << AbhkShapeCollection::asString(); \
-out << "Num Subparts:  " << numSubparts << endl; \
-for (uint i0 = 0; i0 < subparts.size(); i0++) { \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Subparts[" << i0 << "][" << i1 << "]:  " << subparts[i0][i1] << endl; \
-	}; \
-}; \
-for (uint i0 = 0; i0 < 9; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-out << "Scale:  " << scale << endl; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats 2[" << i0 << "]:  " << unknownFloats2[i0] << endl; \
-}; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_FIXLINKS \
-AbhkShapeCollection::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<hkPackedNiTriStripsData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_PACKED_NI_TRI_STRIPS_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkShapeCollection::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_PRISMATIC_CONSTRAINT_MEMBERS \
-Float4 unknownVectors[8]; \
-float unknownFloats2[3]; \
+array<Float4,8> unknownVectors; \
+array<float,3> unknownFloats2; \
 
 #define BHK_PRISMATIC_CONSTRAINT_INCLUDE "AbhkConstraint.h" \
 
@@ -3180,49 +1320,19 @@ float unknownFloats2[3]; \
 #define BHK_PRISMATIC_CONSTRAINT_CONSTRUCT \
 
 #define BHK_PRISMATIC_CONSTRAINT_READ \
-AbhkConstraint::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownVectors[i0], in, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats2[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_PRISMATIC_CONSTRAINT_WRITE \
-AbhkConstraint::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownVectors[i0], out, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats2[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_PRISMATIC_CONSTRAINT_STRING \
-stringstream out; \
-out << AbhkConstraint::asString(); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Vectors[" << i0 << "]:  " << unknownVectors[i0] << endl; \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats 2[" << i0 << "]:  " << unknownFloats2[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_PRISMATIC_CONSTRAINT_FIXLINKS \
-AbhkConstraint::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_PRISMATIC_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkConstraint::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_RAGDOLL_CONSTRAINT_MEMBERS \
 
@@ -3233,29 +1343,25 @@ return refs; \
 #define BHK_RAGDOLL_CONSTRAINT_CONSTRUCT \
 
 #define BHK_RAGDOLL_CONSTRAINT_READ \
-AbhkRagdollConstraint::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_RAGDOLL_CONSTRAINT_WRITE \
-AbhkRagdollConstraint::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_RAGDOLL_CONSTRAINT_STRING \
-stringstream out; \
-out << AbhkRagdollConstraint::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_RAGDOLL_CONSTRAINT_FIXLINKS \
-AbhkRagdollConstraint::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_RAGDOLL_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkRagdollConstraint::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_RIGID_BODY_MEMBERS \
-float unknownFloats1[5]; \
-ushort unknownShorts1[4]; \
+array<float,5> unknownFloats1; \
+array<ushort,4> unknownShorts1; \
 uint layerCopy_; \
-ushort unknownShorts2[6]; \
+array<ushort,6> unknownShorts2; \
 Vector3 translation; \
 float unknownFloat00; \
 QuaternionXYZW rotation; \
@@ -3263,7 +1369,7 @@ Vector3 linearVelocity; \
 float unknownFloat01; \
 Vector3 angularVelocity; \
 float unknownFloat02; \
-float transform_[12]; \
+array<float,12> transform_; \
 Vector3 center; \
 float unknownFloat03; \
 float mass; \
@@ -3281,7 +1387,7 @@ byte qualityType; \
 uint unknownInt6; \
 uint unknownInt7; \
 uint unknownInt8; \
-uint numConstraints; \
+mutable uint numConstraints; \
 vector<Ref<AbhkConstraint > > constraints; \
 
 #define BHK_RIGID_BODY_INCLUDE "bhkEntity.h" \
@@ -3292,198 +1398,19 @@ vector<Ref<AbhkConstraint > > constraints; \
  : layerCopy_((uint)0), unknownFloat00(0.0f), unknownFloat01(0.0f), unknownFloat02(0.0f), unknownFloat03(0.0f), mass(0.0f), linearDamping(0.0f), angularDamping(0.0f), friction(0.0f), restitution(0.0f), maxLinearVelocity(0.0f), maxAngularVelocity(31.415926535f), penDepth(0.0f), motionSystem_((byte)0), unknownByte1((byte)0), unknownByte2((byte)0), qualityType((byte)0), unknownInt6((uint)0), unknownInt7((uint)0), unknownInt8((uint)0), numConstraints((uint)0) \
 
 #define BHK_RIGID_BODY_READ \
-uint block_num; \
-bhkEntity::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	NifStream( unknownFloats1[i0], in, version ); \
-}; \
-for (uint i0 = 0; i0 < 4; i0++) { \
-	NifStream( unknownShorts1[i0], in, version ); \
-}; \
-NifStream( layerCopy_, in, version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownShorts2[i0], in, version ); \
-}; \
-NifStream( translation, in, version ); \
-NifStream( unknownFloat00, in, version ); \
-NifStream( rotation.x, in, version ); \
-NifStream( rotation.y, in, version ); \
-NifStream( rotation.z, in, version ); \
-NifStream( rotation.w, in, version ); \
-NifStream( linearVelocity, in, version ); \
-NifStream( unknownFloat01, in, version ); \
-NifStream( angularVelocity, in, version ); \
-NifStream( unknownFloat02, in, version ); \
-for (uint i0 = 0; i0 < 12; i0++) { \
-	NifStream( transform_[i0], in, version ); \
-}; \
-NifStream( center, in, version ); \
-NifStream( unknownFloat03, in, version ); \
-NifStream( mass, in, version ); \
-NifStream( linearDamping, in, version ); \
-NifStream( angularDamping, in, version ); \
-NifStream( friction, in, version ); \
-NifStream( restitution, in, version ); \
-NifStream( maxLinearVelocity, in, version ); \
-NifStream( maxAngularVelocity, in, version ); \
-NifStream( penDepth, in, version ); \
-NifStream( motionSystem_, in, version ); \
-NifStream( unknownByte1, in, version ); \
-NifStream( unknownByte2, in, version ); \
-NifStream( qualityType, in, version ); \
-NifStream( unknownInt6, in, version ); \
-NifStream( unknownInt7, in, version ); \
-NifStream( unknownInt8, in, version ); \
-NifStream( numConstraints, in, version ); \
-constraints.resize(numConstraints); \
-for (uint i0 = 0; i0 < constraints.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( unknownInt6, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_RIGID_BODY_WRITE \
-bhkEntity::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	NifStream( unknownFloats1[i0], out, version ); \
-}; \
-for (uint i0 = 0; i0 < 4; i0++) { \
-	NifStream( unknownShorts1[i0], out, version ); \
-}; \
-NifStream( layerCopy_, out, version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownShorts2[i0], out, version ); \
-}; \
-NifStream( translation, out, version ); \
-NifStream( unknownFloat00, out, version ); \
-NifStream( rotation.x, out, version ); \
-NifStream( rotation.y, out, version ); \
-NifStream( rotation.z, out, version ); \
-NifStream( rotation.w, out, version ); \
-NifStream( linearVelocity, out, version ); \
-NifStream( unknownFloat01, out, version ); \
-NifStream( angularVelocity, out, version ); \
-NifStream( unknownFloat02, out, version ); \
-for (uint i0 = 0; i0 < 12; i0++) { \
-	NifStream( transform_[i0], out, version ); \
-}; \
-NifStream( center, out, version ); \
-NifStream( unknownFloat03, out, version ); \
-NifStream( mass, out, version ); \
-NifStream( linearDamping, out, version ); \
-NifStream( angularDamping, out, version ); \
-NifStream( friction, out, version ); \
-NifStream( restitution, out, version ); \
-NifStream( maxLinearVelocity, out, version ); \
-NifStream( maxAngularVelocity, out, version ); \
-NifStream( penDepth, out, version ); \
-NifStream( motionSystem_, out, version ); \
-NifStream( unknownByte1, out, version ); \
-NifStream( unknownByte2, out, version ); \
-NifStream( qualityType, out, version ); \
-NifStream( unknownInt6, out, version ); \
-NifStream( unknownInt7, out, version ); \
-NifStream( unknownInt8, out, version ); \
-NifStream( numConstraints, out, version ); \
-for (uint i0 = 0; i0 < constraints.size(); i0++) { \
-	if ( constraints[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(constraints[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-NifStream( unknownInt6, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_RIGID_BODY_STRING \
-stringstream out; \
-out << bhkEntity::asString(); \
-for (uint i0 = 0; i0 < 5; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats 1[" << i0 << "]:  " << unknownFloats1[i0] << endl; \
-}; \
-for (uint i0 = 0; i0 < 4; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Shorts 1[" << i0 << "]:  " << unknownShorts1[i0] << endl; \
-}; \
-out << "Layer Copy?:  " << layerCopy_ << endl; \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Shorts 2[" << i0 << "]:  " << unknownShorts2[i0] << endl; \
-}; \
-out << "Translation:  " << translation << endl; \
-out << "Unknown Float 00:  " << unknownFloat00 << endl; \
-out << "x:  " << rotation.x << endl; \
-out << "y:  " << rotation.y << endl; \
-out << "z:  " << rotation.z << endl; \
-out << "w:  " << rotation.w << endl; \
-out << "Linear Velocity:  " << linearVelocity << endl; \
-out << "Unknown Float 01:  " << unknownFloat01 << endl; \
-out << "Angular Velocity:  " << angularVelocity << endl; \
-out << "Unknown Float 02:  " << unknownFloat02 << endl; \
-for (uint i0 = 0; i0 < 12; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Transform?[" << i0 << "]:  " << transform_[i0] << endl; \
-}; \
-out << "Center:  " << center << endl; \
-out << "Unknown Float 03:  " << unknownFloat03 << endl; \
-out << "Mass:  " << mass << endl; \
-out << "Linear Damping:  " << linearDamping << endl; \
-out << "Angular Damping:  " << angularDamping << endl; \
-out << "Friction:  " << friction << endl; \
-out << "Restitution:  " << restitution << endl; \
-out << "Max Linear Velocity:  " << maxLinearVelocity << endl; \
-out << "Max Angular Velocity:  " << maxAngularVelocity << endl; \
-out << "Pen Depth:  " << penDepth << endl; \
-out << "Motion System?:  " << motionSystem_ << endl; \
-out << "Unknown Byte 1:  " << unknownByte1 << endl; \
-out << "Unknown Byte 2:  " << unknownByte2 << endl; \
-out << "Quality Type:  " << qualityType << endl; \
-out << "Unknown Int 6:  " << unknownInt6 << endl; \
-out << "Unknown Int 7:  " << unknownInt7 << endl; \
-out << "Unknown Int 8:  " << unknownInt8 << endl; \
-out << "Num Constraints:  " << numConstraints << endl; \
-for (uint i0 = 0; i0 < constraints.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Constraints[" << i0 << "]:  " << constraints[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_RIGID_BODY_FIXLINKS \
-bhkEntity::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < constraints.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		constraints[i0] = DynamicCast<AbhkConstraint>(objects[link_stack.front()]); \
-		if ( constraints[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		constraints[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_RIGID_BODY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkEntity::GetRefs(); \
-for (uint i0 = 0; i0 < constraints.size(); i0++) { \
-	if ( constraints[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(constraints[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_RIGID_BODY_T_MEMBERS \
 
@@ -3494,27 +1421,23 @@ return refs; \
 #define BHK_RIGID_BODY_T_CONSTRUCT \
 
 #define BHK_RIGID_BODY_T_READ \
-bhkRigidBody::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_RIGID_BODY_T_WRITE \
-bhkRigidBody::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_RIGID_BODY_T_STRING \
-stringstream out; \
-out << bhkRigidBody::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_RIGID_BODY_T_FIXLINKS \
-bhkRigidBody::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_RIGID_BODY_T_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkRigidBody::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_MEMBERS \
-float unkownFloats[7]; \
-float unknownFloats2[3][5]; \
+array<float,7> unkownFloats; \
+array<array<float,3>,5> unknownFloats2; \
 float unknownFloat; \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_INCLUDE "bhkEntity.h" \
@@ -3525,58 +1448,19 @@ float unknownFloat; \
  : unknownFloat(0.0f) \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_READ \
-bhkEntity::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 7; i0++) { \
-	NifStream( unkownFloats[i0], in, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	for (uint i1 = 0; i1 < 5; i1++) { \
-		NifStream( unknownFloats2[i0][i1], in, version ); \
-	}; \
-}; \
-NifStream( unknownFloat, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_WRITE \
-bhkEntity::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 7; i0++) { \
-	NifStream( unkownFloats[i0], out, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	for (uint i1 = 0; i1 < 5; i1++) { \
-		NifStream( unknownFloats2[i0][i1], out, version ); \
-	}; \
-}; \
-NifStream( unknownFloat, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_STRING \
-stringstream out; \
-out << bhkEntity::asString(); \
-for (uint i0 = 0; i0 < 7; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unkown Floats[" << i0 << "]:  " << unkownFloats[i0] << endl; \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	for (uint i1 = 0; i1 < 5; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats 2[" << i0 << "][" << i1 << "]:  " << unknownFloats2[i0][i1] << endl; \
-	}; \
-}; \
-out << "Unknown Float:  " << unknownFloat << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_FIXLINKS \
-bhkEntity::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_SIMPLE_SHAPE_PHANTOM_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkEntity::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_S_P_COLLISION_OBJECT_MEMBERS \
 
@@ -3587,23 +1471,19 @@ return refs; \
 #define BHK_S_P_COLLISION_OBJECT_CONSTRUCT \
 
 #define BHK_S_P_COLLISION_OBJECT_READ \
-NiCollisionObject::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_S_P_COLLISION_OBJECT_WRITE \
-NiCollisionObject::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_S_P_COLLISION_OBJECT_STRING \
-stringstream out; \
-out << NiCollisionObject::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_S_P_COLLISION_OBJECT_FIXLINKS \
-NiCollisionObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_S_P_COLLISION_OBJECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiCollisionObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_SPHERE_SHAPE_MEMBERS \
 float radius; \
@@ -3616,29 +1496,22 @@ float radius; \
  : radius(0.0f) \
 
 #define BHK_SPHERE_SHAPE_READ \
-bhkConvexShape::Read( in, link_stack, version, user_version ); \
-NifStream( radius, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_SPHERE_SHAPE_WRITE \
-bhkConvexShape::Write( out, link_map, version, user_version ); \
-NifStream( radius, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_SPHERE_SHAPE_STRING \
-stringstream out; \
-out << bhkConvexShape::asString(); \
-out << "Radius:  " << radius << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_SPHERE_SHAPE_FIXLINKS \
-bhkConvexShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_SPHERE_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkConvexShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_MEMBERS \
-float unknownFloats[2][4]; \
+array<array<float,2>,4> unknownFloats; \
 float unknownFloat; \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_INCLUDE "AbhkConstraint.h" \
@@ -3649,45 +1522,19 @@ float unknownFloat; \
  : unknownFloat(0.0f) \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_READ \
-AbhkConstraint::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( unknownFloats[i0][i1], in, version ); \
-	}; \
-}; \
-NifStream( unknownFloat, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_WRITE \
-AbhkConstraint::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( unknownFloats[i0][i1], out, version ); \
-	}; \
-}; \
-NifStream( unknownFloat, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_STRING \
-stringstream out; \
-out << AbhkConstraint::asString(); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats[" << i0 << "][" << i1 << "]:  " << unknownFloats[i0][i1] << endl; \
-	}; \
-}; \
-out << "Unknown Float:  " << unknownFloat << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_FIXLINKS \
-AbhkConstraint::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_STIFF_SPRING_CONSTRAINT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkConstraint::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_TRANSFORM_SHAPE_MEMBERS \
 float unknownFloat1; \
@@ -3703,35 +1550,19 @@ Matrix44 transform; \
  : unknownFloat1(0.0f), unknownFloat2(0.0f), unknownFloat3(0.0f) \
 
 #define BHK_TRANSFORM_SHAPE_READ \
-bhkEntity::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownFloat2, in, version ); \
-NifStream( unknownFloat3, in, version ); \
-NifStream( transform, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_TRANSFORM_SHAPE_WRITE \
-bhkEntity::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownFloat2, out, version ); \
-NifStream( unknownFloat3, out, version ); \
-NifStream( transform, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_TRANSFORM_SHAPE_STRING \
-stringstream out; \
-out << bhkEntity::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Float 3:  " << unknownFloat3 << endl; \
-out << "Transform:  " << transform << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_TRANSFORM_SHAPE_FIXLINKS \
-bhkEntity::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_TRANSFORM_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkEntity::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define BHK_CONVEX_TRANSFORM_SHAPE_MEMBERS \
 
@@ -3742,26 +1573,22 @@ return refs; \
 #define BHK_CONVEX_TRANSFORM_SHAPE_CONSTRUCT \
 
 #define BHK_CONVEX_TRANSFORM_SHAPE_READ \
-bhkTransformShape::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define BHK_CONVEX_TRANSFORM_SHAPE_WRITE \
-bhkTransformShape::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define BHK_CONVEX_TRANSFORM_SHAPE_STRING \
-stringstream out; \
-out << bhkTransformShape::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define BHK_CONVEX_TRANSFORM_SHAPE_FIXLINKS \
-bhkTransformShape::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define BHK_CONVEX_TRANSFORM_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = bhkTransformShape::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define B_S_BOUND_MEMBERS \
-float unknownFloats[6]; \
+array<float,6> unknownFloats; \
 
 #define B_S_BOUND_INCLUDE "NiExtraData.h" \
 
@@ -3770,39 +1597,22 @@ float unknownFloats[6]; \
 #define B_S_BOUND_CONSTRUCT \
 
 #define B_S_BOUND_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define B_S_BOUND_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define B_S_BOUND_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define B_S_BOUND_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define B_S_BOUND_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define B_S_FURNITURE_MARKER_MEMBERS \
-uint numPositions; \
+mutable uint numPositions; \
 vector<FurniturePosition > positions; \
 
 #define B_S_FURNITURE_MARKER_INCLUDE "NiExtraData.h" \
@@ -3813,45 +1623,19 @@ vector<FurniturePosition > positions; \
  : numPositions((uint)0) \
 
 #define B_S_FURNITURE_MARKER_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( numPositions, in, version ); \
-positions.resize(numPositions); \
-for (uint i0 = 0; i0 < positions.size(); i0++) { \
-	NifStream( positions[i0].offset, in, version ); \
-	NifStream( positions[i0].orientation, in, version ); \
-	NifStream( positions[i0].positionRef1, in, version ); \
-	NifStream( positions[i0].positionRef2, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define B_S_FURNITURE_MARKER_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( numPositions, out, version ); \
-for (uint i0 = 0; i0 < positions.size(); i0++) { \
-	NifStream( positions[i0].offset, out, version ); \
-	NifStream( positions[i0].orientation, out, version ); \
-	NifStream( positions[i0].positionRef1, out, version ); \
-	NifStream( positions[i0].positionRef2, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define B_S_FURNITURE_MARKER_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Num Positions:  " << numPositions << endl; \
-for (uint i0 = 0; i0 < positions.size(); i0++) { \
-	out << "  Offset:  " << positions[i0].offset << endl; \
-	out << "  Orientation:  " << positions[i0].orientation << endl; \
-	out << "  Position Ref 1:  " << positions[i0].positionRef1 << endl; \
-	out << "  Position Ref 2:  " << positions[i0].positionRef2 << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define B_S_FURNITURE_MARKER_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define B_S_FURNITURE_MARKER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define B_S_PARENT_VELOCITY_MODIFIER_MEMBERS \
 float unknownFloat; \
@@ -3864,26 +1648,19 @@ float unknownFloat; \
  : unknownFloat(0.0f) \
 
 #define B_S_PARENT_VELOCITY_MODIFIER_READ \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define B_S_PARENT_VELOCITY_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define B_S_PARENT_VELOCITY_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Unknown Float:  " << unknownFloat << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define B_S_PARENT_VELOCITY_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define B_S_PARENT_VELOCITY_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define B_S_P_SYS_ARRAY_EMITTER_MEMBERS \
 
@@ -3894,23 +1671,19 @@ return refs; \
 #define B_S_P_SYS_ARRAY_EMITTER_CONSTRUCT \
 
 #define B_S_P_SYS_ARRAY_EMITTER_READ \
-NiPSysVolumeEmitter::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define B_S_P_SYS_ARRAY_EMITTER_WRITE \
-NiPSysVolumeEmitter::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define B_S_P_SYS_ARRAY_EMITTER_STRING \
-stringstream out; \
-out << NiPSysVolumeEmitter::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define B_S_P_SYS_ARRAY_EMITTER_FIXLINKS \
-NiPSysVolumeEmitter::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define B_S_P_SYS_ARRAY_EMITTER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysVolumeEmitter::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define B_S_X_FLAGS_MEMBERS \
 uint flags; \
@@ -3923,31 +1696,24 @@ uint flags; \
  : flags((uint)0) \
 
 #define B_S_X_FLAGS_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define B_S_X_FLAGS_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define B_S_X_FLAGS_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Flags:  " << flags << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define B_S_X_FLAGS_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define B_S_X_FLAGS_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define HK_PACKED_NI_TRI_STRIPS_DATA_MEMBERS \
-uint numTriangles; \
+mutable uint numTriangles; \
 vector<hkTriangle > triangles; \
-uint numVertices; \
+mutable uint numVertices; \
 vector<Vector3 > vertices; \
 
 #define HK_PACKED_NI_TRI_STRIPS_DATA_INCLUDE "AbhkShapeCollection.h" \
@@ -3958,59 +1724,19 @@ vector<Vector3 > vertices; \
  : numTriangles((uint)0), numVertices((uint)0) \
 
 #define HK_PACKED_NI_TRI_STRIPS_DATA_READ \
-AbhkShapeCollection::Read( in, link_stack, version, user_version ); \
-NifStream( numTriangles, in, version ); \
-triangles.resize(numTriangles); \
-for (uint i0 = 0; i0 < triangles.size(); i0++) { \
-	NifStream( triangles[i0].triangle, in, version ); \
-	NifStream( triangles[i0].unknownShort, in, version ); \
-	NifStream( triangles[i0].normal, in, version ); \
-}; \
-NifStream( numVertices, in, version ); \
-vertices.resize(numVertices); \
-for (uint i0 = 0; i0 < vertices.size(); i0++) { \
-	NifStream( vertices[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define HK_PACKED_NI_TRI_STRIPS_DATA_WRITE \
-AbhkShapeCollection::Write( out, link_map, version, user_version ); \
-NifStream( numTriangles, out, version ); \
-for (uint i0 = 0; i0 < triangles.size(); i0++) { \
-	NifStream( triangles[i0].triangle, out, version ); \
-	NifStream( triangles[i0].unknownShort, out, version ); \
-	NifStream( triangles[i0].normal, out, version ); \
-}; \
-NifStream( numVertices, out, version ); \
-for (uint i0 = 0; i0 < vertices.size(); i0++) { \
-	NifStream( vertices[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define HK_PACKED_NI_TRI_STRIPS_DATA_STRING \
-stringstream out; \
-out << AbhkShapeCollection::asString(); \
-out << "Num Triangles:  " << numTriangles << endl; \
-for (uint i0 = 0; i0 < triangles.size(); i0++) { \
-	out << "  Triangle:  " << triangles[i0].triangle << endl; \
-	out << "  Unknown Short:  " << triangles[i0].unknownShort << endl; \
-	out << "  Normal:  " << triangles[i0].normal << endl; \
-}; \
-out << "Num Vertices:  " << numVertices << endl; \
-for (uint i0 = 0; i0 < vertices.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Vertices[" << i0 << "]:  " << vertices[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define HK_PACKED_NI_TRI_STRIPS_DATA_FIXLINKS \
-AbhkShapeCollection::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define HK_PACKED_NI_TRI_STRIPS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AbhkShapeCollection::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_ALPHA_CONTROLLER_MEMBERS \
 Ref<NiFloatData > data; \
@@ -4023,48 +1749,19 @@ Ref<NiFloatData > data; \
  : data(NULL) \
 
 #define NI_ALPHA_CONTROLLER_READ \
-uint block_num; \
-NiSingleInterpolatorController::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_ALPHA_CONTROLLER_WRITE \
-NiSingleInterpolatorController::Write( out, link_map, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if ( data != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_ALPHA_CONTROLLER_STRING \
-stringstream out; \
-out << NiSingleInterpolatorController::asString(); \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_ALPHA_CONTROLLER_FIXLINKS \
-NiSingleInterpolatorController::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		data = DynamicCast<NiFloatData>(objects[link_stack.front()]); \
-		if ( data == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		data = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_ALPHA_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiSingleInterpolatorController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_ALPHA_PROPERTY_MEMBERS \
 ushort flags; \
@@ -4078,29 +1775,19 @@ byte threshold; \
  : flags((ushort)237), threshold((byte)0) \
 
 #define NI_ALPHA_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
-NifStream( threshold, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_ALPHA_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
-NifStream( threshold, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_ALPHA_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Threshold:  " << threshold << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_ALPHA_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_ALPHA_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_AMBIENT_LIGHT_MEMBERS \
 
@@ -4111,23 +1798,19 @@ return refs; \
 #define NI_AMBIENT_LIGHT_CONSTRUCT \
 
 #define NI_AMBIENT_LIGHT_READ \
-NiLight::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_AMBIENT_LIGHT_WRITE \
-NiLight::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_AMBIENT_LIGHT_STRING \
-stringstream out; \
-out << NiLight::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_AMBIENT_LIGHT_FIXLINKS \
-NiLight::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_AMBIENT_LIGHT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiLight::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_AUTO_NORMAL_PARTICLES_DATA_MEMBERS \
 ushort numParticles; \
@@ -4145,74 +1828,19 @@ vector<float > sizes; \
  : numParticles((ushort)0), size(0.0f), numActive((ushort)0), unknownShort((ushort)0), hasSizes(false) \
 
 #define NI_AUTO_NORMAL_PARTICLES_DATA_READ \
-NiTriBasedGeomData::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x04000002 ) { \
-	NifStream( numParticles, in, version ); \
-}; \
-if ( version <= 0x0A000100 ) { \
-	NifStream( size, in, version ); \
-}; \
-if ( version <= 0x04000002 ) { \
-	NifStream( numActive, in, version ); \
-}; \
-if ( ( version >= 0x0401000C ) && ( version <= 0x0A000100 ) ) { \
-	NifStream( unknownShort, in, version ); \
-}; \
-NifStream( hasSizes, in, version ); \
-if ( (hasSizes != 0) ) { \
-	sizes.resize(numVertices); \
-	for (uint i1 = 0; i1 < sizes.size(); i1++) { \
-		NifStream( sizes[i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_DATA_WRITE \
-NiTriBasedGeomData::Write( out, link_map, version, user_version ); \
-if ( version <= 0x04000002 ) { \
-	NifStream( numParticles, out, version ); \
-}; \
-if ( version <= 0x0A000100 ) { \
-	NifStream( size, out, version ); \
-}; \
-if ( version <= 0x04000002 ) { \
-	NifStream( numActive, out, version ); \
-}; \
-if ( ( version >= 0x0401000C ) && ( version <= 0x0A000100 ) ) { \
-	NifStream( unknownShort, out, version ); \
-}; \
-NifStream( hasSizes, out, version ); \
-if ( (hasSizes != 0) ) { \
-	for (uint i1 = 0; i1 < sizes.size(); i1++) { \
-		NifStream( sizes[i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_DATA_STRING \
-stringstream out; \
-out << NiTriBasedGeomData::asString(); \
-out << "Num Particles:  " << numParticles << endl; \
-out << "Size:  " << size << endl; \
-out << "Num Active:  " << numActive << endl; \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Has Sizes:  " << hasSizes << endl; \
-if ( (hasSizes != 0) ) { \
-	for (uint i1 = 0; i1 < sizes.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Sizes[" << i1 << "]:  " << sizes[i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_DATA_FIXLINKS \
-NiTriBasedGeomData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTriBasedGeomData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BINARY_EXTRA_DATA_MEMBERS \
 ByteArray binaryData; \
@@ -4224,40 +1852,19 @@ ByteArray binaryData; \
 #define NI_BINARY_EXTRA_DATA_CONSTRUCT \
 
 #define NI_BINARY_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( binaryData.dataSize, in, version ); \
-binaryData.data.resize(binaryData.dataSize); \
-for (uint i0 = 0; i0 < binaryData.data.size(); i0++) { \
-	NifStream( binaryData.data[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BINARY_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( binaryData.dataSize, out, version ); \
-for (uint i0 = 0; i0 < binaryData.data.size(); i0++) { \
-	NifStream( binaryData.data[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BINARY_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Data Size:  " << binaryData.dataSize << endl; \
-for (uint i0 = 0; i0 < binaryData.data.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Data[" << i0 << "]:  " << binaryData.data[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BINARY_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BINARY_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BLEND_BOOL_INTERPOLATOR_MEMBERS \
 byte boolValue; \
@@ -4270,26 +1877,19 @@ byte boolValue; \
  : boolValue((byte)0) \
 
 #define NI_BLEND_BOOL_INTERPOLATOR_READ \
-NiBlendInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( boolValue, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BLEND_BOOL_INTERPOLATOR_WRITE \
-NiBlendInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( boolValue, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BLEND_BOOL_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBlendInterpolator::asString(); \
-out << "Bool Value:  " << boolValue << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BLEND_BOOL_INTERPOLATOR_FIXLINKS \
-NiBlendInterpolator::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BLEND_BOOL_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBlendInterpolator::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BLEND_FLOAT_INTERPOLATOR_MEMBERS \
 float floatValue; \
@@ -4302,26 +1902,19 @@ float floatValue; \
  : floatValue(0.0f) \
 
 #define NI_BLEND_FLOAT_INTERPOLATOR_READ \
-NiBlendInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( floatValue, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BLEND_FLOAT_INTERPOLATOR_WRITE \
-NiBlendInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( floatValue, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BLEND_FLOAT_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBlendInterpolator::asString(); \
-out << "Float Value:  " << floatValue << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BLEND_FLOAT_INTERPOLATOR_FIXLINKS \
-NiBlendInterpolator::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BLEND_FLOAT_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBlendInterpolator::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BLEND_POINT3_INTERPOLATOR_MEMBERS \
 Vector3 pointValue; \
@@ -4333,26 +1926,19 @@ Vector3 pointValue; \
 #define NI_BLEND_POINT3_INTERPOLATOR_CONSTRUCT \
 
 #define NI_BLEND_POINT3_INTERPOLATOR_READ \
-NiBlendInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( pointValue, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BLEND_POINT3_INTERPOLATOR_WRITE \
-NiBlendInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( pointValue, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BLEND_POINT3_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBlendInterpolator::asString(); \
-out << "Point Value:  " << pointValue << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BLEND_POINT3_INTERPOLATOR_FIXLINKS \
-NiBlendInterpolator::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BLEND_POINT3_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBlendInterpolator::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BLEND_TRANSFORM_INTERPOLATOR_MEMBERS \
 
@@ -4363,28 +1949,24 @@ return refs; \
 #define NI_BLEND_TRANSFORM_INTERPOLATOR_CONSTRUCT \
 
 #define NI_BLEND_TRANSFORM_INTERPOLATOR_READ \
-NiBlendInterpolator::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BLEND_TRANSFORM_INTERPOLATOR_WRITE \
-NiBlendInterpolator::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BLEND_TRANSFORM_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBlendInterpolator::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BLEND_TRANSFORM_INTERPOLATOR_FIXLINKS \
-NiBlendInterpolator::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BLEND_TRANSFORM_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBlendInterpolator::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BONE_L_O_D_CONTROLLER_MEMBERS \
-uint numShapeGroups; \
+mutable uint numShapeGroups; \
 vector<SkinShapeGroup > shapeGroups1; \
-uint numShapeGroups2; \
+mutable uint numShapeGroups2; \
 vector<Ref<NiTriShape > > shapeGroups2; \
 
 #define NI_BONE_L_O_D_CONTROLLER_INCLUDE "ABoneLODController.h" \
@@ -4395,124 +1977,19 @@ vector<Ref<NiTriShape > > shapeGroups2; \
  : numShapeGroups((uint)0), numShapeGroups2((uint)0) \
 
 #define NI_BONE_L_O_D_CONTROLLER_READ \
-uint block_num; \
-ABoneLODController::Read( in, link_stack, version, user_version ); \
-NifStream( numShapeGroups, in, version ); \
-shapeGroups1.resize(numShapeGroups); \
-for (uint i0 = 0; i0 < shapeGroups1.size(); i0++) { \
-	NifStream( shapeGroups1[i0].numLinkPairs, in, version ); \
-	shapeGroups1[i0].linkPairs.resize(shapeGroups1[i0].numLinkPairs); \
-	for (uint i1 = 0; i1 < shapeGroups1[i0].linkPairs.size(); i1++) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
-NifStream( numShapeGroups2, in, version ); \
-shapeGroups2.resize(numShapeGroups2); \
-for (uint i0 = 0; i0 < shapeGroups2.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BONE_L_O_D_CONTROLLER_WRITE \
-ABoneLODController::Write( out, link_map, version, user_version ); \
-NifStream( numShapeGroups, out, version ); \
-for (uint i0 = 0; i0 < shapeGroups1.size(); i0++) { \
-	NifStream( shapeGroups1[i0].numLinkPairs, out, version ); \
-	for (uint i1 = 0; i1 < shapeGroups1[i0].linkPairs.size(); i1++) { \
-		if ( shapeGroups1[i0].linkPairs[i1].shape != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(shapeGroups1[i0].linkPairs[i1].shape)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-		if ( shapeGroups1[i0].linkPairs[i1].skinInstance != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(shapeGroups1[i0].linkPairs[i1].skinInstance)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
-NifStream( numShapeGroups2, out, version ); \
-for (uint i0 = 0; i0 < shapeGroups2.size(); i0++) { \
-	if ( shapeGroups2[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(shapeGroups2[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BONE_L_O_D_CONTROLLER_STRING \
-stringstream out; \
-out << ABoneLODController::asString(); \
-out << "Num Shape Groups:  " << numShapeGroups << endl; \
-for (uint i0 = 0; i0 < shapeGroups1.size(); i0++) { \
-	out << "  Num Link Pairs:  " << shapeGroups1[i0].numLinkPairs << endl; \
-	for (uint i1 = 0; i1 < shapeGroups1[i0].linkPairs.size(); i1++) { \
-		out << "    Shape:  " << shapeGroups1[i0].linkPairs[i1].shape << endl; \
-		out << "    Skin Instance:  " << shapeGroups1[i0].linkPairs[i1].skinInstance << endl; \
-	}; \
-}; \
-out << "Num Shape Groups 2:  " << numShapeGroups2 << endl; \
-for (uint i0 = 0; i0 < shapeGroups2.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Shape Groups 2[" << i0 << "]:  " << shapeGroups2[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BONE_L_O_D_CONTROLLER_FIXLINKS \
-ABoneLODController::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < shapeGroups1.size(); i0++) { \
-	for (uint i1 = 0; i1 < shapeGroups1[i0].linkPairs.size(); i1++) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			shapeGroups1[i0].linkPairs[i1].shape = DynamicCast<NiTriShape>(objects[link_stack.front()]); \
-			if ( shapeGroups1[i0].linkPairs[i1].shape == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			shapeGroups1[i0].linkPairs[i1].shape = NULL; \
-		link_stack.pop_front(); \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			shapeGroups1[i0].linkPairs[i1].skinInstance = DynamicCast<NiSkinInstance>(objects[link_stack.front()]); \
-			if ( shapeGroups1[i0].linkPairs[i1].skinInstance == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			shapeGroups1[i0].linkPairs[i1].skinInstance = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
-for (uint i0 = 0; i0 < shapeGroups2.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		shapeGroups2[i0] = DynamicCast<NiTriShape>(objects[link_stack.front()]); \
-		if ( shapeGroups2[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		shapeGroups2[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BONE_L_O_D_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = ABoneLODController::GetRefs(); \
-for (uint i0 = 0; i0 < shapeGroups1.size(); i0++) { \
-	for (uint i1 = 0; i1 < shapeGroups1[i0].linkPairs.size(); i1++) { \
-		if ( shapeGroups1[i0].linkPairs[i1].shape != NULL ) \
-			refs.push_back(StaticCast<NiObject>(shapeGroups1[i0].linkPairs[i1].shape)); \
-		if ( shapeGroups1[i0].linkPairs[i1].skinInstance != NULL ) \
-			refs.push_back(StaticCast<NiObject>(shapeGroups1[i0].linkPairs[i1].skinInstance)); \
-	}; \
-}; \
-for (uint i0 = 0; i0 < shapeGroups2.size(); i0++) { \
-	if ( shapeGroups2[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(shapeGroups2[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BOOL_DATA_MEMBERS \
 KeyGroup<byte > data; \
@@ -4524,49 +2001,19 @@ KeyGroup<byte > data; \
 #define NI_BOOL_DATA_CONSTRUCT \
 
 #define NI_BOOL_DATA_READ \
-AKeyedData::Read( in, link_stack, version, user_version ); \
-NifStream( data.numKeys, in, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, in, version ); \
-}; \
-data.keys.resize(data.numKeys); \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], in, version, data.interpolation ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BOOL_DATA_WRITE \
-AKeyedData::Write( out, link_map, version, user_version ); \
-NifStream( data.numKeys, out, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, out, version ); \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], out, version, data.interpolation ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BOOL_DATA_STRING \
-stringstream out; \
-out << AKeyedData::asString(); \
-out << "Num Keys:  " << data.numKeys << endl; \
-if ( (data.numKeys != 0) ) { \
-	out << "  Interpolation:  " << data.interpolation << endl; \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Keys[" << i0 << "]:  " << data.keys[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BOOL_DATA_FIXLINKS \
-AKeyedData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BOOL_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AKeyedData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BOOLEAN_EXTRA_DATA_MEMBERS \
 byte booleanData; \
@@ -4579,26 +2026,19 @@ byte booleanData; \
  : booleanData((byte)0) \
 
 #define NI_BOOLEAN_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( booleanData, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BOOLEAN_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( booleanData, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BOOLEAN_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Boolean Data:  " << booleanData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BOOLEAN_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BOOLEAN_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BOOL_INTERPOLATOR_MEMBERS \
 bool boolValue; \
@@ -4612,45 +2052,19 @@ Ref<NiBoolData > data; \
  : boolValue(false), data(NULL) \
 
 #define NI_BOOL_INTERPOLATOR_READ \
-uint block_num; \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( boolValue, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BOOL_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( boolValue, out, version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BOOL_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Bool Value:  " << boolValue << endl; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BOOL_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiBoolData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BOOL_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BOOL_TIMELINE_INTERPOLATOR_MEMBERS \
 byte boolValue; \
@@ -4664,45 +2078,19 @@ Ref<NiBoolData > data; \
  : boolValue((byte)0), data(NULL) \
 
 #define NI_BOOL_TIMELINE_INTERPOLATOR_READ \
-uint block_num; \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( boolValue, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BOOL_TIMELINE_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( boolValue, out, version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BOOL_TIMELINE_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Bool Value:  " << boolValue << endl; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BOOL_TIMELINE_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiBoolData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BOOL_TIMELINE_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_S_BONE_L_O_D_CONTROLLER_MEMBERS \
 
@@ -4713,23 +2101,19 @@ return refs; \
 #define NI_B_S_BONE_L_O_D_CONTROLLER_CONSTRUCT \
 
 #define NI_B_S_BONE_L_O_D_CONTROLLER_READ \
-ABoneLODController::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_S_BONE_L_O_D_CONTROLLER_WRITE \
-ABoneLODController::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_S_BONE_L_O_D_CONTROLLER_STRING \
-stringstream out; \
-out << ABoneLODController::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_S_BONE_L_O_D_CONTROLLER_FIXLINKS \
-ABoneLODController::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_S_BONE_L_O_D_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = ABoneLODController::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_SPLINE_BASIS_DATA_MEMBERS \
 uint unknownInt; \
@@ -4742,29 +2126,22 @@ uint unknownInt; \
  : unknownInt((uint)0) \
 
 #define NI_B_SPLINE_BASIS_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( unknownInt, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_BASIS_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( unknownInt, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_SPLINE_BASIS_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Unknown Int:  " << unknownInt << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_SPLINE_BASIS_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_BASIS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_MEMBERS \
-float unknownFloats[6]; \
+array<float,6> unknownFloats; \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_INCLUDE "NiBSplineInterpolator.h" \
 
@@ -4773,41 +2150,24 @@ float unknownFloats[6]; \
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_CONSTRUCT \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_READ \
-NiBSplineInterpolator::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_WRITE \
-NiBSplineInterpolator::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBSplineInterpolator::asString(); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_FIXLINKS \
-NiBSplineInterpolator::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBSplineInterpolator::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_MEMBERS \
 Ref<NiBSplineData > data; \
 Ref<NiObject > unknownLink; \
-float unknownFloats[6]; \
+array<float,6> unknownFloats; \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_INCLUDE "NiBSplineInterpolator.h" \
 
@@ -4817,78 +2177,24 @@ float unknownFloats[6]; \
  : data(NULL), unknownLink(NULL) \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_READ \
-uint block_num; \
-NiBSplineInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_WRITE \
-NiBSplineInterpolator::Write( out, link_map, version, user_version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( unknownLink != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBSplineInterpolator::asString(); \
-out << "Data:  " << data << endl; \
-out << "Unknown Link:  " << unknownLink << endl; \
-for (uint i0 = 0; i0 < 6; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_FIXLINKS \
-NiBSplineInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiBSplineData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( unknownLink == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBSplineInterpolator::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-if ( unknownLink != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_MEMBERS \
 Ref<NiBSplineData > data; \
 Ref<NiBSplineBasisData > basisData; \
-float unknown4[17]; \
+array<float,17> unknown4; \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_INCLUDE "NiBSplineInterpolator.h" \
 
@@ -4898,77 +2204,23 @@ float unknown4[17]; \
  : data(NULL), basisData(NULL) \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_READ \
-uint block_num; \
-NiBSplineInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-for (uint i0 = 0; i0 < 17; i0++) { \
-	NifStream( unknown4[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_WRITE \
-NiBSplineInterpolator::Write( out, link_map, version, user_version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( basisData != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(basisData)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-for (uint i0 = 0; i0 < 17; i0++) { \
-	NifStream( unknown4[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBSplineInterpolator::asString(); \
-out << "Data:  " << data << endl; \
-out << "Basis Data:  " << basisData << endl; \
-for (uint i0 = 0; i0 < 17; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown4[" << i0 << "]:  " << unknown4[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_FIXLINKS \
-NiBSplineInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiBSplineData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	basisData = DynamicCast<NiBSplineBasisData>(objects[link_stack.front()]); \
-	if ( basisData == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	basisData = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBSplineInterpolator::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-if ( basisData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(basisData)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_SPLINE_DATA_MEMBERS \
 uint unknownInt; \
-uint count; \
+mutable uint count; \
 vector< array<byte,2> > unknownData; \
 
 #define NI_B_SPLINE_DATA_INCLUDE "NiObject.h" \
@@ -4979,49 +2231,19 @@ vector< array<byte,2> > unknownData; \
  : unknownInt((uint)0), count((uint)0) \
 
 #define NI_B_SPLINE_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( unknownInt, in, version ); \
-NifStream( count, in, version ); \
-unknownData.resize(count); \
-for (uint i0 = 0; i0 < unknownData.size(); i0++) { \
-	for (uint i1 = 0; i1 < 2; i1++) { \
-		NifStream( unknownData[i0][i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( unknownInt, out, version ); \
-NifStream( count, out, version ); \
-for (uint i0 = 0; i0 < unknownData.size(); i0++) { \
-	for (uint i1 = 0; i1 < 2; i1++) { \
-		NifStream( unknownData[i0][i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_SPLINE_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Unknown Int:  " << unknownInt << endl; \
-out << "Count:  " << count << endl; \
-for (uint i0 = 0; i0 < unknownData.size(); i0++) { \
-	for (uint i1 = 0; i1 < 2; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Data[" << i0 << "][" << i1 << "]:  " << unknownData[i0][i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_SPLINE_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_SPLINE_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_CAMERA_MEMBERS \
 ushort unknownShort; \
@@ -5049,99 +2271,19 @@ uint unknownInt2; \
  : unknownShort((ushort)0), frustumLeft(0.0f), frustumRight(0.0f), frustumTop(0.0f), frustumBottom(0.0f), frustumNear(0.0f), frustumFar(0.0f), useOrthographicProjection(false), viewportLeft(0.0f), viewportRight(0.0f), viewportTop(0.0f), viewportBottom(0.0f), lodAdjust(0.0f), unknownLink_(NULL), unknownInt((uint)0), unknownInt2((uint)0) \
 
 #define NI_CAMERA_READ \
-uint block_num; \
-NiAVObject::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownShort, in, version ); \
-}; \
-NifStream( frustumLeft, in, version ); \
-NifStream( frustumRight, in, version ); \
-NifStream( frustumTop, in, version ); \
-NifStream( frustumBottom, in, version ); \
-NifStream( frustumNear, in, version ); \
-NifStream( frustumFar, in, version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( useOrthographicProjection, in, version ); \
-}; \
-NifStream( viewportLeft, in, version ); \
-NifStream( viewportRight, in, version ); \
-NifStream( viewportTop, in, version ); \
-NifStream( viewportBottom, in, version ); \
-NifStream( lodAdjust, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( unknownInt, in, version ); \
-if ( version >= 0x04020100 ) { \
-	NifStream( unknownInt2, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_CAMERA_WRITE \
-NiAVObject::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownShort, out, version ); \
-}; \
-NifStream( frustumLeft, out, version ); \
-NifStream( frustumRight, out, version ); \
-NifStream( frustumTop, out, version ); \
-NifStream( frustumBottom, out, version ); \
-NifStream( frustumNear, out, version ); \
-NifStream( frustumFar, out, version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( useOrthographicProjection, out, version ); \
-}; \
-NifStream( viewportLeft, out, version ); \
-NifStream( viewportRight, out, version ); \
-NifStream( viewportTop, out, version ); \
-NifStream( viewportBottom, out, version ); \
-NifStream( lodAdjust, out, version ); \
-if ( unknownLink_ != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink_)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( unknownInt, out, version ); \
-if ( version >= 0x04020100 ) { \
-	NifStream( unknownInt2, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_CAMERA_STRING \
-stringstream out; \
-out << NiAVObject::asString(); \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Frustum Left:  " << frustumLeft << endl; \
-out << "Frustum Right:  " << frustumRight << endl; \
-out << "Frustum Top:  " << frustumTop << endl; \
-out << "Frustum Bottom:  " << frustumBottom << endl; \
-out << "Frustum Near:  " << frustumNear << endl; \
-out << "Frustum Far:  " << frustumFar << endl; \
-out << "Use Orthographic Projection:  " << useOrthographicProjection << endl; \
-out << "Viewport Left:  " << viewportLeft << endl; \
-out << "Viewport Right:  " << viewportRight << endl; \
-out << "Viewport Top:  " << viewportTop << endl; \
-out << "Viewport Bottom:  " << viewportBottom << endl; \
-out << "LOD Adjust:  " << lodAdjust << endl; \
-out << "Unknown Link?:  " << unknownLink_ << endl; \
-out << "Unknown Int:  " << unknownInt << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_CAMERA_FIXLINKS \
-NiAVObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink_ = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( unknownLink_ == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink_ = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_CAMERA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiAVObject::GetRefs(); \
-if ( unknownLink_ != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink_)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_COLLISION_DATA_MEMBERS \
 NiNode * targetNode; \
@@ -5150,8 +2292,8 @@ byte unknown3; \
 uint collisionType; \
 uint unknown5; \
 Vector3 unknown7; \
-float unknown6[8]; \
-float unknown8[15]; \
+array<float,8> unknown6; \
+array<float,15> unknown8; \
 
 #define NI_COLLISION_DATA_INCLUDE "NiObject.h" \
 
@@ -5161,99 +2303,19 @@ float unknown8[15]; \
  : targetNode(NULL), unknown2((uint)0), unknown3((byte)0), collisionType((uint)0), unknown5((uint)0) \
 
 #define NI_COLLISION_DATA_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( unknown2, in, version ); \
-NifStream( unknown3, in, version ); \
-NifStream( collisionType, in, version ); \
-if ( (collisionType == 0) ) { \
-	NifStream( unknown5, in, version ); \
-	NifStream( unknown7, in, version ); \
-}; \
-if ( (collisionType == 2) ) { \
-	for (uint i1 = 0; i1 < 8; i1++) { \
-		NifStream( unknown6[i1], in, version ); \
-	}; \
-}; \
-if ( (collisionType == 1) ) { \
-	for (uint i1 = 0; i1 < 15; i1++) { \
-		NifStream( unknown8[i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_COLLISION_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-if ( targetNode != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(targetNode)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( unknown2, out, version ); \
-NifStream( unknown3, out, version ); \
-NifStream( collisionType, out, version ); \
-if ( (collisionType == 0) ) { \
-	NifStream( unknown5, out, version ); \
-	NifStream( unknown7, out, version ); \
-}; \
-if ( (collisionType == 2) ) { \
-	for (uint i1 = 0; i1 < 8; i1++) { \
-		NifStream( unknown6[i1], out, version ); \
-	}; \
-}; \
-if ( (collisionType == 1) ) { \
-	for (uint i1 = 0; i1 < 15; i1++) { \
-		NifStream( unknown8[i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_COLLISION_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Target Node:  " << targetNode << endl; \
-out << "Unknown2:  " << unknown2 << endl; \
-out << "Unknown3:  " << unknown3 << endl; \
-out << "Collision Type:  " << collisionType << endl; \
-if ( (collisionType == 0) ) { \
-	out << "  Unknown5:  " << unknown5 << endl; \
-	out << "  Unknown7:  " << unknown7 << endl; \
-}; \
-if ( (collisionType == 2) ) { \
-	for (uint i1 = 0; i1 < 8; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown6[" << i1 << "]:  " << unknown6[i1] << endl; \
-	}; \
-}; \
-if ( (collisionType == 1) ) { \
-	for (uint i1 = 0; i1 < 15; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown8[" << i1 << "]:  " << unknown8[i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_COLLISION_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	targetNode = DynamicCast<NiNode>(objects[link_stack.front()]); \
-	if ( targetNode == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	targetNode = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_COLLISION_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_COLOR_DATA_MEMBERS \
 KeyGroup<Color4 > data; \
@@ -5265,49 +2327,19 @@ KeyGroup<Color4 > data; \
 #define NI_COLOR_DATA_CONSTRUCT \
 
 #define NI_COLOR_DATA_READ \
-AKeyedData::Read( in, link_stack, version, user_version ); \
-NifStream( data.numKeys, in, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, in, version ); \
-}; \
-data.keys.resize(data.numKeys); \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], in, version, data.interpolation ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_COLOR_DATA_WRITE \
-AKeyedData::Write( out, link_map, version, user_version ); \
-NifStream( data.numKeys, out, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, out, version ); \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], out, version, data.interpolation ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_COLOR_DATA_STRING \
-stringstream out; \
-out << AKeyedData::asString(); \
-out << "Num Keys:  " << data.numKeys << endl; \
-if ( (data.numKeys != 0) ) { \
-	out << "  Interpolation:  " << data.interpolation << endl; \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Keys[" << i0 << "]:  " << data.keys[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_COLOR_DATA_FIXLINKS \
-AKeyedData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_COLOR_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AKeyedData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_COLOR_EXTRA_DATA_MEMBERS \
 Color4 data; \
@@ -5319,30 +2351,23 @@ Color4 data; \
 #define NI_COLOR_EXTRA_DATA_CONSTRUCT \
 
 #define NI_COLOR_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( data, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_COLOR_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( data, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_COLOR_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_COLOR_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_COLOR_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_CONTROLLER_MANAGER_MEMBERS \
 bool cumulative; \
-uint numControllerSequences; \
+mutable uint numControllerSequences; \
 vector<Ref<NiControllerSequence > > controllerSequences; \
 Ref<NiDefaultAVObjectPalette > objectPalette; \
 
@@ -5354,86 +2379,24 @@ Ref<NiDefaultAVObjectPalette > objectPalette; \
  : cumulative(false), numControllerSequences((uint)0), objectPalette(NULL) \
 
 #define NI_CONTROLLER_MANAGER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( cumulative, in, version ); \
-NifStream( numControllerSequences, in, version ); \
-controllerSequences.resize(numControllerSequences); \
-for (uint i0 = 0; i0 < controllerSequences.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_CONTROLLER_MANAGER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-NifStream( cumulative, out, version ); \
-NifStream( numControllerSequences, out, version ); \
-for (uint i0 = 0; i0 < controllerSequences.size(); i0++) { \
-	if ( controllerSequences[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(controllerSequences[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( objectPalette != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(objectPalette)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_CONTROLLER_MANAGER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Cumulative:  " << cumulative << endl; \
-out << "Num Controller Sequences:  " << numControllerSequences << endl; \
-for (uint i0 = 0; i0 < controllerSequences.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Controller Sequences[" << i0 << "]:  " << controllerSequences[i0] << endl; \
-}; \
-out << "Object Palette:  " << objectPalette << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_CONTROLLER_MANAGER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < controllerSequences.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		controllerSequences[i0] = DynamicCast<NiControllerSequence>(objects[link_stack.front()]); \
-		if ( controllerSequences[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		controllerSequences[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	objectPalette = DynamicCast<NiDefaultAVObjectPalette>(objects[link_stack.front()]); \
-	if ( objectPalette == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	objectPalette = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_CONTROLLER_MANAGER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-for (uint i0 = 0; i0 < controllerSequences.size(); i0++) { \
-	if ( controllerSequences[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(controllerSequences[i0])); \
-}; \
-if ( objectPalette != NULL ) \
-	refs.push_back(StaticCast<NiObject>(objectPalette)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_CONTROLLER_SEQUENCE_MEMBERS \
 string name; \
 ControllerLink textKeys; \
-uint numControlledBlocks; \
+mutable uint numControlledBlocks; \
 uint unknownInt1; \
 vector<ControllerLink > controlledBlocks; \
 float weight; \
@@ -5457,535 +2420,23 @@ Ref<NiStringPalette > stringPalette; \
  : numControlledBlocks((uint)0), unknownInt1((uint)0), weight(1.0f), textKeys2(NULL), cycleType((uint)0), unknownInt0((uint)0), frequency(0.0f), startTime(0.0f), stopTime(0.0f), unknownFloat2(0.0f), unknownByte((byte)0), manager(NULL), stringPalette(NULL) \
 
 #define NI_CONTROLLER_SEQUENCE_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( name, in, version ); \
-if ( version <= 0x0A010000 ) { \
-	if ( version <= 0x0A010000 ) { \
-		NifStream( textKeys.name, in, version ); \
-	}; \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	if ( version >= 0x0A01006A ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-		NifStream( textKeys.unknownShort0, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 10 ) ) { \
-		NifStream( textKeys.priority_, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 11 ) ) { \
-		NifStream( textKeys.priority_, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.nodeName, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.nodeNameOffset, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.propertyType, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.propertyTypeOffset, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.controllerType, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.controllerTypeOffset, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.variable1, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.variableOffset1, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.variable2, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.variableOffset2, in, version ); \
-	}; \
-}; \
-NifStream( numControlledBlocks, in, version ); \
-if ( version >= 0x0A01006A ) { \
-	NifStream( unknownInt1, in, version ); \
-}; \
-controlledBlocks.resize(numControlledBlocks); \
-for (uint i0 = 0; i0 < controlledBlocks.size(); i0++) { \
-	if ( version <= 0x0A010000 ) { \
-		NifStream( controlledBlocks[i0].name, in, version ); \
-	}; \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	if ( version >= 0x0A01006A ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-		NifStream( controlledBlocks[i0].unknownShort0, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 10 ) ) { \
-		NifStream( controlledBlocks[i0].priority_, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 11 ) ) { \
-		NifStream( controlledBlocks[i0].priority_, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].nodeName, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].nodeNameOffset, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].propertyType, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].propertyTypeOffset, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].controllerType, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].controllerTypeOffset, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].variable1, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].variableOffset1, in, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].variable2, in, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].variableOffset2, in, version ); \
-	}; \
-}; \
-if ( version >= 0x0A01006A ) { \
-	NifStream( weight, in, version ); \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( cycleType, in, version ); \
-}; \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	NifStream( unknownInt0, in, version ); \
-}; \
-if ( version >= 0x0A01006A ) { \
-	NifStream( frequency, in, version ); \
-	NifStream( startTime, in, version ); \
-	NifStream( stopTime, in, version ); \
-}; \
-if ( ( version >= 0x0A020000 ) && ( version <= 0x0A020000 ) ) { \
-	NifStream( unknownFloat2, in, version ); \
-}; \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	NifStream( unknownByte, in, version ); \
-}; \
-if ( version >= 0x0A01006A ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( unknownString, in, version ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_CONTROLLER_SEQUENCE_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( name, out, version ); \
-if ( version <= 0x0A010000 ) { \
-	if ( version <= 0x0A010000 ) { \
-		NifStream( textKeys.name, out, version ); \
-	}; \
-	if ( textKeys.interpolator != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(textKeys.interpolator)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	if ( version >= 0x0A01006A ) { \
-		if ( textKeys.unknownLink1 != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(textKeys.unknownLink1)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		if ( textKeys.unknownLink2 != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(textKeys.unknownLink2)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-		NifStream( textKeys.unknownShort0, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 10 ) ) { \
-		NifStream( textKeys.priority_, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 11 ) ) { \
-		NifStream( textKeys.priority_, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		if ( textKeys.stringPalette != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(textKeys.stringPalette)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.nodeName, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.nodeNameOffset, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.propertyType, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.propertyTypeOffset, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.controllerType, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.controllerTypeOffset, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.variable1, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.variableOffset1, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( textKeys.variable2, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( textKeys.variableOffset2, out, version ); \
-	}; \
-}; \
-NifStream( numControlledBlocks, out, version ); \
-if ( version >= 0x0A01006A ) { \
-	NifStream( unknownInt1, out, version ); \
-}; \
-for (uint i0 = 0; i0 < controlledBlocks.size(); i0++) { \
-	if ( version <= 0x0A010000 ) { \
-		NifStream( controlledBlocks[i0].name, out, version ); \
-	}; \
-	if ( controlledBlocks[i0].interpolator != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(controlledBlocks[i0].interpolator)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	if ( version >= 0x0A01006A ) { \
-		if ( controlledBlocks[i0].unknownLink1 != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(controlledBlocks[i0].unknownLink1)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		if ( controlledBlocks[i0].unknownLink2 != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(controlledBlocks[i0].unknownLink2)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-		NifStream( controlledBlocks[i0].unknownShort0, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 10 ) ) { \
-		NifStream( controlledBlocks[i0].priority_, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( user_version == 11 ) ) { \
-		NifStream( controlledBlocks[i0].priority_, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		if ( controlledBlocks[i0].stringPalette != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(controlledBlocks[i0].stringPalette)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].nodeName, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].nodeNameOffset, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].propertyType, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].propertyTypeOffset, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].controllerType, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].controllerTypeOffset, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].variable1, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].variableOffset1, out, version ); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( controlledBlocks[i0].variable2, out, version ); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		NifStream( controlledBlocks[i0].variableOffset2, out, version ); \
-	}; \
-}; \
-if ( version >= 0x0A01006A ) { \
-	NifStream( weight, out, version ); \
-	if ( textKeys2 != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(textKeys2)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( cycleType, out, version ); \
-}; \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	NifStream( unknownInt0, out, version ); \
-}; \
-if ( version >= 0x0A01006A ) { \
-	NifStream( frequency, out, version ); \
-	NifStream( startTime, out, version ); \
-	NifStream( stopTime, out, version ); \
-}; \
-if ( ( version >= 0x0A020000 ) && ( version <= 0x0A020000 ) ) { \
-	NifStream( unknownFloat2, out, version ); \
-}; \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	NifStream( unknownByte, out, version ); \
-}; \
-if ( version >= 0x0A01006A ) { \
-	if ( manager != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(manager)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( unknownString, out, version ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if ( stringPalette != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(stringPalette)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_CONTROLLER_SEQUENCE_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Name:  " << name << endl; \
-out << "Name:  " << textKeys.name << endl; \
-out << "Interpolator:  " << textKeys.interpolator << endl; \
-out << "Unknown Link 1:  " << textKeys.unknownLink1 << endl; \
-out << "Unknown Link 2:  " << textKeys.unknownLink2 << endl; \
-out << "Unknown Short 0:  " << textKeys.unknownShort0 << endl; \
-out << "Priority?:  " << textKeys.priority_ << endl; \
-out << "String Palette:  " << textKeys.stringPalette << endl; \
-out << "Node Name:  " << textKeys.nodeName << endl; \
-out << "Node Name Offset:  " << textKeys.nodeNameOffset << endl; \
-out << "Property Type:  " << textKeys.propertyType << endl; \
-out << "Property Type Offset:  " << textKeys.propertyTypeOffset << endl; \
-out << "Controller Type:  " << textKeys.controllerType << endl; \
-out << "Controller Type Offset:  " << textKeys.controllerTypeOffset << endl; \
-out << "Variable 1:  " << textKeys.variable1 << endl; \
-out << "Variable Offset 1:  " << textKeys.variableOffset1 << endl; \
-out << "Variable 2:  " << textKeys.variable2 << endl; \
-out << "Variable Offset 2:  " << textKeys.variableOffset2 << endl; \
-out << "Num Controlled Blocks:  " << numControlledBlocks << endl; \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-for (uint i0 = 0; i0 < controlledBlocks.size(); i0++) { \
-	out << "  Name:  " << controlledBlocks[i0].name << endl; \
-	out << "  Interpolator:  " << controlledBlocks[i0].interpolator << endl; \
-	out << "  Unknown Link 1:  " << controlledBlocks[i0].unknownLink1 << endl; \
-	out << "  Unknown Link 2:  " << controlledBlocks[i0].unknownLink2 << endl; \
-	out << "  Unknown Short 0:  " << controlledBlocks[i0].unknownShort0 << endl; \
-	out << "  Priority?:  " << controlledBlocks[i0].priority_ << endl; \
-	out << "  String Palette:  " << controlledBlocks[i0].stringPalette << endl; \
-	out << "  Node Name:  " << controlledBlocks[i0].nodeName << endl; \
-	out << "  Node Name Offset:  " << controlledBlocks[i0].nodeNameOffset << endl; \
-	out << "  Property Type:  " << controlledBlocks[i0].propertyType << endl; \
-	out << "  Property Type Offset:  " << controlledBlocks[i0].propertyTypeOffset << endl; \
-	out << "  Controller Type:  " << controlledBlocks[i0].controllerType << endl; \
-	out << "  Controller Type Offset:  " << controlledBlocks[i0].controllerTypeOffset << endl; \
-	out << "  Variable 1:  " << controlledBlocks[i0].variable1 << endl; \
-	out << "  Variable Offset 1:  " << controlledBlocks[i0].variableOffset1 << endl; \
-	out << "  Variable 2:  " << controlledBlocks[i0].variable2 << endl; \
-	out << "  Variable Offset 2:  " << controlledBlocks[i0].variableOffset2 << endl; \
-}; \
-out << "Weight:  " << weight << endl; \
-out << "Text Keys 2:  " << textKeys2 << endl; \
-out << "Cycle Type:  " << cycleType << endl; \
-out << "Unknown Int 0:  " << unknownInt0 << endl; \
-out << "Frequency:  " << frequency << endl; \
-out << "Start Time:  " << startTime << endl; \
-out << "Stop Time:  " << stopTime << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Byte:  " << unknownByte << endl; \
-out << "Manager:  " << manager << endl; \
-out << "Unknown String:  " << unknownString << endl; \
-out << "String Palette:  " << stringPalette << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_CONTROLLER_SEQUENCE_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		textKeys.interpolator = DynamicCast<NiInterpolator>(objects[link_stack.front()]); \
-		if ( textKeys.interpolator == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		textKeys.interpolator = NULL; \
-	link_stack.pop_front(); \
-	if ( version >= 0x0A01006A ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			textKeys.unknownLink1 = DynamicCast<NiObject>(objects[link_stack.front()]); \
-			if ( textKeys.unknownLink1 == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			textKeys.unknownLink1 = NULL; \
-		link_stack.pop_front(); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			textKeys.unknownLink2 = DynamicCast<NiObject>(objects[link_stack.front()]); \
-			if ( textKeys.unknownLink2 == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			textKeys.unknownLink2 = NULL; \
-		link_stack.pop_front(); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			textKeys.stringPalette = DynamicCast<NiStringPalette>(objects[link_stack.front()]); \
-			if ( textKeys.stringPalette == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			textKeys.stringPalette = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
-for (uint i0 = 0; i0 < controlledBlocks.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		controlledBlocks[i0].interpolator = DynamicCast<NiInterpolator>(objects[link_stack.front()]); \
-		if ( controlledBlocks[i0].interpolator == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		controlledBlocks[i0].interpolator = NULL; \
-	link_stack.pop_front(); \
-	if ( version >= 0x0A01006A ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			controlledBlocks[i0].unknownLink1 = DynamicCast<NiObject>(objects[link_stack.front()]); \
-			if ( controlledBlocks[i0].unknownLink1 == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			controlledBlocks[i0].unknownLink1 = NULL; \
-		link_stack.pop_front(); \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			controlledBlocks[i0].unknownLink2 = DynamicCast<NiObject>(objects[link_stack.front()]); \
-			if ( controlledBlocks[i0].unknownLink2 == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			controlledBlocks[i0].unknownLink2 = NULL; \
-		link_stack.pop_front(); \
-	}; \
-	if ( version >= 0x0A020000 ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			controlledBlocks[i0].stringPalette = DynamicCast<NiStringPalette>(objects[link_stack.front()]); \
-			if ( controlledBlocks[i0].stringPalette == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			controlledBlocks[i0].stringPalette = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
-if ( version >= 0x0A01006A ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		textKeys2 = DynamicCast<NiTextKeyExtraData>(objects[link_stack.front()]); \
-		if ( textKeys2 == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		textKeys2 = NULL; \
-	link_stack.pop_front(); \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		manager = DynamicCast<NiControllerManager>(objects[link_stack.front()]); \
-		if ( manager == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		manager = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		stringPalette = DynamicCast<NiStringPalette>(objects[link_stack.front()]); \
-		if ( stringPalette == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		stringPalette = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_CONTROLLER_SEQUENCE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( textKeys.interpolator != NULL ) \
-	refs.push_back(StaticCast<NiObject>(textKeys.interpolator)); \
-if ( textKeys.unknownLink1 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(textKeys.unknownLink1)); \
-if ( textKeys.unknownLink2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(textKeys.unknownLink2)); \
-if ( textKeys.stringPalette != NULL ) \
-	refs.push_back(StaticCast<NiObject>(textKeys.stringPalette)); \
-for (uint i0 = 0; i0 < controlledBlocks.size(); i0++) { \
-	if ( controlledBlocks[i0].interpolator != NULL ) \
-		refs.push_back(StaticCast<NiObject>(controlledBlocks[i0].interpolator)); \
-	if ( controlledBlocks[i0].unknownLink1 != NULL ) \
-		refs.push_back(StaticCast<NiObject>(controlledBlocks[i0].unknownLink1)); \
-	if ( controlledBlocks[i0].unknownLink2 != NULL ) \
-		refs.push_back(StaticCast<NiObject>(controlledBlocks[i0].unknownLink2)); \
-	if ( controlledBlocks[i0].stringPalette != NULL ) \
-		refs.push_back(StaticCast<NiObject>(controlledBlocks[i0].stringPalette)); \
-}; \
-if ( textKeys2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(textKeys2)); \
-if ( stringPalette != NULL ) \
-	refs.push_back(StaticCast<NiObject>(stringPalette)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_DEFAULT_A_V_OBJECT_PALETTE_MEMBERS \
 uint unknownInt; \
-uint numObjs; \
+mutable uint numObjs; \
 vector<AVObject > objs; \
 
 #define NI_DEFAULT_A_V_OBJECT_PALETTE_INCLUDE "NiObject.h" \
@@ -5996,60 +2447,19 @@ vector<AVObject > objs; \
  : unknownInt((uint)0), numObjs((uint)0) \
 
 #define NI_DEFAULT_A_V_OBJECT_PALETTE_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( unknownInt, in, version ); \
-NifStream( numObjs, in, version ); \
-objs.resize(numObjs); \
-for (uint i0 = 0; i0 < objs.size(); i0++) { \
-	NifStream( objs[i0].name, in, version ); \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_DEFAULT_A_V_OBJECT_PALETTE_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( unknownInt, out, version ); \
-NifStream( numObjs, out, version ); \
-for (uint i0 = 0; i0 < objs.size(); i0++) { \
-	NifStream( objs[i0].name, out, version ); \
-	if ( objs[i0].object != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(objs[i0].object)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_DEFAULT_A_V_OBJECT_PALETTE_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Unknown Int:  " << unknownInt << endl; \
-out << "Num Objs:  " << numObjs << endl; \
-for (uint i0 = 0; i0 < objs.size(); i0++) { \
-	out << "  Name:  " << objs[i0].name << endl; \
-	out << "  Object:  " << objs[i0].object << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_DEFAULT_A_V_OBJECT_PALETTE_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < objs.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		objs[i0].object = DynamicCast<NiAVObject>(objects[link_stack.front()]); \
-		if ( objs[i0].object == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		objs[i0].object = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_DEFAULT_A_V_OBJECT_PALETTE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-for (uint i0 = 0; i0 < objs.size(); i0++) { \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_DIRECTIONAL_LIGHT_MEMBERS \
 
@@ -6060,23 +2470,19 @@ return refs; \
 #define NI_DIRECTIONAL_LIGHT_CONSTRUCT \
 
 #define NI_DIRECTIONAL_LIGHT_READ \
-NiLight::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_DIRECTIONAL_LIGHT_WRITE \
-NiLight::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_DIRECTIONAL_LIGHT_STRING \
-stringstream out; \
-out << NiLight::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_DIRECTIONAL_LIGHT_FIXLINKS \
-NiLight::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_DIRECTIONAL_LIGHT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiLight::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_DITHER_PROPERTY_MEMBERS \
 ushort flags; \
@@ -6089,32 +2495,25 @@ ushort flags; \
  : flags((ushort)0) \
 
 #define NI_DITHER_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_DITHER_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_DITHER_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_DITHER_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_DITHER_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_FLIP_CONTROLLER_MEMBERS \
 uint textureSlot; \
 uint unknownInt2; \
 float delta; \
-uint numSources; \
+mutable uint numSources; \
 vector<Ref<NiSourceTexture > > sources; \
 
 #define NI_FLIP_CONTROLLER_INCLUDE "NiSingleInterpolatorController.h" \
@@ -6125,73 +2524,19 @@ vector<Ref<NiSourceTexture > > sources; \
  : textureSlot((uint)0), unknownInt2((uint)0), delta(0.0f), numSources((uint)0) \
 
 #define NI_FLIP_CONTROLLER_READ \
-uint block_num; \
-NiSingleInterpolatorController::Read( in, link_stack, version, user_version ); \
-NifStream( textureSlot, in, version ); \
-if ( version <= 0x0A010000 ) { \
-	NifStream( unknownInt2, in, version ); \
-	NifStream( delta, in, version ); \
-}; \
-NifStream( numSources, in, version ); \
-sources.resize(numSources); \
-for (uint i0 = 0; i0 < sources.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_FLIP_CONTROLLER_WRITE \
-NiSingleInterpolatorController::Write( out, link_map, version, user_version ); \
-NifStream( textureSlot, out, version ); \
-if ( version <= 0x0A010000 ) { \
-	NifStream( unknownInt2, out, version ); \
-	NifStream( delta, out, version ); \
-}; \
-NifStream( numSources, out, version ); \
-for (uint i0 = 0; i0 < sources.size(); i0++) { \
-	if ( sources[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(sources[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_FLIP_CONTROLLER_STRING \
-stringstream out; \
-out << NiSingleInterpolatorController::asString(); \
-out << "Texture Slot:  " << textureSlot << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-out << "Delta:  " << delta << endl; \
-out << "Num Sources:  " << numSources << endl; \
-for (uint i0 = 0; i0 < sources.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Sources[" << i0 << "]:  " << sources[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_FLIP_CONTROLLER_FIXLINKS \
-NiSingleInterpolatorController::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < sources.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		sources[i0] = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( sources[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		sources[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_FLIP_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiSingleInterpolatorController::GetRefs(); \
-for (uint i0 = 0; i0 < sources.size(); i0++) { \
-	if ( sources[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(sources[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_FLOAT_DATA_MEMBERS \
 KeyGroup<float > data; \
@@ -6203,49 +2548,19 @@ KeyGroup<float > data; \
 #define NI_FLOAT_DATA_CONSTRUCT \
 
 #define NI_FLOAT_DATA_READ \
-AKeyedData::Read( in, link_stack, version, user_version ); \
-NifStream( data.numKeys, in, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, in, version ); \
-}; \
-data.keys.resize(data.numKeys); \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], in, version, data.interpolation ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_FLOAT_DATA_WRITE \
-AKeyedData::Write( out, link_map, version, user_version ); \
-NifStream( data.numKeys, out, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, out, version ); \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], out, version, data.interpolation ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_FLOAT_DATA_STRING \
-stringstream out; \
-out << AKeyedData::asString(); \
-out << "Num Keys:  " << data.numKeys << endl; \
-if ( (data.numKeys != 0) ) { \
-	out << "  Interpolation:  " << data.interpolation << endl; \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Keys[" << i0 << "]:  " << data.keys[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_FLOAT_DATA_FIXLINKS \
-AKeyedData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_FLOAT_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AKeyedData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_FLOAT_EXTRA_DATA_MEMBERS \
 float floatData; \
@@ -6258,26 +2573,19 @@ float floatData; \
  : floatData(0.0f) \
 
 #define NI_FLOAT_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( floatData, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_FLOAT_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( floatData, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_FLOAT_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Float Data:  " << floatData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_FLOAT_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_FLOAT_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_FLOAT_EXTRA_DATA_CONTROLLER_MEMBERS \
 Ref<NiObject > unknownLink; \
@@ -6291,51 +2599,19 @@ string unknownString; \
  : unknownLink(NULL) \
 
 #define NI_FLOAT_EXTRA_DATA_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x14000004 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( unknownString, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_FLOAT_EXTRA_DATA_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( version >= 0x14000004 ) { \
-	if ( unknownLink != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( unknownString, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_FLOAT_EXTRA_DATA_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown Link:  " << unknownLink << endl; \
-out << "Unknown String:  " << unknownString << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_FLOAT_EXTRA_DATA_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if ( version >= 0x14000004 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		unknownLink = DynamicCast<NiObject>(objects[link_stack.front()]); \
-		if ( unknownLink == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		unknownLink = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_FLOAT_EXTRA_DATA_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( unknownLink != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_FLOAT_INTERPOLATOR_MEMBERS \
 float floatValue; \
@@ -6349,48 +2625,22 @@ Ref<NiFloatData > data; \
  : floatValue(0.0f), data(NULL) \
 
 #define NI_FLOAT_INTERPOLATOR_READ \
-uint block_num; \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( floatValue, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_FLOAT_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( floatValue, out, version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_FLOAT_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Float Value:  " << floatValue << endl; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_FLOAT_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiFloatData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_FLOAT_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_FLOATS_EXTRA_DATA_MEMBERS \
-uint numFloats; \
+mutable uint numFloats; \
 vector<float > data; \
 
 #define NI_FLOATS_EXTRA_DATA_INCLUDE "NiExtraData.h" \
@@ -6401,40 +2651,19 @@ vector<float > data; \
  : numFloats((uint)0) \
 
 #define NI_FLOATS_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( numFloats, in, version ); \
-data.resize(numFloats); \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	NifStream( data[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_FLOATS_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( numFloats, out, version ); \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	NifStream( data[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_FLOATS_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Num Floats:  " << numFloats << endl; \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Data[" << i0 << "]:  " << data[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_FLOATS_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_FLOATS_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_FOG_PROPERTY_MEMBERS \
 ushort flags; \
@@ -6449,41 +2678,28 @@ Color3 fogColor; \
  : flags((ushort)0), fogDepth(0.0f) \
 
 #define NI_FOG_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
-NifStream( fogDepth, in, version ); \
-NifStream( fogColor, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_FOG_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
-NifStream( fogDepth, out, version ); \
-NifStream( fogColor, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_FOG_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Fog Depth:  " << fogDepth << endl; \
-out << "Fog Color:  " << fogColor << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_FOG_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_FOG_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_GEOM_MORPHER_CONTROLLER_MEMBERS \
 ushort unknown; \
 byte unknown2; \
 Ref<NiMorphData > data; \
 byte unknownByte; \
-uint numInterpolators; \
+mutable uint numInterpolators; \
 vector<Ref<NiInterpolator > > interpolators; \
-uint numUnknownInts; \
+mutable uint numUnknownInts; \
 vector<uint > unknownInts; \
 
 #define NI_GEOM_MORPHER_CONTROLLER_INCLUDE "NiTimeController.h" \
@@ -6494,122 +2710,19 @@ vector<uint > unknownInts; \
  : unknown((ushort)0), unknown2((byte)0), data(NULL), unknownByte((byte)0), numInterpolators((uint)0), numUnknownInts((uint)0) \
 
 #define NI_GEOM_MORPHER_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknown, in, version ); \
-}; \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	NifStream( unknown2, in, version ); \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( unknownByte, in, version ); \
-if ( version >= 0x0A01006A ) { \
-	NifStream( numInterpolators, in, version ); \
-	interpolators.resize(numInterpolators); \
-	for (uint i1 = 0; i1 < interpolators.size(); i1++) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( numUnknownInts, in, version ); \
-	unknownInts.resize(numUnknownInts); \
-	for (uint i1 = 0; i1 < unknownInts.size(); i1++) { \
-		NifStream( unknownInts[i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_GEOM_MORPHER_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknown, out, version ); \
-}; \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	NifStream( unknown2, out, version ); \
-}; \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( unknownByte, out, version ); \
-if ( version >= 0x0A01006A ) { \
-	NifStream( numInterpolators, out, version ); \
-	for (uint i1 = 0; i1 < interpolators.size(); i1++) { \
-		if ( interpolators[i1] != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(interpolators[i1])], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( numUnknownInts, out, version ); \
-	for (uint i1 = 0; i1 < unknownInts.size(); i1++) { \
-		NifStream( unknownInts[i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_GEOM_MORPHER_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown:  " << unknown << endl; \
-out << "Unknown 2:  " << unknown2 << endl; \
-out << "Data:  " << data << endl; \
-out << "Unknown Byte:  " << unknownByte << endl; \
-out << "Num Interpolators:  " << numInterpolators << endl; \
-for (uint i0 = 0; i0 < interpolators.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Interpolators[" << i0 << "]:  " << interpolators[i0] << endl; \
-}; \
-out << "Num Unknown Ints:  " << numUnknownInts << endl; \
-for (uint i0 = 0; i0 < unknownInts.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Ints[" << i0 << "]:  " << unknownInts[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_GEOM_MORPHER_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiMorphData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
-if ( version >= 0x0A01006A ) { \
-	for (uint i1 = 0; i1 < interpolators.size(); i1++) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			interpolators[i1] = DynamicCast<NiInterpolator>(objects[link_stack.front()]); \
-			if ( interpolators[i1] == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			interpolators[i1] = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_GEOM_MORPHER_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-for (uint i0 = 0; i0 < interpolators.size(); i0++) { \
-	if ( interpolators[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(interpolators[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_GRAVITY_MEMBERS \
 float unknownFloat1; \
@@ -6626,38 +2739,19 @@ Vector3 direction; \
  : unknownFloat1(0.0f), force(0.0f), type((uint)0) \
 
 #define NI_GRAVITY_READ \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( force, in, version ); \
-NifStream( type, in, version ); \
-NifStream( position, in, version ); \
-NifStream( direction, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_GRAVITY_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( force, out, version ); \
-NifStream( type, out, version ); \
-NifStream( position, out, version ); \
-NifStream( direction, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_GRAVITY_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Force:  " << force << endl; \
-out << "Type:  " << type << endl; \
-out << "Position:  " << position << endl; \
-out << "Direction:  " << direction << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_GRAVITY_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_GRAVITY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_INTEGER_EXTRA_DATA_MEMBERS \
 uint integerData; \
@@ -6670,29 +2764,22 @@ uint integerData; \
  : integerData((uint)0) \
 
 #define NI_INTEGER_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( integerData, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_INTEGER_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( integerData, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_INTEGER_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Integer Data:  " << integerData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_INTEGER_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_INTEGER_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_INTEGERS_EXTRA_DATA_MEMBERS \
-uint numIntegers; \
+mutable uint numIntegers; \
 vector<uint > data; \
 
 #define NI_INTEGERS_EXTRA_DATA_INCLUDE "NiExtraData.h" \
@@ -6703,40 +2790,19 @@ vector<uint > data; \
  : numIntegers((uint)0) \
 
 #define NI_INTEGERS_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( numIntegers, in, version ); \
-data.resize(numIntegers); \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	NifStream( data[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_INTEGERS_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( numIntegers, out, version ); \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	NifStream( data[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_INTEGERS_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Num Integers:  " << numIntegers << endl; \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Data[" << i0 << "]:  " << data[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_INTEGERS_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_INTEGERS_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_KEYFRAME_CONTROLLER_MEMBERS \
 Ref<NiKeyframeData > data; \
@@ -6749,42 +2815,19 @@ Ref<NiKeyframeData > data; \
  : data(NULL) \
 
 #define NI_KEYFRAME_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_KEYFRAME_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_KEYFRAME_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_KEYFRAME_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiKeyframeData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_KEYFRAME_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define B_S_KEYFRAME_CONTROLLER_MEMBERS \
 Ref<NiKeyframeData > data2; \
@@ -6797,49 +2840,26 @@ Ref<NiKeyframeData > data2; \
  : data2(NULL) \
 
 #define B_S_KEYFRAME_CONTROLLER_READ \
-uint block_num; \
-NiKeyframeController::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define B_S_KEYFRAME_CONTROLLER_WRITE \
-NiKeyframeController::Write( out, link_map, version, user_version ); \
-if ( data2 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data2)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define B_S_KEYFRAME_CONTROLLER_STRING \
-stringstream out; \
-out << NiKeyframeController::asString(); \
-out << "Data 2:  " << data2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define B_S_KEYFRAME_CONTROLLER_FIXLINKS \
-NiKeyframeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data2 = DynamicCast<NiKeyframeData>(objects[link_stack.front()]); \
-	if ( data2 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data2 = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define B_S_KEYFRAME_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiKeyframeController::GetRefs(); \
-if ( data2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data2)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_KEYFRAME_DATA_MEMBERS \
-uint numRotationKeys; \
+mutable uint numRotationKeys; \
 KeyType rotationType; \
 vector<Key<Quaternion > > quaternionKeys; \
 float unknownFloat; \
-KeyGroup<float > xyzRotations[3]; \
+array<KeyGroup<float >,3> xyzRotations; \
 KeyGroup<Vector3 > translations; \
 KeyGroup<float > scales; \
 
@@ -6851,156 +2871,19 @@ KeyGroup<float > scales; \
  : numRotationKeys((uint)0), rotationType((KeyType)0), unknownFloat(0.0f) \
 
 #define NI_KEYFRAME_DATA_READ \
-AKeyedData::Read( in, link_stack, version, user_version ); \
-NifStream( numRotationKeys, in, version ); \
-if ( (numRotationKeys != 0) ) { \
-	NifStream( rotationType, in, version ); \
-}; \
-if ( (rotationType != 4) ) { \
-	quaternionKeys.resize(numRotationKeys); \
-	for (uint i1 = 0; i1 < quaternionKeys.size(); i1++) { \
-		NifStream( quaternionKeys[i1], in, version, rotationType ); \
-	}; \
-}; \
-if ( version <= 0x0A010000 ) { \
-	if ( (rotationType == 4) ) { \
-		NifStream( unknownFloat, in, version ); \
-	}; \
-}; \
-if ( (rotationType == 4) ) { \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		NifStream( xyzRotations[i1].numKeys, in, version ); \
-		if ( (xyzRotations[i1].numKeys != 0) ) { \
-			NifStream( xyzRotations[i1].interpolation, in, version ); \
-		}; \
-		xyzRotations[i1].keys.resize(xyzRotations[i1].numKeys); \
-		for (uint i2 = 0; i2 < xyzRotations[i1].keys.size(); i2++) { \
-			NifStream( xyzRotations[i1].keys[i2], in, version, xyzRotations[i1].interpolation ); \
-		}; \
-	}; \
-}; \
-NifStream( translations.numKeys, in, version ); \
-if ( (translations.numKeys != 0) ) { \
-	NifStream( translations.interpolation, in, version ); \
-}; \
-translations.keys.resize(translations.numKeys); \
-for (uint i0 = 0; i0 < translations.keys.size(); i0++) { \
-	NifStream( translations.keys[i0], in, version, translations.interpolation ); \
-}; \
-NifStream( scales.numKeys, in, version ); \
-if ( (scales.numKeys != 0) ) { \
-	NifStream( scales.interpolation, in, version ); \
-}; \
-scales.keys.resize(scales.numKeys); \
-for (uint i0 = 0; i0 < scales.keys.size(); i0++) { \
-	NifStream( scales.keys[i0], in, version, scales.interpolation ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_KEYFRAME_DATA_WRITE \
-AKeyedData::Write( out, link_map, version, user_version ); \
-NifStream( numRotationKeys, out, version ); \
-if ( (numRotationKeys != 0) ) { \
-	NifStream( rotationType, out, version ); \
-}; \
-if ( (rotationType != 4) ) { \
-	for (uint i1 = 0; i1 < quaternionKeys.size(); i1++) { \
-		NifStream( quaternionKeys[i1], out, version, rotationType ); \
-	}; \
-}; \
-if ( version <= 0x0A010000 ) { \
-	if ( (rotationType == 4) ) { \
-		NifStream( unknownFloat, out, version ); \
-	}; \
-}; \
-if ( (rotationType == 4) ) { \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		NifStream( xyzRotations[i1].numKeys, out, version ); \
-		if ( (xyzRotations[i1].numKeys != 0) ) { \
-			NifStream( xyzRotations[i1].interpolation, out, version ); \
-		}; \
-		for (uint i2 = 0; i2 < xyzRotations[i1].keys.size(); i2++) { \
-			NifStream( xyzRotations[i1].keys[i2], out, version, xyzRotations[i1].interpolation ); \
-		}; \
-	}; \
-}; \
-NifStream( translations.numKeys, out, version ); \
-if ( (translations.numKeys != 0) ) { \
-	NifStream( translations.interpolation, out, version ); \
-}; \
-for (uint i0 = 0; i0 < translations.keys.size(); i0++) { \
-	NifStream( translations.keys[i0], out, version, translations.interpolation ); \
-}; \
-NifStream( scales.numKeys, out, version ); \
-if ( (scales.numKeys != 0) ) { \
-	NifStream( scales.interpolation, out, version ); \
-}; \
-for (uint i0 = 0; i0 < scales.keys.size(); i0++) { \
-	NifStream( scales.keys[i0], out, version, scales.interpolation ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_KEYFRAME_DATA_STRING \
-stringstream out; \
-out << AKeyedData::asString(); \
-out << "Num Rotation Keys:  " << numRotationKeys << endl; \
-if ( (numRotationKeys != 0) ) { \
-	out << "  Rotation Type:  " << rotationType << endl; \
-}; \
-if ( (rotationType != 4) ) { \
-	for (uint i1 = 0; i1 < quaternionKeys.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Quaternion Keys[" << i1 << "]:  " << quaternionKeys[i1] << endl; \
-	}; \
-}; \
-if ( (rotationType == 4) ) { \
-	out << "  Unknown Float:  " << unknownFloat << endl; \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		out << "    Num Keys:  " << xyzRotations[i1].numKeys << endl; \
-		if ( (xyzRotations[i1].numKeys != 0) ) { \
-			out << "      Interpolation:  " << xyzRotations[i1].interpolation << endl; \
-		}; \
-		for (uint i2 = 0; i2 < xyzRotations[i1].keys.size(); i2++) { \
-			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) { \
-				out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-				break; \
-			}; \
-			out << "      Keys[" << i2 << "]:  " << xyzRotations[i1].keys[i2] << endl; \
-		}; \
-	}; \
-}; \
-out << "Num Keys:  " << translations.numKeys << endl; \
-if ( (translations.numKeys != 0) ) { \
-	out << "  Interpolation:  " << translations.interpolation << endl; \
-}; \
-for (uint i0 = 0; i0 < translations.keys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Keys[" << i0 << "]:  " << translations.keys[i0] << endl; \
-}; \
-out << "Num Keys:  " << scales.numKeys << endl; \
-if ( (scales.numKeys != 0) ) { \
-	out << "  Interpolation:  " << scales.interpolation << endl; \
-}; \
-for (uint i0 = 0; i0 < scales.keys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Keys[" << i0 << "]:  " << scales.keys[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_KEYFRAME_DATA_FIXLINKS \
-AKeyedData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_KEYFRAME_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AKeyedData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_LIGHT_COLOR_CONTROLLER_MEMBERS \
 ushort unknownShort; \
@@ -7015,81 +2898,19 @@ Ref<NiPoint3Interpolator > interpolator; \
  : unknownShort((ushort)0), data(NULL), interpolator(NULL) \
 
 #define NI_LIGHT_COLOR_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-if ( ( version >= 0x0A010000 ) && ( version <= 0x0A010000 ) ) { \
-	NifStream( unknownShort, in, version ); \
-}; \
-if ( version <= 0x0A010000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( unknownShort, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_LIGHT_COLOR_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( ( version >= 0x0A010000 ) && ( version <= 0x0A010000 ) ) { \
-	NifStream( unknownShort, out, version ); \
-}; \
-if ( version <= 0x0A010000 ) { \
-	if ( data != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if ( interpolator != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(interpolator)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( unknownShort, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_LIGHT_COLOR_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Data:  " << data << endl; \
-out << "Interpolator:  " << interpolator << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_LIGHT_COLOR_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		data = DynamicCast<NiPosData>(objects[link_stack.front()]); \
-		if ( data == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		data = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		interpolator = DynamicCast<NiPoint3Interpolator>(objects[link_stack.front()]); \
-		if ( interpolator == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		interpolator = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_LIGHT_COLOR_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-if ( interpolator != NULL ) \
-	refs.push_back(StaticCast<NiObject>(interpolator)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_LIGHT_DIMMER_CONTROLLER_MEMBERS \
 Ref<NiInterpolator > unknownLink; \
@@ -7102,42 +2923,19 @@ Ref<NiInterpolator > unknownLink; \
  : unknownLink(NULL) \
 
 #define NI_LIGHT_DIMMER_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_LIGHT_DIMMER_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( unknownLink != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_LIGHT_DIMMER_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown Link:  " << unknownLink << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_LIGHT_DIMMER_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink = DynamicCast<NiInterpolator>(objects[link_stack.front()]); \
-	if ( unknownLink == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_LIGHT_DIMMER_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( unknownLink != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_LOOK_AT_CONTROLLER_MEMBERS \
 ushort unknown1; \
@@ -7151,49 +2949,19 @@ Ref<NiNode > lookAtNode; \
  : unknown1((ushort)0), lookAtNode(NULL) \
 
 #define NI_LOOK_AT_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknown1, in, version ); \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_LOOK_AT_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknown1, out, version ); \
-}; \
-if ( lookAtNode != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(lookAtNode)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_LOOK_AT_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown1:  " << unknown1 << endl; \
-out << "Look At Node:  " << lookAtNode << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_LOOK_AT_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	lookAtNode = DynamicCast<NiNode>(objects[link_stack.front()]); \
-	if ( lookAtNode == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	lookAtNode = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_LOOK_AT_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( lookAtNode != NULL ) \
-	refs.push_back(StaticCast<NiObject>(lookAtNode)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_LOOK_AT_INTERPOLATOR_MEMBERS \
 ushort unknownShort; \
@@ -7214,111 +2982,19 @@ Ref<NiFloatInterpolator > unknownLink3; \
  : unknownShort((ushort)0), lookAt(NULL), unknownFloat(0.0f), scale(0.0f), unknownLink1(NULL), unknownLink2(NULL), unknownLink3(NULL) \
 
 #define NI_LOOK_AT_INTERPOLATOR_READ \
-uint block_num; \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( unknownShort, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( unknownFloat, in, version ); \
-NifStream( translation, in, version ); \
-NifStream( rotation, in, version ); \
-NifStream( scale, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_LOOK_AT_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( unknownShort, out, version ); \
-if ( lookAt != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(lookAt)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( unknownFloat, out, version ); \
-NifStream( translation, out, version ); \
-NifStream( rotation, out, version ); \
-NifStream( scale, out, version ); \
-if ( unknownLink1 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink1)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( unknownLink2 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink2)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( unknownLink3 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink3)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_LOOK_AT_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Look At:  " << lookAt << endl; \
-out << "Unknown Float:  " << unknownFloat << endl; \
-out << "Translation:  " << translation << endl; \
-out << "Rotation:  " << rotation << endl; \
-out << "Scale:  " << scale << endl; \
-out << "Unknown Link 1:  " << unknownLink1 << endl; \
-out << "Unknown Link 2:  " << unknownLink2 << endl; \
-out << "Unknown Link 3:  " << unknownLink3 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_LOOK_AT_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	lookAt = DynamicCast<NiNode>(objects[link_stack.front()]); \
-	if ( lookAt == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	lookAt = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink1 = DynamicCast<NiPoint3Interpolator>(objects[link_stack.front()]); \
-	if ( unknownLink1 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink1 = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink2 = DynamicCast<NiFloatInterpolator>(objects[link_stack.front()]); \
-	if ( unknownLink2 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink2 = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink3 = DynamicCast<NiFloatInterpolator>(objects[link_stack.front()]); \
-	if ( unknownLink3 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink3 = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_LOOK_AT_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-if ( lookAt != NULL ) \
-	refs.push_back(StaticCast<NiObject>(lookAt)); \
-if ( unknownLink1 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink1)); \
-if ( unknownLink2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink2)); \
-if ( unknownLink3 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink3)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_MATERIAL_COLOR_CONTROLLER_MEMBERS \
 ushort unknown; \
@@ -7332,55 +3008,19 @@ Ref<NiPosData > data; \
  : unknown((ushort)0), data(NULL) \
 
 #define NI_MATERIAL_COLOR_CONTROLLER_READ \
-uint block_num; \
-NiSingleInterpolatorController::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknown, in, version ); \
-}; \
-if ( version <= 0x0A010000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_MATERIAL_COLOR_CONTROLLER_WRITE \
-NiSingleInterpolatorController::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknown, out, version ); \
-}; \
-if ( version <= 0x0A010000 ) { \
-	if ( data != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_MATERIAL_COLOR_CONTROLLER_STRING \
-stringstream out; \
-out << NiSingleInterpolatorController::asString(); \
-out << "Unknown:  " << unknown << endl; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_MATERIAL_COLOR_CONTROLLER_FIXLINKS \
-NiSingleInterpolatorController::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		data = DynamicCast<NiPosData>(objects[link_stack.front()]); \
-		if ( data == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		data = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_MATERIAL_COLOR_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiSingleInterpolatorController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_MATERIAL_PROPERTY_MEMBERS \
 ushort flags; \
@@ -7399,48 +3039,19 @@ float alpha; \
  : flags((ushort)0), glossiness(0.0f), alpha(0.0f) \
 
 #define NI_MATERIAL_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x0A000102 ) { \
-	NifStream( flags, in, version ); \
-}; \
-NifStream( ambientColor, in, version ); \
-NifStream( diffuseColor, in, version ); \
-NifStream( specularColor, in, version ); \
-NifStream( emissiveColor, in, version ); \
-NifStream( glossiness, in, version ); \
-NifStream( alpha, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_MATERIAL_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-if ( version <= 0x0A000102 ) { \
-	NifStream( flags, out, version ); \
-}; \
-NifStream( ambientColor, out, version ); \
-NifStream( diffuseColor, out, version ); \
-NifStream( specularColor, out, version ); \
-NifStream( emissiveColor, out, version ); \
-NifStream( glossiness, out, version ); \
-NifStream( alpha, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_MATERIAL_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Ambient Color:  " << ambientColor << endl; \
-out << "Diffuse Color:  " << diffuseColor << endl; \
-out << "Specular Color:  " << specularColor << endl; \
-out << "Emissive Color:  " << emissiveColor << endl; \
-out << "Glossiness:  " << glossiness << endl; \
-out << "Alpha:  " << alpha << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_MATERIAL_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_MATERIAL_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_MESH_P_SYS_DATA_MEMBERS \
 byte unknownByte11; \
@@ -7450,7 +3061,7 @@ vector< array<float,12> > unknownFloats5; \
 uint unknownInt1; \
 Ref<NiPSysModifier > modifier; \
 byte unknownByte2; \
-uint numUnknownLinks; \
+mutable uint numUnknownLinks; \
 vector<Ref<NiPSysModifier > > unknownLinks; \
 ushort unknownShort4; \
 uint unknownInt2; \
@@ -7467,217 +3078,22 @@ Ref<NiNode > unknownLink2; \
  : unknownByte11((byte)0), unknownInt1((uint)0), modifier(NULL), unknownByte2((byte)0), numUnknownLinks((uint)0), unknownShort4((ushort)0), unknownInt2((uint)0), unknownByte12((byte)0), unknownInt3((uint)0), unknownInt4((uint)0), unknownLink2(NULL) \
 
 #define NI_MESH_P_SYS_DATA_READ \
-uint block_num; \
-APSysData::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x14000005 ) { \
-	NifStream( unknownByte11, in, version ); \
-}; \
-if ( version <= 0x14000004 ) { \
-	unknownFloats3.resize(numVertices); \
-	for (uint i1 = 0; i1 < unknownFloats3.size(); i1++) { \
-		for (uint i2 = 0; i2 < 4; i2++) { \
-			NifStream( unknownFloats3[i1][i2], in, version ); \
-		}; \
-	}; \
-	unknownFloats4.resize(numVertices); \
-	for (uint i1 = 0; i1 < unknownFloats4.size(); i1++) { \
-		for (uint i2 = 0; i2 < 10; i2++) { \
-			NifStream( unknownFloats4[i1][i2], in, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x14000005 ) { \
-	unknownFloats5.resize(numVertices); \
-	for (uint i1 = 0; i1 < unknownFloats5.size(); i1++) { \
-		for (uint i2 = 0; i2 < 12; i2++) { \
-			NifStream( unknownFloats5[i1][i2], in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( unknownInt1, in, version ); \
-if ( version <= 0x14000004 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-if ( ( version >= 0x0A020000 ) && ( version <= 0x14000004 ) ) { \
-	NifStream( unknownByte2, in, version ); \
-	NifStream( numUnknownLinks, in, version ); \
-	unknownLinks.resize(numUnknownLinks); \
-	for (uint i1 = 0; i1 < unknownLinks.size(); i1++) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
-if ( version >= 0x14000005 ) { \
-	NifStream( unknownShort4, in, version ); \
-	NifStream( unknownInt2, in, version ); \
-	NifStream( unknownByte12, in, version ); \
-	NifStream( unknownInt3, in, version ); \
-	NifStream( unknownInt4, in, version ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_MESH_P_SYS_DATA_WRITE \
-APSysData::Write( out, link_map, version, user_version ); \
-if ( version >= 0x14000005 ) { \
-	NifStream( unknownByte11, out, version ); \
-}; \
-if ( version <= 0x14000004 ) { \
-	for (uint i1 = 0; i1 < unknownFloats3.size(); i1++) { \
-		for (uint i2 = 0; i2 < 4; i2++) { \
-			NifStream( unknownFloats3[i1][i2], out, version ); \
-		}; \
-	}; \
-	for (uint i1 = 0; i1 < unknownFloats4.size(); i1++) { \
-		for (uint i2 = 0; i2 < 10; i2++) { \
-			NifStream( unknownFloats4[i1][i2], out, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x14000005 ) { \
-	for (uint i1 = 0; i1 < unknownFloats5.size(); i1++) { \
-		for (uint i2 = 0; i2 < 12; i2++) { \
-			NifStream( unknownFloats5[i1][i2], out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( unknownInt1, out, version ); \
-if ( version <= 0x14000004 ) { \
-	if ( modifier != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(modifier)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( ( version >= 0x0A020000 ) && ( version <= 0x14000004 ) ) { \
-	NifStream( unknownByte2, out, version ); \
-	NifStream( numUnknownLinks, out, version ); \
-	for (uint i1 = 0; i1 < unknownLinks.size(); i1++) { \
-		if ( unknownLinks[i1] != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(unknownLinks[i1])], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
-if ( version >= 0x14000005 ) { \
-	NifStream( unknownShort4, out, version ); \
-	NifStream( unknownInt2, out, version ); \
-	NifStream( unknownByte12, out, version ); \
-	NifStream( unknownInt3, out, version ); \
-	NifStream( unknownInt4, out, version ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if ( unknownLink2 != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(unknownLink2)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_MESH_P_SYS_DATA_STRING \
-stringstream out; \
-out << APSysData::asString(); \
-out << "Unknown Byte 11:  " << unknownByte11 << endl; \
-for (uint i0 = 0; i0 < unknownFloats3.size(); i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats 3[" << i0 << "][" << i1 << "]:  " << unknownFloats3[i0][i1] << endl; \
-	}; \
-}; \
-for (uint i0 = 0; i0 < unknownFloats4.size(); i0++) { \
-	for (uint i1 = 0; i1 < 10; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats 4[" << i0 << "][" << i1 << "]:  " << unknownFloats4[i0][i1] << endl; \
-	}; \
-}; \
-for (uint i0 = 0; i0 < unknownFloats5.size(); i0++) { \
-	for (uint i1 = 0; i1 < 12; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats 5[" << i0 << "][" << i1 << "]:  " << unknownFloats5[i0][i1] << endl; \
-	}; \
-}; \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-out << "Modifier:  " << modifier << endl; \
-out << "Unknown Byte 2:  " << unknownByte2 << endl; \
-out << "Num Unknown Links:  " << numUnknownLinks << endl; \
-for (uint i0 = 0; i0 < unknownLinks.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Links[" << i0 << "]:  " << unknownLinks[i0] << endl; \
-}; \
-out << "Unknown Short 4:  " << unknownShort4 << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-out << "Unknown Byte 12:  " << unknownByte12 << endl; \
-out << "Unknown Int 3:  " << unknownInt3 << endl; \
-out << "Unknown Int 4:  " << unknownInt4 << endl; \
-out << "Unknown Link 2:  " << unknownLink2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_MESH_P_SYS_DATA_FIXLINKS \
-APSysData::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x14000004 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		modifier = DynamicCast<NiPSysModifier>(objects[link_stack.front()]); \
-		if ( modifier == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		modifier = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( ( version >= 0x0A020000 ) && ( version <= 0x14000004 ) ) { \
-	for (uint i1 = 0; i1 < unknownLinks.size(); i1++) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			unknownLinks[i1] = DynamicCast<NiPSysModifier>(objects[link_stack.front()]); \
-			if ( unknownLinks[i1] == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			unknownLinks[i1] = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		unknownLink2 = DynamicCast<NiNode>(objects[link_stack.front()]); \
-		if ( unknownLink2 == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		unknownLink2 = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_MESH_P_SYS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysData::GetRefs(); \
-if ( modifier != NULL ) \
-	refs.push_back(StaticCast<NiObject>(modifier)); \
-for (uint i0 = 0; i0 < unknownLinks.size(); i0++) { \
-	if ( unknownLinks[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(unknownLinks[i0])); \
-}; \
-if ( unknownLink2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink2)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_MORPH_DATA_MEMBERS \
-uint numMorphs; \
+mutable uint numMorphs; \
 uint numVertices; \
 byte unknownByte; \
 vector<Morph > morphs; \
@@ -7690,94 +3106,22 @@ vector<Morph > morphs; \
  : numMorphs((uint)0), numVertices((uint)0), unknownByte((byte)0) \
 
 #define NI_MORPH_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( numMorphs, in, version ); \
-NifStream( numVertices, in, version ); \
-NifStream( unknownByte, in, version ); \
-morphs.resize(numMorphs); \
-for (uint i0 = 0; i0 < morphs.size(); i0++) { \
-	if ( version >= 0x0A01006A ) { \
-		NifStream( morphs[i0].frameName, in, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		NifStream( morphs[i0].numMorphKeys, in, version ); \
-		NifStream( morphs[i0].morphInterpolation, in, version ); \
-		morphs[i0].morphKeys.resize(morphs[i0].numMorphKeys); \
-		for (uint i2 = 0; i2 < morphs[i0].morphKeys.size(); i2++) { \
-			NifStream( morphs[i0].morphKeys[i2], in, version, morphs[i0].morphInterpolation ); \
-		}; \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( morphs[i0].unknownInt, in, version ); \
-	}; \
-	morphs[i0].vectors.resize(numVertices); \
-	for (uint i1 = 0; i1 < morphs[i0].vectors.size(); i1++) { \
-		NifStream( morphs[i0].vectors[i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_MORPH_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( numMorphs, out, version ); \
-NifStream( numVertices, out, version ); \
-NifStream( unknownByte, out, version ); \
-for (uint i0 = 0; i0 < morphs.size(); i0++) { \
-	if ( version >= 0x0A01006A ) { \
-		NifStream( morphs[i0].frameName, out, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		NifStream( morphs[i0].numMorphKeys, out, version ); \
-		NifStream( morphs[i0].morphInterpolation, out, version ); \
-		for (uint i2 = 0; i2 < morphs[i0].morphKeys.size(); i2++) { \
-			NifStream( morphs[i0].morphKeys[i2], out, version, morphs[i0].morphInterpolation ); \
-		}; \
-	}; \
-	if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-		NifStream( morphs[i0].unknownInt, out, version ); \
-	}; \
-	for (uint i1 = 0; i1 < morphs[i0].vectors.size(); i1++) { \
-		NifStream( morphs[i0].vectors[i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_MORPH_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Num Morphs:  " << numMorphs << endl; \
-out << "Num Vertices:  " << numVertices << endl; \
-out << "Unknown Byte:  " << unknownByte << endl; \
-for (uint i0 = 0; i0 < morphs.size(); i0++) { \
-	out << "  Frame Name:  " << morphs[i0].frameName << endl; \
-	out << "  Num Morph Keys:  " << morphs[i0].numMorphKeys << endl; \
-	out << "  Morph Interpolation:  " << morphs[i0].morphInterpolation << endl; \
-	for (uint i1 = 0; i1 < morphs[i0].morphKeys.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Morph Keys[" << i1 << "]:  " << morphs[i0].morphKeys[i1] << endl; \
-	}; \
-	out << "  Unknown Int:  " << morphs[i0].unknownInt << endl; \
-	for (uint i1 = 0; i1 < morphs[i0].vectors.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Vectors[" << i1 << "]:  " << morphs[i0].vectors[i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_MORPH_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_MORPH_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_MULTI_TARGET_TRANSFORM_CONTROLLER_MEMBERS \
-ushort numExtraTargets; \
+mutable ushort numExtraTargets; \
 vector<NiNode * > extraTargets; \
 
 #define NI_MULTI_TARGET_TRANSFORM_CONTROLLER_INCLUDE "NiTimeController.h" \
@@ -7788,63 +3132,24 @@ vector<NiNode * > extraTargets; \
  : numExtraTargets((ushort)0) \
 
 #define NI_MULTI_TARGET_TRANSFORM_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( numExtraTargets, in, version ); \
-extraTargets.resize(numExtraTargets); \
-for (uint i0 = 0; i0 < extraTargets.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_MULTI_TARGET_TRANSFORM_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-NifStream( numExtraTargets, out, version ); \
-for (uint i0 = 0; i0 < extraTargets.size(); i0++) { \
-	if ( extraTargets[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(extraTargets[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_MULTI_TARGET_TRANSFORM_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Num Extra Targets:  " << numExtraTargets << endl; \
-for (uint i0 = 0; i0 < extraTargets.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Extra Targets[" << i0 << "]:  " << extraTargets[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_MULTI_TARGET_TRANSFORM_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < extraTargets.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		extraTargets[i0] = DynamicCast<NiNode>(objects[link_stack.front()]); \
-		if ( extraTargets[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		extraTargets[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_MULTI_TARGET_TRANSFORM_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-for (uint i0 = 0; i0 < extraTargets.size(); i0++) { \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_NODE_MEMBERS \
-uint numChildren; \
+mutable uint numChildren; \
 vector<Ref<NiAVObject > > children; \
-uint numEffects; \
+mutable uint numEffects; \
 vector<Ref<NiDynamicEffect > > effects; \
 
 #define NI_NODE_INCLUDE "NiAVObject.h" \
@@ -7855,96 +3160,19 @@ vector<Ref<NiDynamicEffect > > effects; \
  : numChildren((uint)0), numEffects((uint)0) \
 
 #define NI_NODE_READ \
-uint block_num; \
-NiAVObject::Read( in, link_stack, version, user_version ); \
-NifStream( numChildren, in, version ); \
-children.resize(numChildren); \
-for (uint i0 = 0; i0 < children.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( numEffects, in, version ); \
-effects.resize(numEffects); \
-for (uint i0 = 0; i0 < effects.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_NODE_WRITE \
-NiAVObject::Write( out, link_map, version, user_version ); \
-NifStream( numChildren, out, version ); \
-for (uint i0 = 0; i0 < children.size(); i0++) { \
-	if ( children[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(children[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-NifStream( numEffects, out, version ); \
-for (uint i0 = 0; i0 < effects.size(); i0++) { \
-	if ( effects[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(effects[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_NODE_STRING \
-stringstream out; \
-out << NiAVObject::asString(); \
-out << "Num Children:  " << numChildren << endl; \
-for (uint i0 = 0; i0 < children.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Children[" << i0 << "]:  " << children[i0] << endl; \
-}; \
-out << "Num Effects:  " << numEffects << endl; \
-for (uint i0 = 0; i0 < effects.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Effects[" << i0 << "]:  " << effects[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_NODE_FIXLINKS \
-NiAVObject::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < children.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		children[i0] = DynamicCast<NiAVObject>(objects[link_stack.front()]); \
-		if ( children[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		children[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
-for (uint i0 = 0; i0 < effects.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		effects[i0] = DynamicCast<NiDynamicEffect>(objects[link_stack.front()]); \
-		if ( effects[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		effects[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_NODE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiAVObject::GetRefs(); \
-for (uint i0 = 0; i0 < children.size(); i0++) { \
-	if ( children[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(children[i0])); \
-}; \
-for (uint i0 = 0; i0 < effects.size(); i0++) { \
-	if ( effects[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(effects[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define AVOID_NODE_MEMBERS \
 
@@ -7955,27 +3183,23 @@ return refs; \
 #define AVOID_NODE_CONSTRUCT \
 
 #define AVOID_NODE_READ \
-NiNode::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define AVOID_NODE_WRITE \
-NiNode::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define AVOID_NODE_STRING \
-stringstream out; \
-out << NiNode::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define AVOID_NODE_FIXLINKS \
-NiNode::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define AVOID_NODE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiNode::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define FX_WIDGET_MEMBERS \
 byte unknown1; \
-byte unknown292Bytes[292]; \
+array<byte,292> unknown292Bytes; \
 
 #define FX_WIDGET_INCLUDE "NiNode.h" \
 
@@ -7985,39 +3209,19 @@ byte unknown292Bytes[292]; \
  : unknown1((byte)0) \
 
 #define FX_WIDGET_READ \
-NiNode::Read( in, link_stack, version, user_version ); \
-NifStream( unknown1, in, version ); \
-for (uint i0 = 0; i0 < 292; i0++) { \
-	NifStream( unknown292Bytes[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define FX_WIDGET_WRITE \
-NiNode::Write( out, link_map, version, user_version ); \
-NifStream( unknown1, out, version ); \
-for (uint i0 = 0; i0 < 292; i0++) { \
-	NifStream( unknown292Bytes[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define FX_WIDGET_STRING \
-stringstream out; \
-out << NiNode::asString(); \
-out << "Unknown1:  " << unknown1 << endl; \
-for (uint i0 = 0; i0 < 292; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown 292 Bytes[" << i0 << "]:  " << unknown292Bytes[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define FX_WIDGET_FIXLINKS \
-NiNode::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define FX_WIDGET_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiNode::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define FX_BUTTON_MEMBERS \
 
@@ -8028,29 +3232,25 @@ return refs; \
 #define FX_BUTTON_CONSTRUCT \
 
 #define FX_BUTTON_READ \
-FxWidget::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define FX_BUTTON_WRITE \
-FxWidget::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define FX_BUTTON_STRING \
-stringstream out; \
-out << FxWidget::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define FX_BUTTON_FIXLINKS \
-FxWidget::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define FX_BUTTON_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = FxWidget::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define FX_RADIO_BUTTON_MEMBERS \
 uint unknownInt1; \
 uint unknownInt2; \
 uint unknownInt3; \
-uint numUnknownLinks; \
+mutable uint numUnknownLinks; \
 vector<Ref<NiObject > > unknownLinks; \
 
 #define FX_RADIO_BUTTON_INCLUDE "FxWidget.h" \
@@ -8061,69 +3261,19 @@ vector<Ref<NiObject > > unknownLinks; \
  : unknownInt1((uint)0), unknownInt2((uint)0), unknownInt3((uint)0), numUnknownLinks((uint)0) \
 
 #define FX_RADIO_BUTTON_READ \
-uint block_num; \
-FxWidget::Read( in, link_stack, version, user_version ); \
-NifStream( unknownInt1, in, version ); \
-NifStream( unknownInt2, in, version ); \
-NifStream( unknownInt3, in, version ); \
-NifStream( numUnknownLinks, in, version ); \
-unknownLinks.resize(numUnknownLinks); \
-for (uint i0 = 0; i0 < unknownLinks.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define FX_RADIO_BUTTON_WRITE \
-FxWidget::Write( out, link_map, version, user_version ); \
-NifStream( unknownInt1, out, version ); \
-NifStream( unknownInt2, out, version ); \
-NifStream( unknownInt3, out, version ); \
-NifStream( numUnknownLinks, out, version ); \
-for (uint i0 = 0; i0 < unknownLinks.size(); i0++) { \
-	if ( unknownLinks[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(unknownLinks[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define FX_RADIO_BUTTON_STRING \
-stringstream out; \
-out << FxWidget::asString(); \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-out << "Unknown Int  2:  " << unknownInt2 << endl; \
-out << "Unknown Int 3:  " << unknownInt3 << endl; \
-out << "Num Unknown Links:  " << numUnknownLinks << endl; \
-for (uint i0 = 0; i0 < unknownLinks.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Links[" << i0 << "]:  " << unknownLinks[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define FX_RADIO_BUTTON_FIXLINKS \
-FxWidget::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < unknownLinks.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		unknownLinks[i0] = DynamicCast<NiObject>(objects[link_stack.front()]); \
-		if ( unknownLinks[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		unknownLinks[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define FX_RADIO_BUTTON_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = FxWidget::GetRefs(); \
-for (uint i0 = 0; i0 < unknownLinks.size(); i0++) { \
-	if ( unknownLinks[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(unknownLinks[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_BILLBOARD_NODE_MEMBERS \
 ushort billboardMode; \
@@ -8136,30 +3286,19 @@ ushort billboardMode; \
  : billboardMode((ushort)0) \
 
 #define NI_BILLBOARD_NODE_READ \
-NiNode::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( billboardMode, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_BILLBOARD_NODE_WRITE \
-NiNode::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( billboardMode, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_BILLBOARD_NODE_STRING \
-stringstream out; \
-out << NiNode::asString(); \
-out << "Billboard Mode:  " << billboardMode << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_BILLBOARD_NODE_FIXLINKS \
-NiNode::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_BILLBOARD_NODE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiNode::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_S_ANIMATION_NODE_MEMBERS \
 
@@ -8170,23 +3309,19 @@ return refs; \
 #define NI_B_S_ANIMATION_NODE_CONSTRUCT \
 
 #define NI_B_S_ANIMATION_NODE_READ \
-NiNode::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_S_ANIMATION_NODE_WRITE \
-NiNode::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_S_ANIMATION_NODE_STRING \
-stringstream out; \
-out << NiNode::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_S_ANIMATION_NODE_FIXLINKS \
-NiNode::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_S_ANIMATION_NODE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiNode::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_S_PARTICLE_NODE_MEMBERS \
 
@@ -8197,28 +3332,24 @@ return refs; \
 #define NI_B_S_PARTICLE_NODE_CONSTRUCT \
 
 #define NI_B_S_PARTICLE_NODE_READ \
-NiNode::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_S_PARTICLE_NODE_WRITE \
-NiNode::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_S_PARTICLE_NODE_STRING \
-stringstream out; \
-out << NiNode::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_S_PARTICLE_NODE_FIXLINKS \
-NiNode::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_S_PARTICLE_NODE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiNode::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_L_O_D_NODE_MEMBERS \
 uint lodType; \
 Vector3 lodCenter; \
-uint numLodLevels; \
+mutable uint numLodLevels; \
 vector<LODRange > lodLevels; \
 ushort unknownShort; \
 Ref<NiRangeLODData > rangeData; \
@@ -8231,86 +3362,24 @@ Ref<NiRangeLODData > rangeData; \
  : lodType((uint)0), numLodLevels((uint)0), unknownShort((ushort)0), rangeData(NULL) \
 
 #define NI_L_O_D_NODE_READ \
-uint block_num; \
-NiNode::Read( in, link_stack, version, user_version ); \
-NifStream( lodType, in, version ); \
-if ( (lodType == 0) ) { \
-	NifStream( lodCenter, in, version ); \
-	NifStream( numLodLevels, in, version ); \
-	lodLevels.resize(numLodLevels); \
-	for (uint i1 = 0; i1 < lodLevels.size(); i1++) { \
-		NifStream( lodLevels[i1].near, in, version ); \
-		NifStream( lodLevels[i1].far, in, version ); \
-	}; \
-}; \
-if ( (lodType == 1) ) { \
-	NifStream( unknownShort, in, version ); \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_L_O_D_NODE_WRITE \
-NiNode::Write( out, link_map, version, user_version ); \
-NifStream( lodType, out, version ); \
-if ( (lodType == 0) ) { \
-	NifStream( lodCenter, out, version ); \
-	NifStream( numLodLevels, out, version ); \
-	for (uint i1 = 0; i1 < lodLevels.size(); i1++) { \
-		NifStream( lodLevels[i1].near, out, version ); \
-		NifStream( lodLevels[i1].far, out, version ); \
-	}; \
-}; \
-if ( (lodType == 1) ) { \
-	NifStream( unknownShort, out, version ); \
-	if ( rangeData != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(rangeData)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_L_O_D_NODE_STRING \
-stringstream out; \
-out << NiNode::asString(); \
-out << "LOD Type:  " << lodType << endl; \
-if ( (lodType == 0) ) { \
-	out << "  LOD Center:  " << lodCenter << endl; \
-	out << "  Num LOD Levels:  " << numLodLevels << endl; \
-	for (uint i1 = 0; i1 < lodLevels.size(); i1++) { \
-		out << "    Near:  " << lodLevels[i1].near << endl; \
-		out << "    Far:  " << lodLevels[i1].far << endl; \
-	}; \
-}; \
-if ( (lodType == 1) ) { \
-	out << "  Unknown Short:  " << unknownShort << endl; \
-	out << "  Range Data:  " << rangeData << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_L_O_D_NODE_FIXLINKS \
-NiNode::FixLinks( objects, link_stack, version, user_version ); \
-if ( (lodType == 1) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		rangeData = DynamicCast<NiRangeLODData>(objects[link_stack.front()]); \
-		if ( rangeData == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		rangeData = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_L_O_D_NODE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiNode::GetRefs(); \
-if ( rangeData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(rangeData)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PALETTE_MEMBERS \
 byte unknownByte; \
 uint numEntries_; \
-byte palette[256][4]; \
+array<array<byte,256>,4> palette; \
 
 #define NI_PALETTE_INCLUDE "NiObject.h" \
 
@@ -8320,48 +3389,19 @@ byte palette[256][4]; \
  : unknownByte((byte)0), numEntries_((uint)0) \
 
 #define NI_PALETTE_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( unknownByte, in, version ); \
-NifStream( numEntries_, in, version ); \
-for (uint i0 = 0; i0 < 256; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( palette[i0][i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PALETTE_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( unknownByte, out, version ); \
-NifStream( numEntries_, out, version ); \
-for (uint i0 = 0; i0 < 256; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( palette[i0][i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PALETTE_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Unknown Byte:  " << unknownByte << endl; \
-out << "Num Entries?:  " << numEntries_ << endl; \
-for (uint i0 = 0; i0 < 256; i0++) { \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Palette[" << i0 << "][" << i1 << "]:  " << palette[i0][i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PALETTE_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PALETTE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_BOMB_MEMBERS \
 float unknownFloat1; \
@@ -8385,59 +3425,19 @@ float unknownFloat10; \
  : unknownFloat1(0.0f), unknownFloat2(0.0f), unknownFloat3(0.0f), unknownFloat4(0.0f), unknownInt1((uint)0), unknownInt2((uint)0), unknownFloat5(0.0f), unknownFloat6(0.0f), unknownFloat7(0.0f), unknownFloat8(0.0f), unknownFloat9(0.0f), unknownFloat10(0.0f) \
 
 #define NI_PARTICLE_BOMB_READ \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownFloat2, in, version ); \
-NifStream( unknownFloat3, in, version ); \
-NifStream( unknownFloat4, in, version ); \
-NifStream( unknownInt1, in, version ); \
-NifStream( unknownInt2, in, version ); \
-NifStream( unknownFloat5, in, version ); \
-NifStream( unknownFloat6, in, version ); \
-NifStream( unknownFloat7, in, version ); \
-NifStream( unknownFloat8, in, version ); \
-NifStream( unknownFloat9, in, version ); \
-NifStream( unknownFloat10, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_BOMB_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownFloat2, out, version ); \
-NifStream( unknownFloat3, out, version ); \
-NifStream( unknownFloat4, out, version ); \
-NifStream( unknownInt1, out, version ); \
-NifStream( unknownInt2, out, version ); \
-NifStream( unknownFloat5, out, version ); \
-NifStream( unknownFloat6, out, version ); \
-NifStream( unknownFloat7, out, version ); \
-NifStream( unknownFloat8, out, version ); \
-NifStream( unknownFloat9, out, version ); \
-NifStream( unknownFloat10, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_BOMB_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Float 3:  " << unknownFloat3 << endl; \
-out << "Unknown Float 4:  " << unknownFloat4 << endl; \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-out << "Unknown Float 5:  " << unknownFloat5 << endl; \
-out << "Unknown Float 6:  " << unknownFloat6 << endl; \
-out << "Unknown Float 7:  " << unknownFloat7 << endl; \
-out << "Unknown Float 8:  " << unknownFloat8 << endl; \
-out << "Unknown Float 9:  " << unknownFloat9 << endl; \
-out << "Unknown Float 10:  " << unknownFloat10 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_BOMB_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_BOMB_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_COLOR_MODIFIER_MEMBERS \
 Ref<NiColorData > colorData; \
@@ -8450,42 +3450,19 @@ Ref<NiColorData > colorData; \
  : colorData(NULL) \
 
 #define NI_PARTICLE_COLOR_MODIFIER_READ \
-uint block_num; \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_COLOR_MODIFIER_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-if ( colorData != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(colorData)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_COLOR_MODIFIER_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Color Data:  " << colorData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_COLOR_MODIFIER_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	colorData = DynamicCast<NiColorData>(objects[link_stack.front()]); \
-	if ( colorData == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	colorData = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_COLOR_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-if ( colorData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(colorData)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_GROW_FADE_MEMBERS \
 float grow; \
@@ -8499,32 +3476,22 @@ float fade; \
  : grow(0.0f), fade(0.0f) \
 
 #define NI_PARTICLE_GROW_FADE_READ \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-NifStream( grow, in, version ); \
-NifStream( fade, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_GROW_FADE_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-NifStream( grow, out, version ); \
-NifStream( fade, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_GROW_FADE_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Grow:  " << grow << endl; \
-out << "Fade:  " << fade << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_GROW_FADE_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_GROW_FADE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_MESH_MODIFIER_MEMBERS \
-uint numParticleMeshes; \
+mutable uint numParticleMeshes; \
 vector<Ref<NiAVObject > > particleMeshes; \
 
 #define NI_PARTICLE_MESH_MODIFIER_INCLUDE "AParticleModifier.h" \
@@ -8535,60 +3502,19 @@ vector<Ref<NiAVObject > > particleMeshes; \
  : numParticleMeshes((uint)0) \
 
 #define NI_PARTICLE_MESH_MODIFIER_READ \
-uint block_num; \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-NifStream( numParticleMeshes, in, version ); \
-particleMeshes.resize(numParticleMeshes); \
-for (uint i0 = 0; i0 < particleMeshes.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_MESH_MODIFIER_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-NifStream( numParticleMeshes, out, version ); \
-for (uint i0 = 0; i0 < particleMeshes.size(); i0++) { \
-	if ( particleMeshes[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(particleMeshes[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_MESH_MODIFIER_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Num Particle Meshes:  " << numParticleMeshes << endl; \
-for (uint i0 = 0; i0 < particleMeshes.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Particle Meshes[" << i0 << "]:  " << particleMeshes[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_MESH_MODIFIER_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < particleMeshes.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		particleMeshes[i0] = DynamicCast<NiAVObject>(objects[link_stack.front()]); \
-		if ( particleMeshes[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		particleMeshes[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_MESH_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-for (uint i0 = 0; i0 < particleMeshes.size(); i0++) { \
-	if ( particleMeshes[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(particleMeshes[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_ROTATION_MEMBERS \
 byte unknownByte; \
@@ -8605,38 +3531,19 @@ float unknownFloat4; \
  : unknownByte((byte)0), unknownFloat1(0.0f), unknownFloat2(0.0f), unknownFloat3(0.0f), unknownFloat4(0.0f) \
 
 #define NI_PARTICLE_ROTATION_READ \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-NifStream( unknownByte, in, version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownFloat2, in, version ); \
-NifStream( unknownFloat3, in, version ); \
-NifStream( unknownFloat4, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_ROTATION_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-NifStream( unknownByte, out, version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownFloat2, out, version ); \
-NifStream( unknownFloat3, out, version ); \
-NifStream( unknownFloat4, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_ROTATION_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Unknown Byte:  " << unknownByte << endl; \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Float 3:  " << unknownFloat3 << endl; \
-out << "Unknown Float 4:  " << unknownFloat4 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_ROTATION_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_ROTATION_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLES_MEMBERS \
 
@@ -8647,23 +3554,19 @@ return refs; \
 #define NI_PARTICLES_CONSTRUCT \
 
 #define NI_PARTICLES_READ \
-NiTriBasedGeom::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLES_WRITE \
-NiTriBasedGeom::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLES_STRING \
-stringstream out; \
-out << NiTriBasedGeom::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLES_FIXLINKS \
-NiTriBasedGeom::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLES_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTriBasedGeom::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_AUTO_NORMAL_PARTICLES_MEMBERS \
 
@@ -8674,23 +3577,19 @@ return refs; \
 #define NI_AUTO_NORMAL_PARTICLES_CONSTRUCT \
 
 #define NI_AUTO_NORMAL_PARTICLES_READ \
-NiParticles::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_WRITE \
-NiParticles::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_STRING \
-stringstream out; \
-out << NiParticles::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_FIXLINKS \
-NiParticles::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_AUTO_NORMAL_PARTICLES_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticles::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_MESHES_MEMBERS \
 
@@ -8701,23 +3600,19 @@ return refs; \
 #define NI_PARTICLE_MESHES_CONSTRUCT \
 
 #define NI_PARTICLE_MESHES_READ \
-NiParticles::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_MESHES_WRITE \
-NiParticles::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_MESHES_STRING \
-stringstream out; \
-out << NiParticles::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_MESHES_FIXLINKS \
-NiParticles::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_MESHES_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticles::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLES_DATA_MEMBERS \
 ushort numActive; \
@@ -8734,76 +3629,19 @@ vector<Quaternion > rotations; \
  : numActive((ushort)0), hasUnknownFloats(false), hasRotations(false) \
 
 #define NI_PARTICLES_DATA_READ \
-NiAutoNormalParticlesData::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( numActive, in, version ); \
-	NifStream( hasUnknownFloats, in, version ); \
-	if ( (hasUnknownFloats != 0) ) { \
-		unknownFloats.resize(numVertices); \
-		for (uint i2 = 0; i2 < unknownFloats.size(); i2++) { \
-			NifStream( unknownFloats[i2], in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasRotations, in, version ); \
-if ( (hasRotations != 0) ) { \
-	rotations.resize(numVertices); \
-	for (uint i1 = 0; i1 < rotations.size(); i1++) { \
-		NifStream( rotations[i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLES_DATA_WRITE \
-NiAutoNormalParticlesData::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( numActive, out, version ); \
-	NifStream( hasUnknownFloats, out, version ); \
-	if ( (hasUnknownFloats != 0) ) { \
-		for (uint i2 = 0; i2 < unknownFloats.size(); i2++) { \
-			NifStream( unknownFloats[i2], out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasRotations, out, version ); \
-if ( (hasRotations != 0) ) { \
-	for (uint i1 = 0; i1 < rotations.size(); i1++) { \
-		NifStream( rotations[i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLES_DATA_STRING \
-stringstream out; \
-out << NiAutoNormalParticlesData::asString(); \
-out << "Num Active:  " << numActive << endl; \
-out << "Has Unknown Floats:  " << hasUnknownFloats << endl; \
-if ( (hasUnknownFloats != 0) ) { \
-	for (uint i1 = 0; i1 < unknownFloats.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats[" << i1 << "]:  " << unknownFloats[i1] << endl; \
-	}; \
-}; \
-out << "Has Rotations:  " << hasRotations << endl; \
-if ( (hasRotations != 0) ) { \
-	for (uint i1 = 0; i1 < rotations.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Rotations[" << i1 << "]:  " << rotations[i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLES_DATA_FIXLINKS \
-NiAutoNormalParticlesData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLES_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiAutoNormalParticlesData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_MESHES_DATA_MEMBERS \
 Ref<NiAVObject > unknownLink2; \
@@ -8816,46 +3654,23 @@ Ref<NiAVObject > unknownLink2; \
  : unknownLink2(NULL) \
 
 #define NI_PARTICLE_MESHES_DATA_READ \
-uint block_num; \
-NiParticlesData::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_MESHES_DATA_WRITE \
-NiParticlesData::Write( out, link_map, version, user_version ); \
-if ( unknownLink2 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink2)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_MESHES_DATA_STRING \
-stringstream out; \
-out << NiParticlesData::asString(); \
-out << "Unknown Link 2:  " << unknownLink2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_MESHES_DATA_FIXLINKS \
-NiParticlesData::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink2 = DynamicCast<NiAVObject>(objects[link_stack.front()]); \
-	if ( unknownLink2 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink2 = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_MESHES_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticlesData::GetRefs(); \
-if ( unknownLink2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink2)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_SYSTEM_MEMBERS \
 bool unknownBool; \
-uint numModifiers; \
+mutable uint numModifiers; \
 vector<Ref<NiPSysModifier > > modifiers; \
 
 #define NI_PARTICLE_SYSTEM_INCLUDE "NiParticles.h" \
@@ -8866,69 +3681,19 @@ vector<Ref<NiPSysModifier > > modifiers; \
  : unknownBool(false), numModifiers((uint)0) \
 
 #define NI_PARTICLE_SYSTEM_READ \
-uint block_num; \
-NiParticles::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownBool, in, version ); \
-	NifStream( numModifiers, in, version ); \
-	modifiers.resize(numModifiers); \
-	for (uint i1 = 0; i1 < modifiers.size(); i1++) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_SYSTEM_WRITE \
-NiParticles::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownBool, out, version ); \
-	NifStream( numModifiers, out, version ); \
-	for (uint i1 = 0; i1 < modifiers.size(); i1++) { \
-		if ( modifiers[i1] != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(modifiers[i1])], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_SYSTEM_STRING \
-stringstream out; \
-out << NiParticles::asString(); \
-out << "Unknown Bool:  " << unknownBool << endl; \
-out << "Num Modifiers:  " << numModifiers << endl; \
-for (uint i0 = 0; i0 < modifiers.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Modifiers[" << i0 << "]:  " << modifiers[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_SYSTEM_FIXLINKS \
-NiParticles::FixLinks( objects, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	for (uint i1 = 0; i1 < modifiers.size(); i1++) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			modifiers[i1] = DynamicCast<NiPSysModifier>(objects[link_stack.front()]); \
-			if ( modifiers[i1] == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			modifiers[i1] = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_SYSTEM_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticles::GetRefs(); \
-for (uint i0 = 0; i0 < modifiers.size(); i0++) { \
-	if ( modifiers[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(modifiers[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_MESH_PARTICLE_SYSTEM_MEMBERS \
 
@@ -8939,23 +3704,19 @@ return refs; \
 #define NI_MESH_PARTICLE_SYSTEM_CONSTRUCT \
 
 #define NI_MESH_PARTICLE_SYSTEM_READ \
-NiParticleSystem::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_MESH_PARTICLE_SYSTEM_WRITE \
-NiParticleSystem::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_MESH_PARTICLE_SYSTEM_STRING \
-stringstream out; \
-out << NiParticleSystem::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_MESH_PARTICLE_SYSTEM_FIXLINKS \
-NiParticleSystem::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_MESH_PARTICLE_SYSTEM_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticleSystem::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PARTICLE_SYSTEM_CONTROLLER_MEMBERS \
 float speed; \
@@ -8986,7 +3747,7 @@ float unknownFloat13_; \
 uint unknownInt1_; \
 uint unknownInt2_; \
 ushort unknownShort3_; \
-ushort numParticles; \
+mutable ushort numParticles; \
 ushort numValid; \
 vector<Particle > particles; \
 Ref<NiObject > unknownLink; \
@@ -9002,214 +3763,19 @@ byte trailer; \
  : speed(0.0f), speedRandom(0.0f), verticalDirection(0.0f), verticalAngle(0.0f), horizontalDirection(0.0f), horizontalAngle(0.0f), unknownFloat5(0.0f), unknownFloat6(0.0f), unknownFloat7(0.0f), unknownFloat8(0.0f), unknownFloat9(0.0f), unknownFloat10(0.0f), unknownFloat11(0.0f), size(0.0f), emitStartTime(0.0f), emitStopTime(0.0f), unknownByte((byte)0), emitRate(0.0f), lifetime(0.0f), lifetimeRandom(0.0f), emitFlags((ushort)0), emitter(NULL), unknownShort2_((ushort)0), unknownFloat13_(0.0f), unknownInt1_((uint)0), unknownInt2_((uint)0), unknownShort3_((ushort)0), numParticles((ushort)0), numValid((ushort)0), unknownLink(NULL), particleExtra(NULL), unknownLink2(NULL), trailer((byte)0) \
 
 #define NI_PARTICLE_SYSTEM_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( speed, in, version ); \
-NifStream( speedRandom, in, version ); \
-NifStream( verticalDirection, in, version ); \
-NifStream( verticalAngle, in, version ); \
-NifStream( horizontalDirection, in, version ); \
-NifStream( horizontalAngle, in, version ); \
-NifStream( unknownFloat5, in, version ); \
-NifStream( unknownFloat6, in, version ); \
-NifStream( unknownFloat7, in, version ); \
-NifStream( unknownFloat8, in, version ); \
-NifStream( unknownFloat9, in, version ); \
-NifStream( unknownFloat10, in, version ); \
-NifStream( unknownFloat11, in, version ); \
-NifStream( size, in, version ); \
-NifStream( emitStartTime, in, version ); \
-NifStream( emitStopTime, in, version ); \
-NifStream( unknownByte, in, version ); \
-NifStream( emitRate, in, version ); \
-NifStream( lifetime, in, version ); \
-NifStream( lifetimeRandom, in, version ); \
-NifStream( emitFlags, in, version ); \
-NifStream( startRandom, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( unknownShort2_, in, version ); \
-NifStream( unknownFloat13_, in, version ); \
-NifStream( unknownInt1_, in, version ); \
-NifStream( unknownInt2_, in, version ); \
-NifStream( unknownShort3_, in, version ); \
-NifStream( numParticles, in, version ); \
-NifStream( numValid, in, version ); \
-particles.resize(numParticles); \
-for (uint i0 = 0; i0 < particles.size(); i0++) { \
-	NifStream( particles[i0].velocity, in, version ); \
-	NifStream( particles[i0].unknownVector, in, version ); \
-	NifStream( particles[i0].lifetime, in, version ); \
-	NifStream( particles[i0].lifespan, in, version ); \
-	NifStream( particles[i0].timestamp, in, version ); \
-	NifStream( particles[i0].unknownShort, in, version ); \
-	NifStream( particles[i0].vertexId, in, version ); \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( trailer, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_SYSTEM_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-NifStream( speed, out, version ); \
-NifStream( speedRandom, out, version ); \
-NifStream( verticalDirection, out, version ); \
-NifStream( verticalAngle, out, version ); \
-NifStream( horizontalDirection, out, version ); \
-NifStream( horizontalAngle, out, version ); \
-NifStream( unknownFloat5, out, version ); \
-NifStream( unknownFloat6, out, version ); \
-NifStream( unknownFloat7, out, version ); \
-NifStream( unknownFloat8, out, version ); \
-NifStream( unknownFloat9, out, version ); \
-NifStream( unknownFloat10, out, version ); \
-NifStream( unknownFloat11, out, version ); \
-NifStream( size, out, version ); \
-NifStream( emitStartTime, out, version ); \
-NifStream( emitStopTime, out, version ); \
-NifStream( unknownByte, out, version ); \
-NifStream( emitRate, out, version ); \
-NifStream( lifetime, out, version ); \
-NifStream( lifetimeRandom, out, version ); \
-NifStream( emitFlags, out, version ); \
-NifStream( startRandom, out, version ); \
-if ( emitter != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(emitter)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( unknownShort2_, out, version ); \
-NifStream( unknownFloat13_, out, version ); \
-NifStream( unknownInt1_, out, version ); \
-NifStream( unknownInt2_, out, version ); \
-NifStream( unknownShort3_, out, version ); \
-NifStream( numParticles, out, version ); \
-NifStream( numValid, out, version ); \
-for (uint i0 = 0; i0 < particles.size(); i0++) { \
-	NifStream( particles[i0].velocity, out, version ); \
-	NifStream( particles[i0].unknownVector, out, version ); \
-	NifStream( particles[i0].lifetime, out, version ); \
-	NifStream( particles[i0].lifespan, out, version ); \
-	NifStream( particles[i0].timestamp, out, version ); \
-	NifStream( particles[i0].unknownShort, out, version ); \
-	NifStream( particles[i0].vertexId, out, version ); \
-}; \
-if ( unknownLink != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( particleExtra != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(particleExtra)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( unknownLink2 != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink2)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( trailer, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PARTICLE_SYSTEM_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Speed:  " << speed << endl; \
-out << "Speed Random:  " << speedRandom << endl; \
-out << "Vertical Direction:  " << verticalDirection << endl; \
-out << "Vertical Angle:  " << verticalAngle << endl; \
-out << "Horizontal Direction:  " << horizontalDirection << endl; \
-out << "Horizontal Angle:  " << horizontalAngle << endl; \
-out << "Unknown Float 5:  " << unknownFloat5 << endl; \
-out << "Unknown Float 6:  " << unknownFloat6 << endl; \
-out << "Unknown Float 7:  " << unknownFloat7 << endl; \
-out << "Unknown Float 8:  " << unknownFloat8 << endl; \
-out << "Unknown Float 9:  " << unknownFloat9 << endl; \
-out << "Unknown Float 10:  " << unknownFloat10 << endl; \
-out << "Unknown Float 11:  " << unknownFloat11 << endl; \
-out << "Size:  " << size << endl; \
-out << "Emit Start Time:  " << emitStartTime << endl; \
-out << "Emit Stop Time:  " << emitStopTime << endl; \
-out << "Unknown Byte:  " << unknownByte << endl; \
-out << "Emit Rate:  " << emitRate << endl; \
-out << "Lifetime:  " << lifetime << endl; \
-out << "Lifetime Random:  " << lifetimeRandom << endl; \
-out << "Emit Flags:  " << emitFlags << endl; \
-out << "Start Random:  " << startRandom << endl; \
-out << "Emitter:  " << emitter << endl; \
-out << "Unknown Short 2?:  " << unknownShort2_ << endl; \
-out << "Unknown Float 13?:  " << unknownFloat13_ << endl; \
-out << "Unknown Int 1?:  " << unknownInt1_ << endl; \
-out << "Unknown Int 2?:  " << unknownInt2_ << endl; \
-out << "Unknown Short 3?:  " << unknownShort3_ << endl; \
-out << "Num Particles:  " << numParticles << endl; \
-out << "Num Valid:  " << numValid << endl; \
-for (uint i0 = 0; i0 < particles.size(); i0++) { \
-	out << "  Velocity:  " << particles[i0].velocity << endl; \
-	out << "  Unknown Vector:  " << particles[i0].unknownVector << endl; \
-	out << "  Lifetime:  " << particles[i0].lifetime << endl; \
-	out << "  Lifespan:  " << particles[i0].lifespan << endl; \
-	out << "  Timestamp:  " << particles[i0].timestamp << endl; \
-	out << "  Unknown Short:  " << particles[i0].unknownShort << endl; \
-	out << "  Vertex ID:  " << particles[i0].vertexId << endl; \
-}; \
-out << "Unknown Link:  " << unknownLink << endl; \
-out << "Particle Extra:  " << particleExtra << endl; \
-out << "Unknown Link 2:  " << unknownLink2 << endl; \
-out << "Trailer:  " << trailer << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PARTICLE_SYSTEM_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	emitter = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( emitter == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	emitter = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( unknownLink == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	particleExtra = DynamicCast<AParticleModifier>(objects[link_stack.front()]); \
-	if ( particleExtra == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	particleExtra = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink2 = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( unknownLink2 == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink2 = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PARTICLE_SYSTEM_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( emitter != NULL ) \
-	refs.push_back(StaticCast<NiObject>(emitter)); \
-if ( unknownLink != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink)); \
-if ( particleExtra != NULL ) \
-	refs.push_back(StaticCast<NiObject>(particleExtra)); \
-if ( unknownLink2 != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink2)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_B_S_P_ARRAY_CONTROLLER_MEMBERS \
 
@@ -9220,23 +3786,19 @@ return refs; \
 #define NI_B_S_P_ARRAY_CONTROLLER_CONSTRUCT \
 
 #define NI_B_S_P_ARRAY_CONTROLLER_READ \
-NiParticleSystemController::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_B_S_P_ARRAY_CONTROLLER_WRITE \
-NiParticleSystemController::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_B_S_P_ARRAY_CONTROLLER_STRING \
-stringstream out; \
-out << NiParticleSystemController::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_B_S_P_ARRAY_CONTROLLER_FIXLINKS \
-NiParticleSystemController::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_B_S_P_ARRAY_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticleSystemController::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PATH_CONTROLLER_MEMBERS \
 ushort unknownShort2; \
@@ -9255,79 +3817,19 @@ Ref<NiFloatData > floatData; \
  : unknownShort2((ushort)0), unknownInt1((uint)0), unknownInt2((uint)0), unknownInt3((uint)0), unknownShort((ushort)0), posData(NULL), floatData(NULL) \
 
 #define NI_PATH_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownShort2, in, version ); \
-}; \
-NifStream( unknownInt1, in, version ); \
-NifStream( unknownInt2, in, version ); \
-NifStream( unknownInt3, in, version ); \
-NifStream( unknownShort, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PATH_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( unknownShort2, out, version ); \
-}; \
-NifStream( unknownInt1, out, version ); \
-NifStream( unknownInt2, out, version ); \
-NifStream( unknownInt3, out, version ); \
-NifStream( unknownShort, out, version ); \
-if ( posData != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(posData)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( floatData != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(floatData)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PATH_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown Short 2:  " << unknownShort2 << endl; \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-out << "Unknown Int 3:  " << unknownInt3 << endl; \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Pos Data:  " << posData << endl; \
-out << "Float Data:  " << floatData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PATH_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	posData = DynamicCast<NiPosData>(objects[link_stack.front()]); \
-	if ( posData == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	posData = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	floatData = DynamicCast<NiFloatData>(objects[link_stack.front()]); \
-	if ( floatData == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	floatData = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PATH_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( posData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(posData)); \
-if ( floatData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(floatData)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PATH_INTERPOLATOR_MEMBERS \
 float unknownFloat1; \
@@ -9344,69 +3846,19 @@ Ref<NiFloatData > floatData; \
  : unknownFloat1(0.0f), unknownFloat2(0.0f), unknownShort2((ushort)0), posData(NULL), floatData(NULL) \
 
 #define NI_PATH_INTERPOLATOR_READ \
-uint block_num; \
-NiBlendInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownFloat2, in, version ); \
-NifStream( unknownShort2, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PATH_INTERPOLATOR_WRITE \
-NiBlendInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownFloat2, out, version ); \
-NifStream( unknownShort2, out, version ); \
-if ( posData != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(posData)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( floatData != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(floatData)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PATH_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiBlendInterpolator::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Short 2:  " << unknownShort2 << endl; \
-out << "Pos Data:  " << posData << endl; \
-out << "Float Data:  " << floatData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PATH_INTERPOLATOR_FIXLINKS \
-NiBlendInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	posData = DynamicCast<NiPosData>(objects[link_stack.front()]); \
-	if ( posData == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	posData = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	floatData = DynamicCast<NiFloatData>(objects[link_stack.front()]); \
-	if ( floatData == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	floatData = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PATH_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiBlendInterpolator::GetRefs(); \
-if ( posData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(posData)); \
-if ( floatData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(floatData)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PIXEL_DATA_MEMBERS \
 PixelFormat pixelFormat; \
@@ -9415,11 +3867,11 @@ uint greenMask; \
 uint blueMask; \
 uint alphaMask; \
 uint bitsPerPixel; \
-byte unknown8Bytes[8]; \
+array<byte,8> unknown8Bytes; \
 uint unknownInt; \
-byte unknown54Bytes[54]; \
+array<byte,54> unknown54Bytes; \
 Ref<NiPalette > palette; \
-uint numMipmaps; \
+mutable uint numMipmaps; \
 uint bytesPerPixel; \
 vector<MipMap > mipmaps; \
 ByteArray pixelData; \
@@ -9433,147 +3885,19 @@ uint unknownInt2; \
  : pixelFormat((PixelFormat)0), redMask((uint)0), greenMask((uint)0), blueMask((uint)0), alphaMask((uint)0), bitsPerPixel((uint)0), unknownInt((uint)0), palette(NULL), numMipmaps((uint)0), bytesPerPixel((uint)0), unknownInt2((uint)0) \
 
 #define NI_PIXEL_DATA_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( pixelFormat, in, version ); \
-if ( version <= 0x0A020000 ) { \
-	NifStream( redMask, in, version ); \
-	NifStream( greenMask, in, version ); \
-	NifStream( blueMask, in, version ); \
-	NifStream( alphaMask, in, version ); \
-	NifStream( bitsPerPixel, in, version ); \
-	for (uint i1 = 0; i1 < 8; i1++) { \
-		NifStream( unknown8Bytes[i1], in, version ); \
-	}; \
-}; \
-if ( ( version >= 0x0A010000 ) && ( version <= 0x0A020000 ) ) { \
-	NifStream( unknownInt, in, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	for (uint i1 = 0; i1 < 54; i1++) { \
-		NifStream( unknown54Bytes[i1], in, version ); \
-	}; \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( numMipmaps, in, version ); \
-NifStream( bytesPerPixel, in, version ); \
-mipmaps.resize(numMipmaps); \
-for (uint i0 = 0; i0 < mipmaps.size(); i0++) { \
-	NifStream( mipmaps[i0].width, in, version ); \
-	NifStream( mipmaps[i0].height, in, version ); \
-	NifStream( mipmaps[i0].offset, in, version ); \
-}; \
-NifStream( pixelData.dataSize, in, version ); \
-pixelData.data.resize(pixelData.dataSize); \
-for (uint i0 = 0; i0 < pixelData.data.size(); i0++) { \
-	NifStream( pixelData.data[i0], in, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	NifStream( unknownInt2, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PIXEL_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( pixelFormat, out, version ); \
-if ( version <= 0x0A020000 ) { \
-	NifStream( redMask, out, version ); \
-	NifStream( greenMask, out, version ); \
-	NifStream( blueMask, out, version ); \
-	NifStream( alphaMask, out, version ); \
-	NifStream( bitsPerPixel, out, version ); \
-	for (uint i1 = 0; i1 < 8; i1++) { \
-		NifStream( unknown8Bytes[i1], out, version ); \
-	}; \
-}; \
-if ( ( version >= 0x0A010000 ) && ( version <= 0x0A020000 ) ) { \
-	NifStream( unknownInt, out, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	for (uint i1 = 0; i1 < 54; i1++) { \
-		NifStream( unknown54Bytes[i1], out, version ); \
-	}; \
-}; \
-if ( palette != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(palette)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( numMipmaps, out, version ); \
-NifStream( bytesPerPixel, out, version ); \
-for (uint i0 = 0; i0 < mipmaps.size(); i0++) { \
-	NifStream( mipmaps[i0].width, out, version ); \
-	NifStream( mipmaps[i0].height, out, version ); \
-	NifStream( mipmaps[i0].offset, out, version ); \
-}; \
-NifStream( pixelData.dataSize, out, version ); \
-for (uint i0 = 0; i0 < pixelData.data.size(); i0++) { \
-	NifStream( pixelData.data[i0], out, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	NifStream( unknownInt2, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PIXEL_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Pixel Format:  " << pixelFormat << endl; \
-out << "Red Mask:  " << redMask << endl; \
-out << "Green Mask:  " << greenMask << endl; \
-out << "Blue Mask:  " << blueMask << endl; \
-out << "Alpha Mask:  " << alphaMask << endl; \
-out << "Bits Per Pixel:  " << bitsPerPixel << endl; \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown 8 Bytes[" << i0 << "]:  " << unknown8Bytes[i0] << endl; \
-}; \
-out << "Unknown Int:  " << unknownInt << endl; \
-for (uint i0 = 0; i0 < 54; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown 54 Bytes[" << i0 << "]:  " << unknown54Bytes[i0] << endl; \
-}; \
-out << "Palette:  " << palette << endl; \
-out << "Num Mipmaps:  " << numMipmaps << endl; \
-out << "Bytes Per Pixel:  " << bytesPerPixel << endl; \
-for (uint i0 = 0; i0 < mipmaps.size(); i0++) { \
-	out << "  Width:  " << mipmaps[i0].width << endl; \
-	out << "  Height:  " << mipmaps[i0].height << endl; \
-	out << "  Offset:  " << mipmaps[i0].offset << endl; \
-}; \
-out << "Data Size:  " << pixelData.dataSize << endl; \
-for (uint i0 = 0; i0 < pixelData.data.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Data[" << i0 << "]:  " << pixelData.data[i0] << endl; \
-}; \
-out << "Unknown Int 2:  " << unknownInt2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PIXEL_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	palette = DynamicCast<NiPalette>(objects[link_stack.front()]); \
-	if ( palette == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	palette = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PIXEL_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( palette != NULL ) \
-	refs.push_back(StaticCast<NiObject>(palette)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_PLANAR_COLLIDER_MEMBERS \
 ushort unknownShort; \
@@ -9603,85 +3927,19 @@ float unknownFloat16; \
  : unknownShort((ushort)0), unknownFloat1(0.0f), unknownFloat2(0.0f), unknownShort2((ushort)0), unknownFloat3(0.0f), unknownFloat4(0.0f), unknownFloat5(0.0f), unknownFloat6(0.0f), unknownFloat7(0.0f), unknownFloat8(0.0f), unknownFloat9(0.0f), unknownFloat10(0.0f), unknownFloat11(0.0f), unknownFloat12(0.0f), unknownFloat13(0.0f), unknownFloat14(0.0f), unknownFloat15(0.0f), unknownFloat16(0.0f) \
 
 #define NI_PLANAR_COLLIDER_READ \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-if ( version >= 0x0A000100 ) { \
-	NifStream( unknownShort, in, version ); \
-}; \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownFloat2, in, version ); \
-if ( ( version >= 0x04020200 ) && ( version <= 0x04020200 ) ) { \
-	NifStream( unknownShort2, in, version ); \
-}; \
-NifStream( unknownFloat3, in, version ); \
-NifStream( unknownFloat4, in, version ); \
-NifStream( unknownFloat5, in, version ); \
-NifStream( unknownFloat6, in, version ); \
-NifStream( unknownFloat7, in, version ); \
-NifStream( unknownFloat8, in, version ); \
-NifStream( unknownFloat9, in, version ); \
-NifStream( unknownFloat10, in, version ); \
-NifStream( unknownFloat11, in, version ); \
-NifStream( unknownFloat12, in, version ); \
-NifStream( unknownFloat13, in, version ); \
-NifStream( unknownFloat14, in, version ); \
-NifStream( unknownFloat15, in, version ); \
-NifStream( unknownFloat16, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_PLANAR_COLLIDER_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-if ( version >= 0x0A000100 ) { \
-	NifStream( unknownShort, out, version ); \
-}; \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownFloat2, out, version ); \
-if ( ( version >= 0x04020200 ) && ( version <= 0x04020200 ) ) { \
-	NifStream( unknownShort2, out, version ); \
-}; \
-NifStream( unknownFloat3, out, version ); \
-NifStream( unknownFloat4, out, version ); \
-NifStream( unknownFloat5, out, version ); \
-NifStream( unknownFloat6, out, version ); \
-NifStream( unknownFloat7, out, version ); \
-NifStream( unknownFloat8, out, version ); \
-NifStream( unknownFloat9, out, version ); \
-NifStream( unknownFloat10, out, version ); \
-NifStream( unknownFloat11, out, version ); \
-NifStream( unknownFloat12, out, version ); \
-NifStream( unknownFloat13, out, version ); \
-NifStream( unknownFloat14, out, version ); \
-NifStream( unknownFloat15, out, version ); \
-NifStream( unknownFloat16, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_PLANAR_COLLIDER_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Short 2:  " << unknownShort2 << endl; \
-out << "Unknown Float 3:  " << unknownFloat3 << endl; \
-out << "Unknown Float 4:  " << unknownFloat4 << endl; \
-out << "Unknown Float 5:  " << unknownFloat5 << endl; \
-out << "Unknown Float 6:  " << unknownFloat6 << endl; \
-out << "Unknown Float 7:  " << unknownFloat7 << endl; \
-out << "Unknown Float 8:  " << unknownFloat8 << endl; \
-out << "Unknown Float 9:  " << unknownFloat9 << endl; \
-out << "Unknown Float 10:  " << unknownFloat10 << endl; \
-out << "Unknown Float 11:  " << unknownFloat11 << endl; \
-out << "Unknown Float 12:  " << unknownFloat12 << endl; \
-out << "Unknown Float 13:  " << unknownFloat13 << endl; \
-out << "Unknown Float 14:  " << unknownFloat14 << endl; \
-out << "Unknown Float 15:  " << unknownFloat15 << endl; \
-out << "Unknown Float 16:  " << unknownFloat16 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_PLANAR_COLLIDER_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_PLANAR_COLLIDER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_POINT3_INTERPOLATOR_MEMBERS \
 Vector3 point3Value; \
@@ -9695,45 +3953,19 @@ Ref<NiPosData > data; \
  : data(NULL) \
 
 #define NI_POINT3_INTERPOLATOR_READ \
-uint block_num; \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( point3Value, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_POINT3_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( point3Value, out, version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_POINT3_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Point 3 Value:  " << point3Value << endl; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_POINT3_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiPosData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_POINT3_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_POINT_LIGHT_MEMBERS \
 float constantAttenuation; \
@@ -9748,32 +3980,19 @@ float quadraticAttenuation; \
  : constantAttenuation(0.0f), linearAttenuation(0.0f), quadraticAttenuation(0.0f) \
 
 #define NI_POINT_LIGHT_READ \
-NiLight::Read( in, link_stack, version, user_version ); \
-NifStream( constantAttenuation, in, version ); \
-NifStream( linearAttenuation, in, version ); \
-NifStream( quadraticAttenuation, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_POINT_LIGHT_WRITE \
-NiLight::Write( out, link_map, version, user_version ); \
-NifStream( constantAttenuation, out, version ); \
-NifStream( linearAttenuation, out, version ); \
-NifStream( quadraticAttenuation, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_POINT_LIGHT_STRING \
-stringstream out; \
-out << NiLight::asString(); \
-out << "Constant Attenuation:  " << constantAttenuation << endl; \
-out << "Linear Attenuation:  " << linearAttenuation << endl; \
-out << "Quadratic Attenuation:  " << quadraticAttenuation << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_POINT_LIGHT_FIXLINKS \
-NiLight::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_POINT_LIGHT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiLight::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_POS_DATA_MEMBERS \
 KeyGroup<Vector3 > data; \
@@ -9785,49 +4004,19 @@ KeyGroup<Vector3 > data; \
 #define NI_POS_DATA_CONSTRUCT \
 
 #define NI_POS_DATA_READ \
-AKeyedData::Read( in, link_stack, version, user_version ); \
-NifStream( data.numKeys, in, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, in, version ); \
-}; \
-data.keys.resize(data.numKeys); \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], in, version, data.interpolation ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_POS_DATA_WRITE \
-AKeyedData::Write( out, link_map, version, user_version ); \
-NifStream( data.numKeys, out, version ); \
-if ( (data.numKeys != 0) ) { \
-	NifStream( data.interpolation, out, version ); \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	NifStream( data.keys[i0], out, version, data.interpolation ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_POS_DATA_STRING \
-stringstream out; \
-out << AKeyedData::asString(); \
-out << "Num Keys:  " << data.numKeys << endl; \
-if ( (data.numKeys != 0) ) { \
-	out << "  Interpolation:  " << data.interpolation << endl; \
-}; \
-for (uint i0 = 0; i0 < data.keys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Keys[" << i0 << "]:  " << data.keys[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_POS_DATA_FIXLINKS \
-AKeyedData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_POS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AKeyedData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_AGE_DEATH_MODIFIER_MEMBERS \
 bool spawnOnDeath; \
@@ -9841,51 +4030,25 @@ Ref<NiPSysSpawnModifier > spawnModifier; \
  : spawnOnDeath(false), spawnModifier(NULL) \
 
 #define NI_P_SYS_AGE_DEATH_MODIFIER_READ \
-uint block_num; \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( spawnOnDeath, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_AGE_DEATH_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( spawnOnDeath, out, version ); \
-if ( spawnModifier != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(spawnModifier)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_AGE_DEATH_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Spawn on Death:  " << spawnOnDeath << endl; \
-out << "Spawn Modifier:  " << spawnModifier << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_AGE_DEATH_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	spawnModifier = DynamicCast<NiPSysSpawnModifier>(objects[link_stack.front()]); \
-	if ( spawnModifier == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	spawnModifier = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_AGE_DEATH_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-if ( spawnModifier != NULL ) \
-	refs.push_back(StaticCast<NiObject>(spawnModifier)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_BOMB_MODIFIER_MEMBERS \
 NiNode * unknownLink; \
-uint unknownInts1[2]; \
-float unknownFloats[3]; \
-uint unknownInts2[2]; \
+array<uint,2> unknownInts1; \
+array<float,3> unknownFloats; \
+array<uint,2> unknownInts2; \
 
 #define NI_P_SYS_BOMB_MODIFIER_INCLUDE "NiPSysModifier.h" \
 
@@ -9895,79 +4058,19 @@ uint unknownInts2[2]; \
  : unknownLink(NULL) \
 
 #define NI_P_SYS_BOMB_MODIFIER_READ \
-uint block_num; \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	NifStream( unknownInts1[i0], in, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	NifStream( unknownInts2[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_BOMB_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-if ( unknownLink != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	NifStream( unknownInts1[i0], out, version ); \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	NifStream( unknownInts2[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_BOMB_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Unknown Link:  " << unknownLink << endl; \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Ints 1[" << i0 << "]:  " << unknownInts1[i0] << endl; \
-}; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-for (uint i0 = 0; i0 < 2; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Ints 2[" << i0 << "]:  " << unknownInts2[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_BOMB_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink = DynamicCast<NiNode>(objects[link_stack.front()]); \
-	if ( unknownLink == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_BOMB_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_BOUND_UPDATE_MODIFIER_MEMBERS \
 ushort updateSkip; \
@@ -9980,26 +4083,19 @@ ushort updateSkip; \
  : updateSkip((ushort)0) \
 
 #define NI_P_SYS_BOUND_UPDATE_MODIFIER_READ \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( updateSkip, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_BOUND_UPDATE_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( updateSkip, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_BOUND_UPDATE_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Update Skip:  " << updateSkip << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_BOUND_UPDATE_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_BOUND_UPDATE_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_BOX_EMITTER_MEMBERS \
 float width; \
@@ -10014,32 +4110,19 @@ float depth; \
  : width(0.0f), height(0.0f), depth(0.0f) \
 
 #define NI_P_SYS_BOX_EMITTER_READ \
-NiPSysVolumeEmitter::Read( in, link_stack, version, user_version ); \
-NifStream( width, in, version ); \
-NifStream( height, in, version ); \
-NifStream( depth, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_BOX_EMITTER_WRITE \
-NiPSysVolumeEmitter::Write( out, link_map, version, user_version ); \
-NifStream( width, out, version ); \
-NifStream( height, out, version ); \
-NifStream( depth, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_BOX_EMITTER_STRING \
-stringstream out; \
-out << NiPSysVolumeEmitter::asString(); \
-out << "Width:  " << width << endl; \
-out << "Height:  " << height << endl; \
-out << "Depth:  " << depth << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_BOX_EMITTER_FIXLINKS \
-NiPSysVolumeEmitter::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_BOX_EMITTER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysVolumeEmitter::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_COLLIDER_MANAGER_MEMBERS \
 Ref<NiPSysPlanarCollider > collider; \
@@ -10052,42 +4135,19 @@ Ref<NiPSysPlanarCollider > collider; \
  : collider(NULL) \
 
 #define NI_P_SYS_COLLIDER_MANAGER_READ \
-uint block_num; \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_COLLIDER_MANAGER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-if ( collider != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(collider)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_COLLIDER_MANAGER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Collider:  " << collider << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_COLLIDER_MANAGER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	collider = DynamicCast<NiPSysPlanarCollider>(objects[link_stack.front()]); \
-	if ( collider == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	collider = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_COLLIDER_MANAGER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-if ( collider != NULL ) \
-	refs.push_back(StaticCast<NiObject>(collider)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_COLOR_MODIFIER_MEMBERS \
 Ref<NiColorData > data; \
@@ -10100,42 +4160,19 @@ Ref<NiColorData > data; \
  : data(NULL) \
 
 #define NI_P_SYS_COLOR_MODIFIER_READ \
-uint block_num; \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_COLOR_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_COLOR_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_COLOR_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiColorData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_COLOR_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_CYLINDER_EMITTER_MEMBERS \
 float radius; \
@@ -10149,29 +4186,19 @@ float height; \
  : radius(0.0f), height(0.0f) \
 
 #define NI_P_SYS_CYLINDER_EMITTER_READ \
-NiPSysVolumeEmitter::Read( in, link_stack, version, user_version ); \
-NifStream( radius, in, version ); \
-NifStream( height, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_CYLINDER_EMITTER_WRITE \
-NiPSysVolumeEmitter::Write( out, link_map, version, user_version ); \
-NifStream( radius, out, version ); \
-NifStream( height, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_CYLINDER_EMITTER_STRING \
-stringstream out; \
-out << NiPSysVolumeEmitter::asString(); \
-out << "Radius:  " << radius << endl; \
-out << "Height:  " << height << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_CYLINDER_EMITTER_FIXLINKS \
-NiPSysVolumeEmitter::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_CYLINDER_EMITTER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysVolumeEmitter::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_DATA_MEMBERS \
 vector< array<float,10> > unknownFloats4; \
@@ -10191,141 +4218,19 @@ uint unknownInt1; \
  : unknownBool1(false), unknownByte3((byte)0), unknownBool2(false), unknownInt1((uint)0) \
 
 #define NI_P_SYS_DATA_READ \
-APSysData::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x0A020000 ) { \
-	unknownFloats4.resize(numVertices); \
-	for (uint i1 = 0; i1 < unknownFloats4.size(); i1++) { \
-		for (uint i2 = 0; i2 < 10; i2++) { \
-			NifStream( unknownFloats4[i1][i2], in, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x14000004 ) { \
-	NifStream( unknownBool1, in, version ); \
-	if ( (unknownBool1 != 0) ) { \
-		unknownBytes.resize(numVertices); \
-		for (uint i2 = 0; i2 < unknownBytes.size(); i2++) { \
-			for (uint i3 = 0; i3 < 32; i3++) { \
-				NifStream( unknownBytes[i2][i3], in, version ); \
-			}; \
-		}; \
-	}; \
-	if ( (unknownBool1 == 0) ) { \
-		unknownBytesAlt.resize(numVertices); \
-		for (uint i2 = 0; i2 < unknownBytesAlt.size(); i2++) { \
-			for (uint i3 = 0; i3 < 28; i3++) { \
-				NifStream( unknownBytesAlt[i2][i3], in, version ); \
-			}; \
-		}; \
-	}; \
-	NifStream( unknownByte3, in, version ); \
-	NifStream( unknownBool2, in, version ); \
-	if ( (unknownBool2 != 0) ) { \
-		unknownBytes2.resize(numVertices); \
-		for (uint i2 = 0; i2 < unknownBytes2.size(); i2++) { \
-			for (uint i3 = 0; i3 < 4; i3++) { \
-				NifStream( unknownBytes2[i2][i3], in, version ); \
-			}; \
-		}; \
-	}; \
-}; \
-NifStream( unknownInt1, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_DATA_WRITE \
-APSysData::Write( out, link_map, version, user_version ); \
-if ( version <= 0x0A020000 ) { \
-	for (uint i1 = 0; i1 < unknownFloats4.size(); i1++) { \
-		for (uint i2 = 0; i2 < 10; i2++) { \
-			NifStream( unknownFloats4[i1][i2], out, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x14000004 ) { \
-	NifStream( unknownBool1, out, version ); \
-	if ( (unknownBool1 != 0) ) { \
-		for (uint i2 = 0; i2 < unknownBytes.size(); i2++) { \
-			for (uint i3 = 0; i3 < 32; i3++) { \
-				NifStream( unknownBytes[i2][i3], out, version ); \
-			}; \
-		}; \
-	}; \
-	if ( (unknownBool1 == 0) ) { \
-		for (uint i2 = 0; i2 < unknownBytesAlt.size(); i2++) { \
-			for (uint i3 = 0; i3 < 28; i3++) { \
-				NifStream( unknownBytesAlt[i2][i3], out, version ); \
-			}; \
-		}; \
-	}; \
-	NifStream( unknownByte3, out, version ); \
-	NifStream( unknownBool2, out, version ); \
-	if ( (unknownBool2 != 0) ) { \
-		for (uint i2 = 0; i2 < unknownBytes2.size(); i2++) { \
-			for (uint i3 = 0; i3 < 4; i3++) { \
-				NifStream( unknownBytes2[i2][i3], out, version ); \
-			}; \
-		}; \
-	}; \
-}; \
-NifStream( unknownInt1, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_DATA_STRING \
-stringstream out; \
-out << APSysData::asString(); \
-for (uint i0 = 0; i0 < unknownFloats4.size(); i0++) { \
-	for (uint i1 = 0; i1 < 10; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown Floats 4[" << i0 << "][" << i1 << "]:  " << unknownFloats4[i0][i1] << endl; \
-	}; \
-}; \
-out << "Unknown Bool 1:  " << unknownBool1 << endl; \
-if ( (unknownBool1 != 0) ) { \
-	for (uint i1 = 0; i1 < unknownBytes.size(); i1++) { \
-		for (uint i2 = 0; i2 < 32; i2++) { \
-			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) { \
-				out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-				break; \
-			}; \
-			out << "      Unknown Bytes[" << i1 << "][" << i2 << "]:  " << unknownBytes[i1][i2] << endl; \
-		}; \
-	}; \
-}; \
-if ( (unknownBool1 == 0) ) { \
-	for (uint i1 = 0; i1 < unknownBytesAlt.size(); i1++) { \
-		for (uint i2 = 0; i2 < 28; i2++) { \
-			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) { \
-				out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-				break; \
-			}; \
-			out << "      Unknown Bytes Alt[" << i1 << "][" << i2 << "]:  " << unknownBytesAlt[i1][i2] << endl; \
-		}; \
-	}; \
-}; \
-out << "Unknown Byte 3:  " << unknownByte3 << endl; \
-out << "Unknown Bool 2:  " << unknownBool2 << endl; \
-if ( (unknownBool2 != 0) ) { \
-	for (uint i1 = 0; i1 < unknownBytes2.size(); i1++) { \
-		for (uint i2 = 0; i2 < 4; i2++) { \
-			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) { \
-				out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-				break; \
-			}; \
-			out << "      Unknown Bytes 2[" << i1 << "][" << i2 << "]:  " << unknownBytes2[i1][i2] << endl; \
-		}; \
-	}; \
-}; \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_DATA_FIXLINKS \
-APSysData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_DRAG_MODIFIER_MEMBERS \
 NiObject * parent; \
@@ -10342,52 +4247,19 @@ float rangeFalloff; \
  : parent(NULL), percentage(0.0f), range(0.0f), rangeFalloff(0.0f) \
 
 #define NI_P_SYS_DRAG_MODIFIER_READ \
-uint block_num; \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( dragAxis, in, version ); \
-NifStream( percentage, in, version ); \
-NifStream( range, in, version ); \
-NifStream( rangeFalloff, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_DRAG_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-if ( parent != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(parent)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( dragAxis, out, version ); \
-NifStream( percentage, out, version ); \
-NifStream( range, out, version ); \
-NifStream( rangeFalloff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_DRAG_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Parent:  " << parent << endl; \
-out << "Drag Axis:  " << dragAxis << endl; \
-out << "Percentage:  " << percentage << endl; \
-out << "Range:  " << range << endl; \
-out << "Range Falloff:  " << rangeFalloff << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_DRAG_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	parent = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( parent == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	parent = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_DRAG_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_CTLR_MEMBERS \
 Ref<NiPSysEmitterCtlrData > data; \
@@ -10401,76 +4273,23 @@ Ref<NiInterpolator > visibilityInterpolator; \
  : data(NULL), visibilityInterpolator(NULL) \
 
 #define NI_P_SYS_EMITTER_CTLR_READ \
-uint block_num; \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if ( data != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if ( visibilityInterpolator != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(visibilityInterpolator)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-out << "Data:  " << data << endl; \
-out << "Visibility Interpolator:  " << visibilityInterpolator << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		data = DynamicCast<NiPSysEmitterCtlrData>(objects[link_stack.front()]); \
-		if ( data == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		data = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( version >= 0x0A020000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		visibilityInterpolator = DynamicCast<NiInterpolator>(objects[link_stack.front()]); \
-		if ( visibilityInterpolator == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		visibilityInterpolator = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-if ( visibilityInterpolator != NULL ) \
-	refs.push_back(StaticCast<NiObject>(visibilityInterpolator)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_CTLR_DATA_MEMBERS \
 KeyGroup<float > floatKeys_; \
-uint numVisibilityKeys_; \
+mutable uint numVisibilityKeys_; \
 vector<Key<byte > > visibilityKeys_; \
 
 #define NI_P_SYS_EMITTER_CTLR_DATA_INCLUDE "NiObject.h" \
@@ -10481,66 +4300,19 @@ vector<Key<byte > > visibilityKeys_; \
  : numVisibilityKeys_((uint)0) \
 
 #define NI_P_SYS_EMITTER_CTLR_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( floatKeys_.numKeys, in, version ); \
-if ( (floatKeys_.numKeys != 0) ) { \
-	NifStream( floatKeys_.interpolation, in, version ); \
-}; \
-floatKeys_.keys.resize(floatKeys_.numKeys); \
-for (uint i0 = 0; i0 < floatKeys_.keys.size(); i0++) { \
-	NifStream( floatKeys_.keys[i0], in, version, floatKeys_.interpolation ); \
-}; \
-NifStream( numVisibilityKeys_, in, version ); \
-visibilityKeys_.resize(numVisibilityKeys_); \
-for (uint i0 = 0; i0 < visibilityKeys_.size(); i0++) { \
-	NifStream( visibilityKeys_[i0], in, version, 1 ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_CTLR_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( floatKeys_.numKeys, out, version ); \
-if ( (floatKeys_.numKeys != 0) ) { \
-	NifStream( floatKeys_.interpolation, out, version ); \
-}; \
-for (uint i0 = 0; i0 < floatKeys_.keys.size(); i0++) { \
-	NifStream( floatKeys_.keys[i0], out, version, floatKeys_.interpolation ); \
-}; \
-NifStream( numVisibilityKeys_, out, version ); \
-for (uint i0 = 0; i0 < visibilityKeys_.size(); i0++) { \
-	NifStream( visibilityKeys_[i0], out, version, 1 ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_CTLR_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Num Keys:  " << floatKeys_.numKeys << endl; \
-if ( (floatKeys_.numKeys != 0) ) { \
-	out << "  Interpolation:  " << floatKeys_.interpolation << endl; \
-}; \
-for (uint i0 = 0; i0 < floatKeys_.keys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Keys[" << i0 << "]:  " << floatKeys_.keys[i0] << endl; \
-}; \
-out << "Num Visibility Keys?:  " << numVisibilityKeys_ << endl; \
-for (uint i0 = 0; i0 < visibilityKeys_.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Visibility Keys?[" << i0 << "]:  " << visibilityKeys_[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_CTLR_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_CTLR_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_CTLR_MEMBERS \
 
@@ -10551,23 +4323,19 @@ return refs; \
 #define NI_P_SYS_EMITTER_DECLINATION_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_EMITTER_DECLINATION_CTLR_READ \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_MEMBERS \
 
@@ -10578,23 +4346,19 @@ return refs; \
 #define NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_READ \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_MEMBERS \
 
@@ -10605,23 +4369,19 @@ return refs; \
 #define NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_READ \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_MEMBERS \
 
@@ -10632,23 +4392,19 @@ return refs; \
 #define NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_READ \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_EMITTER_SPEED_CTLR_MEMBERS \
 
@@ -10659,23 +4415,19 @@ return refs; \
 #define NI_P_SYS_EMITTER_SPEED_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_EMITTER_SPEED_CTLR_READ \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_SPEED_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_SPEED_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_EMITTER_SPEED_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_EMITTER_SPEED_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_GRAVITY_MODIFIER_MEMBERS \
 NiNode * gravityObject; \
@@ -10694,58 +4446,19 @@ float turbulenceScale; \
  : gravityObject(NULL), decay(0.0f), strength(0.0f), forceType((uint)0), turbulence(0.0f), turbulenceScale(1.0f) \
 
 #define NI_P_SYS_GRAVITY_MODIFIER_READ \
-uint block_num; \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( gravityAxis, in, version ); \
-NifStream( decay, in, version ); \
-NifStream( strength, in, version ); \
-NifStream( forceType, in, version ); \
-NifStream( turbulence, in, version ); \
-NifStream( turbulenceScale, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_GRAVITY_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-if ( gravityObject != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(gravityObject)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( gravityAxis, out, version ); \
-NifStream( decay, out, version ); \
-NifStream( strength, out, version ); \
-NifStream( forceType, out, version ); \
-NifStream( turbulence, out, version ); \
-NifStream( turbulenceScale, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_GRAVITY_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Gravity Object:  " << gravityObject << endl; \
-out << "Gravity Axis:  " << gravityAxis << endl; \
-out << "Decay:  " << decay << endl; \
-out << "Strength:  " << strength << endl; \
-out << "Force Type:  " << forceType << endl; \
-out << "Turbulence:  " << turbulence << endl; \
-out << "Turbulence Scale:  " << turbulenceScale << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_GRAVITY_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	gravityObject = DynamicCast<NiNode>(objects[link_stack.front()]); \
-	if ( gravityObject == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	gravityObject = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_GRAVITY_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_GRAVITY_STRENGTH_CTLR_MEMBERS \
 
@@ -10756,23 +4469,19 @@ return refs; \
 #define NI_P_SYS_GRAVITY_STRENGTH_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_GRAVITY_STRENGTH_CTLR_READ \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_GRAVITY_STRENGTH_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_GRAVITY_STRENGTH_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_GRAVITY_STRENGTH_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_GRAVITY_STRENGTH_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_GROW_FADE_MODIFIER_MEMBERS \
 float growTime; \
@@ -10788,38 +4497,22 @@ ushort fadeGeneration; \
  : growTime(0.0f), growGeneration((ushort)0), fadeTime(0.0f), fadeGeneration((ushort)0) \
 
 #define NI_P_SYS_GROW_FADE_MODIFIER_READ \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( growTime, in, version ); \
-NifStream( growGeneration, in, version ); \
-NifStream( fadeTime, in, version ); \
-NifStream( fadeGeneration, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_GROW_FADE_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( growTime, out, version ); \
-NifStream( growGeneration, out, version ); \
-NifStream( fadeTime, out, version ); \
-NifStream( fadeGeneration, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_GROW_FADE_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Grow Time:  " << growTime << endl; \
-out << "Grow Generation:  " << growGeneration << endl; \
-out << "Fade Time:  " << fadeTime << endl; \
-out << "Fade Generation:  " << fadeGeneration << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_GROW_FADE_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_GROW_FADE_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_MESH_EMITTER_MEMBERS \
-uint numEmitterMeshes; \
+mutable uint numEmitterMeshes; \
 vector<Ref<NiTriBasedGeom > > emitterMeshes; \
 uint initialVelocityType; \
 uint emissionType; \
@@ -10833,72 +4526,22 @@ Vector3 emissionAxis; \
  : numEmitterMeshes((uint)0), initialVelocityType((uint)0), emissionType((uint)0) \
 
 #define NI_P_SYS_MESH_EMITTER_READ \
-uint block_num; \
-NiPSysEmitter::Read( in, link_stack, version, user_version ); \
-NifStream( numEmitterMeshes, in, version ); \
-emitterMeshes.resize(numEmitterMeshes); \
-for (uint i0 = 0; i0 < emitterMeshes.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( initialVelocityType, in, version ); \
-NifStream( emissionType, in, version ); \
-NifStream( emissionAxis, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MESH_EMITTER_WRITE \
-NiPSysEmitter::Write( out, link_map, version, user_version ); \
-NifStream( numEmitterMeshes, out, version ); \
-for (uint i0 = 0; i0 < emitterMeshes.size(); i0++) { \
-	if ( emitterMeshes[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(emitterMeshes[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-NifStream( initialVelocityType, out, version ); \
-NifStream( emissionType, out, version ); \
-NifStream( emissionAxis, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_MESH_EMITTER_STRING \
-stringstream out; \
-out << NiPSysEmitter::asString(); \
-out << "Num Emitter Meshes:  " << numEmitterMeshes << endl; \
-for (uint i0 = 0; i0 < emitterMeshes.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Emitter Meshes[" << i0 << "]:  " << emitterMeshes[i0] << endl; \
-}; \
-out << "Initial Velocity Type:  " << initialVelocityType << endl; \
-out << "Emission Type:  " << emissionType << endl; \
-out << "Emission Axis:  " << emissionAxis << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_MESH_EMITTER_FIXLINKS \
-NiPSysEmitter::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < emitterMeshes.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		emitterMeshes[i0] = DynamicCast<NiTriBasedGeom>(objects[link_stack.front()]); \
-		if ( emitterMeshes[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		emitterMeshes[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MESH_EMITTER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysEmitter::GetRefs(); \
-for (uint i0 = 0; i0 < emitterMeshes.size(); i0++) { \
-	if ( emitterMeshes[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(emitterMeshes[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_MESH_UPDATE_MODIFIER_MEMBERS \
-uint numMeshes; \
+mutable uint numMeshes; \
 vector<Ref<NiNode > > meshes; \
 
 #define NI_P_SYS_MESH_UPDATE_MODIFIER_INCLUDE "NiPSysModifier.h" \
@@ -10909,60 +4552,19 @@ vector<Ref<NiNode > > meshes; \
  : numMeshes((uint)0) \
 
 #define NI_P_SYS_MESH_UPDATE_MODIFIER_READ \
-uint block_num; \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( numMeshes, in, version ); \
-meshes.resize(numMeshes); \
-for (uint i0 = 0; i0 < meshes.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MESH_UPDATE_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( numMeshes, out, version ); \
-for (uint i0 = 0; i0 < meshes.size(); i0++) { \
-	if ( meshes[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(meshes[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_MESH_UPDATE_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Num Meshes:  " << numMeshes << endl; \
-for (uint i0 = 0; i0 < meshes.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Meshes[" << i0 << "]:  " << meshes[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_MESH_UPDATE_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < meshes.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		meshes[i0] = DynamicCast<NiNode>(objects[link_stack.front()]); \
-		if ( meshes[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		meshes[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MESH_UPDATE_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-for (uint i0 = 0; i0 < meshes.size(); i0++) { \
-	if ( meshes[i0] != NULL ) \
-		refs.push_back(StaticCast<NiObject>(meshes[i0])); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_MODIFIER_ACTIVE_CTLR_MEMBERS \
 
@@ -10973,23 +4575,19 @@ return refs; \
 #define NI_P_SYS_MODIFIER_ACTIVE_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_MODIFIER_ACTIVE_CTLR_READ \
-APSysCtlr::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MODIFIER_ACTIVE_CTLR_WRITE \
-APSysCtlr::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_MODIFIER_ACTIVE_CTLR_STRING \
-stringstream out; \
-out << APSysCtlr::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_MODIFIER_ACTIVE_CTLR_FIXLINKS \
-APSysCtlr::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_MODIFIER_ACTIVE_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = APSysCtlr::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_PLANAR_COLLIDER_MEMBERS \
 float bounce; \
@@ -11012,115 +4610,19 @@ Vector3 yAxis; \
  : bounce(0.0f), spawnOnCollide(false), dieOnCollide(false), spawnModifier(NULL), parent(NULL), unknownLink_(NULL), colliderObject(NULL), width(0.0f), height(0.0f) \
 
 #define NI_P_SYS_PLANAR_COLLIDER_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( bounce, in, version ); \
-NifStream( spawnOnCollide, in, version ); \
-NifStream( dieOnCollide, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( width, in, version ); \
-NifStream( height, in, version ); \
-NifStream( xAxis, in, version ); \
-NifStream( yAxis, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_PLANAR_COLLIDER_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( bounce, out, version ); \
-NifStream( spawnOnCollide, out, version ); \
-NifStream( dieOnCollide, out, version ); \
-if ( spawnModifier != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(spawnModifier)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( parent != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(parent)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( unknownLink_ != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(unknownLink_)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( colliderObject != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(colliderObject)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( width, out, version ); \
-NifStream( height, out, version ); \
-NifStream( xAxis, out, version ); \
-NifStream( yAxis, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_PLANAR_COLLIDER_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Bounce:  " << bounce << endl; \
-out << "Spawn on Collide:  " << spawnOnCollide << endl; \
-out << "Die on Collide:  " << dieOnCollide << endl; \
-out << "Spawn Modifier:  " << spawnModifier << endl; \
-out << "Parent:  " << parent << endl; \
-out << "Unknown Link?:  " << unknownLink_ << endl; \
-out << "Collider Object:  " << colliderObject << endl; \
-out << "Width:  " << width << endl; \
-out << "Height:  " << height << endl; \
-out << "X Axis:  " << xAxis << endl; \
-out << "Y Axis:  " << yAxis << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_PLANAR_COLLIDER_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	spawnModifier = DynamicCast<NiPSysSpawnModifier>(objects[link_stack.front()]); \
-	if ( spawnModifier == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	spawnModifier = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	parent = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( parent == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	parent = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	unknownLink_ = DynamicCast<NiObject>(objects[link_stack.front()]); \
-	if ( unknownLink_ == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	unknownLink_ = NULL; \
-link_stack.pop_front(); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	colliderObject = DynamicCast<NiNode>(objects[link_stack.front()]); \
-	if ( colliderObject == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	colliderObject = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_PLANAR_COLLIDER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( spawnModifier != NULL ) \
-	refs.push_back(StaticCast<NiObject>(spawnModifier)); \
-if ( unknownLink_ != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink_)); \
-if ( colliderObject != NULL ) \
-	refs.push_back(StaticCast<NiObject>(colliderObject)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_POSITION_MODIFIER_MEMBERS \
 
@@ -11131,23 +4633,19 @@ return refs; \
 #define NI_P_SYS_POSITION_MODIFIER_CONSTRUCT \
 
 #define NI_P_SYS_POSITION_MODIFIER_READ \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_POSITION_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_POSITION_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_POSITION_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_POSITION_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_RESET_ON_LOOP_CTLR_MEMBERS \
 
@@ -11158,23 +4656,19 @@ return refs; \
 #define NI_P_SYS_RESET_ON_LOOP_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_RESET_ON_LOOP_CTLR_READ \
-NiTimeController::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_RESET_ON_LOOP_CTLR_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_RESET_ON_LOOP_CTLR_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_RESET_ON_LOOP_CTLR_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_RESET_ON_LOOP_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_ROTATION_MODIFIER_MEMBERS \
 float initialRotationSpeed; \
@@ -11193,48 +4687,19 @@ Vector3 initialAxis; \
  : initialRotationSpeed(0.0f), initialRotationSpeedVariation(0.0f), initialRotationAngle(0.0f), initialRotationAngleVariation(0.0f), randomRotSpeedSign(false), randomInitialAxis(false) \
 
 #define NI_P_SYS_ROTATION_MODIFIER_READ \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( initialRotationSpeed, in, version ); \
-if ( version >= 0x14000004 ) { \
-	NifStream( initialRotationSpeedVariation, in, version ); \
-	NifStream( initialRotationAngle, in, version ); \
-	NifStream( initialRotationAngleVariation, in, version ); \
-	NifStream( randomRotSpeedSign, in, version ); \
-}; \
-NifStream( randomInitialAxis, in, version ); \
-NifStream( initialAxis, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_ROTATION_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( initialRotationSpeed, out, version ); \
-if ( version >= 0x14000004 ) { \
-	NifStream( initialRotationSpeedVariation, out, version ); \
-	NifStream( initialRotationAngle, out, version ); \
-	NifStream( initialRotationAngleVariation, out, version ); \
-	NifStream( randomRotSpeedSign, out, version ); \
-}; \
-NifStream( randomInitialAxis, out, version ); \
-NifStream( initialAxis, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_ROTATION_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Initial Rotation Speed:  " << initialRotationSpeed << endl; \
-out << "Initial Rotation Speed Variation:  " << initialRotationSpeedVariation << endl; \
-out << "Initial Rotation Angle:  " << initialRotationAngle << endl; \
-out << "Initial Rotation Angle Variation:  " << initialRotationAngleVariation << endl; \
-out << "Random Rot Speed Sign:  " << randomRotSpeedSign << endl; \
-out << "Random Initial Axis:  " << randomInitialAxis << endl; \
-out << "Initial Axis:  " << initialAxis << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_ROTATION_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_ROTATION_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_SPAWN_MODIFIER_MEMBERS \
 ushort numSpawnGenerations; \
@@ -11254,47 +4719,19 @@ float lifeSpanVariation; \
  : numSpawnGenerations((ushort)0), percentageSpawned(0.0f), minNumToSpawn((ushort)0), maxNumToSpawn((ushort)0), spawnSpeedChaos(0.0f), spawnDirChaos(0.0f), lifeSpan(0.0f), lifeSpanVariation(0.0f) \
 
 #define NI_P_SYS_SPAWN_MODIFIER_READ \
-NiPSysModifier::Read( in, link_stack, version, user_version ); \
-NifStream( numSpawnGenerations, in, version ); \
-NifStream( percentageSpawned, in, version ); \
-NifStream( minNumToSpawn, in, version ); \
-NifStream( maxNumToSpawn, in, version ); \
-NifStream( spawnSpeedChaos, in, version ); \
-NifStream( spawnDirChaos, in, version ); \
-NifStream( lifeSpan, in, version ); \
-NifStream( lifeSpanVariation, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_SPAWN_MODIFIER_WRITE \
-NiPSysModifier::Write( out, link_map, version, user_version ); \
-NifStream( numSpawnGenerations, out, version ); \
-NifStream( percentageSpawned, out, version ); \
-NifStream( minNumToSpawn, out, version ); \
-NifStream( maxNumToSpawn, out, version ); \
-NifStream( spawnSpeedChaos, out, version ); \
-NifStream( spawnDirChaos, out, version ); \
-NifStream( lifeSpan, out, version ); \
-NifStream( lifeSpanVariation, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_SPAWN_MODIFIER_STRING \
-stringstream out; \
-out << NiPSysModifier::asString(); \
-out << "Num Spawn Generations:  " << numSpawnGenerations << endl; \
-out << "Percentage Spawned:  " << percentageSpawned << endl; \
-out << "Min Num to Spawn:  " << minNumToSpawn << endl; \
-out << "Max Num to Spawn:  " << maxNumToSpawn << endl; \
-out << "Spawn Speed Chaos:  " << spawnSpeedChaos << endl; \
-out << "Spawn Dir Chaos:  " << spawnDirChaos << endl; \
-out << "Life Span:  " << lifeSpan << endl; \
-out << "Life Span Variation:  " << lifeSpanVariation << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_SPAWN_MODIFIER_FIXLINKS \
-NiPSysModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_SPAWN_MODIFIER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_SPHERE_EMITTER_MEMBERS \
 float radius; \
@@ -11307,26 +4744,19 @@ float radius; \
  : radius(0.0f) \
 
 #define NI_P_SYS_SPHERE_EMITTER_READ \
-NiPSysVolumeEmitter::Read( in, link_stack, version, user_version ); \
-NifStream( radius, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_SPHERE_EMITTER_WRITE \
-NiPSysVolumeEmitter::Write( out, link_map, version, user_version ); \
-NifStream( radius, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_SPHERE_EMITTER_STRING \
-stringstream out; \
-out << NiPSysVolumeEmitter::asString(); \
-out << "Radius:  " << radius << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_SPHERE_EMITTER_FIXLINKS \
-NiPSysVolumeEmitter::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_SPHERE_EMITTER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPSysVolumeEmitter::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_P_SYS_UPDATE_CTLR_MEMBERS \
 
@@ -11337,27 +4767,23 @@ return refs; \
 #define NI_P_SYS_UPDATE_CTLR_CONSTRUCT \
 
 #define NI_P_SYS_UPDATE_CTLR_READ \
-NiTimeController::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_P_SYS_UPDATE_CTLR_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_P_SYS_UPDATE_CTLR_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_P_SYS_UPDATE_CTLR_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_P_SYS_UPDATE_CTLR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_RANGE_L_O_D_DATA_MEMBERS \
 Vector3 lodCenter; \
-uint numLodLevels; \
+mutable uint numLodLevels; \
 vector<LODRange > lodLevels; \
 
 #define NI_RANGE_L_O_D_DATA_INCLUDE "NiObject.h" \
@@ -11368,42 +4794,19 @@ vector<LODRange > lodLevels; \
  : numLodLevels((uint)0) \
 
 #define NI_RANGE_L_O_D_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( lodCenter, in, version ); \
-NifStream( numLodLevels, in, version ); \
-lodLevels.resize(numLodLevels); \
-for (uint i0 = 0; i0 < lodLevels.size(); i0++) { \
-	NifStream( lodLevels[i0].near, in, version ); \
-	NifStream( lodLevels[i0].far, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_RANGE_L_O_D_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( lodCenter, out, version ); \
-NifStream( numLodLevels, out, version ); \
-for (uint i0 = 0; i0 < lodLevels.size(); i0++) { \
-	NifStream( lodLevels[i0].near, out, version ); \
-	NifStream( lodLevels[i0].far, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_RANGE_L_O_D_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "LOD Center:  " << lodCenter << endl; \
-out << "Num LOD Levels:  " << numLodLevels << endl; \
-for (uint i0 = 0; i0 < lodLevels.size(); i0++) { \
-	out << "  Near:  " << lodLevels[i0].near << endl; \
-	out << "  Far:  " << lodLevels[i0].far << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_RANGE_L_O_D_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_RANGE_L_O_D_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_ROTATING_PARTICLES_MEMBERS \
 
@@ -11414,23 +4817,19 @@ return refs; \
 #define NI_ROTATING_PARTICLES_CONSTRUCT \
 
 #define NI_ROTATING_PARTICLES_READ \
-NiParticles::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_ROTATING_PARTICLES_WRITE \
-NiParticles::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_ROTATING_PARTICLES_STRING \
-stringstream out; \
-out << NiParticles::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_ROTATING_PARTICLES_FIXLINKS \
-NiParticles::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_ROTATING_PARTICLES_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticles::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_ROTATING_PARTICLES_DATA_MEMBERS \
 
@@ -11441,27 +4840,23 @@ return refs; \
 #define NI_ROTATING_PARTICLES_DATA_CONSTRUCT \
 
 #define NI_ROTATING_PARTICLES_DATA_READ \
-NiParticlesData::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_ROTATING_PARTICLES_DATA_WRITE \
-NiParticlesData::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_ROTATING_PARTICLES_DATA_STRING \
-stringstream out; \
-out << NiParticlesData::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_ROTATING_PARTICLES_DATA_FIXLINKS \
-NiParticlesData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_ROTATING_PARTICLES_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiParticlesData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SCREEN_L_O_D_DATA_MEMBERS \
-float unknownFloats[8]; \
-uint unknownCount; \
+array<float,8> unknownFloats; \
+mutable uint unknownCount; \
 vector<float > unknownFloats2; \
 
 #define NI_SCREEN_L_O_D_DATA_INCLUDE "NiObject.h" \
@@ -11472,53 +4867,19 @@ vector<float > unknownFloats2; \
  : unknownCount((uint)0) \
 
 #define NI_SCREEN_L_O_D_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownFloats[i0], in, version ); \
-}; \
-NifStream( unknownCount, in, version ); \
-unknownFloats2.resize(unknownCount); \
-for (uint i0 = 0; i0 < unknownFloats2.size(); i0++) { \
-	NifStream( unknownFloats2[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SCREEN_L_O_D_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	NifStream( unknownFloats[i0], out, version ); \
-}; \
-NifStream( unknownCount, out, version ); \
-for (uint i0 = 0; i0 < unknownFloats2.size(); i0++) { \
-	NifStream( unknownFloats2[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SCREEN_L_O_D_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-for (uint i0 = 0; i0 < 8; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats[" << i0 << "]:  " << unknownFloats[i0] << endl; \
-}; \
-out << "Unknown Count:  " << unknownCount << endl; \
-for (uint i0 = 0; i0 < unknownFloats2.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Floats 2[" << i0 << "]:  " << unknownFloats2[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SCREEN_L_O_D_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SCREEN_L_O_D_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SEQUENCE_STREAM_HELPER_MEMBERS \
 
@@ -11529,23 +4890,19 @@ return refs; \
 #define NI_SEQUENCE_STREAM_HELPER_CONSTRUCT \
 
 #define NI_SEQUENCE_STREAM_HELPER_READ \
-NiObjectNET::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SEQUENCE_STREAM_HELPER_WRITE \
-NiObjectNET::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SEQUENCE_STREAM_HELPER_STRING \
-stringstream out; \
-out << NiObjectNET::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SEQUENCE_STREAM_HELPER_FIXLINKS \
-NiObjectNET::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SEQUENCE_STREAM_HELPER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObjectNET::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SHADE_PROPERTY_MEMBERS \
 ushort flags; \
@@ -11558,32 +4915,25 @@ ushort flags; \
  : flags((ushort)0) \
 
 #define NI_SHADE_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SHADE_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SHADE_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SHADE_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SHADE_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SKIN_DATA_MEMBERS \
 Matrix33 rotation; \
 Vector3 translation; \
 float scale; \
-uint numBones; \
+mutable uint numBones; \
 Ref<NiSkinPartition > skinPartition; \
 byte unknownByte; \
 vector<SkinData > boneList; \
@@ -11596,118 +4946,25 @@ vector<SkinData > boneList; \
  : scale(0.0f), numBones((uint)0), skinPartition(NULL), unknownByte((byte)0) \
 
 #define NI_SKIN_DATA_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( rotation, in, version ); \
-NifStream( translation, in, version ); \
-NifStream( scale, in, version ); \
-NifStream( numBones, in, version ); \
-if ( version <= 0x0A010000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-if ( version >= 0x04020100 ) { \
-	NifStream( unknownByte, in, version ); \
-}; \
-boneList.resize(numBones); \
-for (uint i0 = 0; i0 < boneList.size(); i0++) { \
-	NifStream( boneList[i0].rotation, in, version ); \
-	NifStream( boneList[i0].translation, in, version ); \
-	NifStream( boneList[i0].scale, in, version ); \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( boneList[i0].unknown4Floats[i1], in, version ); \
-	}; \
-	NifStream( boneList[i0].numVertices, in, version ); \
-	boneList[i0].vertexWeights.resize(boneList[i0].numVertices); \
-	for (uint i1 = 0; i1 < boneList[i0].vertexWeights.size(); i1++) { \
-		NifStream( boneList[i0].vertexWeights[i1].index, in, version ); \
-		NifStream( boneList[i0].vertexWeights[i1].weight, in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SKIN_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( rotation, out, version ); \
-NifStream( translation, out, version ); \
-NifStream( scale, out, version ); \
-NifStream( numBones, out, version ); \
-if ( version <= 0x0A010000 ) { \
-	if ( skinPartition != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(skinPartition)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( version >= 0x04020100 ) { \
-	NifStream( unknownByte, out, version ); \
-}; \
-for (uint i0 = 0; i0 < boneList.size(); i0++) { \
-	NifStream( boneList[i0].rotation, out, version ); \
-	NifStream( boneList[i0].translation, out, version ); \
-	NifStream( boneList[i0].scale, out, version ); \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		NifStream( boneList[i0].unknown4Floats[i1], out, version ); \
-	}; \
-	NifStream( boneList[i0].numVertices, out, version ); \
-	for (uint i1 = 0; i1 < boneList[i0].vertexWeights.size(); i1++) { \
-		NifStream( boneList[i0].vertexWeights[i1].index, out, version ); \
-		NifStream( boneList[i0].vertexWeights[i1].weight, out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SKIN_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Rotation:  " << rotation << endl; \
-out << "Translation:  " << translation << endl; \
-out << "Scale:  " << scale << endl; \
-out << "Num Bones:  " << numBones << endl; \
-out << "Skin Partition:  " << skinPartition << endl; \
-out << "Unknown Byte:  " << unknownByte << endl; \
-for (uint i0 = 0; i0 < boneList.size(); i0++) { \
-	out << "  Rotation:  " << boneList[i0].rotation << endl; \
-	out << "  Translation:  " << boneList[i0].translation << endl; \
-	out << "  Scale:  " << boneList[i0].scale << endl; \
-	for (uint i1 = 0; i1 < 4; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Unknown 4 Floats[" << i1 << "]:  " << boneList[i0].unknown4Floats[i1] << endl; \
-	}; \
-	out << "  Num Vertices:  " << boneList[i0].numVertices << endl; \
-	for (uint i1 = 0; i1 < boneList[i0].vertexWeights.size(); i1++) { \
-		out << "    Index:  " << boneList[i0].vertexWeights[i1].index << endl; \
-		out << "    Weight:  " << boneList[i0].vertexWeights[i1].weight << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SKIN_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		skinPartition = DynamicCast<NiSkinPartition>(objects[link_stack.front()]); \
-		if ( skinPartition == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		skinPartition = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SKIN_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( skinPartition != NULL ) \
-	refs.push_back(StaticCast<NiObject>(skinPartition)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SKIN_INSTANCE_MEMBERS \
 Ref<NiSkinData > data; \
 Ref<NiSkinPartition > skinPartition; \
 NiNode * skeletonRoot; \
-uint numBones; \
+mutable uint numBones; \
 vector<NiNode * > bones; \
 
 #define NI_SKIN_INSTANCE_INCLUDE "NiObject.h" \
@@ -11718,119 +4975,22 @@ vector<NiNode * > bones; \
  : data(NULL), skinPartition(NULL), skeletonRoot(NULL), numBones((uint)0) \
 
 #define NI_SKIN_INSTANCE_READ \
-uint block_num; \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-if ( version >= 0x0A020000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( numBones, in, version ); \
-bones.resize(numBones); \
-for (uint i0 = 0; i0 < bones.size(); i0++) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SKIN_INSTANCE_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-if ( version >= 0x0A020000 ) { \
-	if ( skinPartition != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(skinPartition)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-if ( skeletonRoot != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(skeletonRoot)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( numBones, out, version ); \
-for (uint i0 = 0; i0 < bones.size(); i0++) { \
-	if ( bones[i0] != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(bones[i0])], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SKIN_INSTANCE_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Data:  " << data << endl; \
-out << "Skin Partition:  " << skinPartition << endl; \
-out << "Skeleton Root:  " << skeletonRoot << endl; \
-out << "Num Bones:  " << numBones << endl; \
-for (uint i0 = 0; i0 < bones.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Bones[" << i0 << "]:  " << bones[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SKIN_INSTANCE_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiSkinData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
-if ( version >= 0x0A020000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		skinPartition = DynamicCast<NiSkinPartition>(objects[link_stack.front()]); \
-		if ( skinPartition == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		skinPartition = NULL; \
-	link_stack.pop_front(); \
-}; \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	skeletonRoot = DynamicCast<NiNode>(objects[link_stack.front()]); \
-	if ( skeletonRoot == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	skeletonRoot = NULL; \
-link_stack.pop_front(); \
-for (uint i0 = 0; i0 < bones.size(); i0++) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		bones[i0] = DynamicCast<NiNode>(objects[link_stack.front()]); \
-		if ( bones[i0] == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		bones[i0] = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SKIN_INSTANCE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-if ( skinPartition != NULL ) \
-	refs.push_back(StaticCast<NiObject>(skinPartition)); \
-for (uint i0 = 0; i0 < bones.size(); i0++) { \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SKIN_PARTITION_MEMBERS \
-uint numSkinPartitionBlocks; \
+mutable uint numSkinPartitionBlocks; \
 vector<SkinPartition > skinPartitionBlocks; \
 
 #define NI_SKIN_PARTITION_INCLUDE "NiObject.h" \
@@ -11841,266 +5001,19 @@ vector<SkinPartition > skinPartitionBlocks; \
  : numSkinPartitionBlocks((uint)0) \
 
 #define NI_SKIN_PARTITION_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( numSkinPartitionBlocks, in, version ); \
-skinPartitionBlocks.resize(numSkinPartitionBlocks); \
-for (uint i0 = 0; i0 < skinPartitionBlocks.size(); i0++) { \
-	NifStream( skinPartitionBlocks[i0].numVertices, in, version ); \
-	NifStream( skinPartitionBlocks[i0].numTriangles, in, version ); \
-	NifStream( skinPartitionBlocks[i0].numBones, in, version ); \
-	NifStream( skinPartitionBlocks[i0].numStrips, in, version ); \
-	NifStream( skinPartitionBlocks[i0].numWeightsPerVertex, in, version ); \
-	skinPartitionBlocks[i0].bones.resize(skinPartitionBlocks[i0].numBones); \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].bones.size(); i1++) { \
-		NifStream( skinPartitionBlocks[i0].bones[i1], in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( skinPartitionBlocks[i0].hasVertexMap, in, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		skinPartitionBlocks[i0].vertexMap.resize(skinPartitionBlocks[i0].numVertices); \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].vertexMap.size(); i2++) { \
-			NifStream( skinPartitionBlocks[i0].vertexMap[i2], in, version ); \
-		}; \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		if ( (skinPartitionBlocks[i0].hasVertexMap != 0) ) { \
-			skinPartitionBlocks[i0].vertexMap.resize(skinPartitionBlocks[i0].numVertices); \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].vertexMap.size(); i3++) { \
-				NifStream( skinPartitionBlocks[i0].vertexMap[i3], in, version ); \
-			}; \
-		}; \
-		NifStream( skinPartitionBlocks[i0].hasVertexWeights, in, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		skinPartitionBlocks[i0].vertexWeights.resize(skinPartitionBlocks[i0].numVertices); \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].vertexWeights.size(); i2++) { \
-			skinPartitionBlocks[i0].vertexWeights[i2].resize(skinPartitionBlocks[i0].numWeightsPerVertex); \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].vertexWeights[i2].size(); i3++) { \
-				NifStream( skinPartitionBlocks[i0].vertexWeights[i2][i3], in, version ); \
-			}; \
-		}; \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		if ( (skinPartitionBlocks[i0].hasVertexWeights != 0) ) { \
-			skinPartitionBlocks[i0].vertexWeights.resize(skinPartitionBlocks[i0].numVertices); \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].vertexWeights.size(); i3++) { \
-				skinPartitionBlocks[i0].vertexWeights[i3].resize(skinPartitionBlocks[i0].numWeightsPerVertex); \
-				for (uint i4 = 0; i4 < skinPartitionBlocks[i0].vertexWeights[i3].size(); i4++) { \
-					NifStream( skinPartitionBlocks[i0].vertexWeights[i3][i4], in, version ); \
-				}; \
-			}; \
-		}; \
-	}; \
-	skinPartitionBlocks[i0].stripLengths.resize(skinPartitionBlocks[i0].numStrips); \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].stripLengths.size(); i1++) { \
-		NifStream( skinPartitionBlocks[i0].stripLengths[i1], in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( skinPartitionBlocks[i0].hasStrips, in, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		skinPartitionBlocks[i0].strips.resize(skinPartitionBlocks[i0].numStrips); \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].strips.size(); i2++) { \
-			skinPartitionBlocks[i0].strips[i2].resize(skinPartitionBlocks[i0].stripLengths[i2]); \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].stripLengths[i2]; i3++) { \
-				NifStream( skinPartitionBlocks[i0].strips[i2][i3], in, version ); \
-			}; \
-		}; \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		if ( (skinPartitionBlocks[i0].hasStrips != 0) ) { \
-			skinPartitionBlocks[i0].strips.resize(skinPartitionBlocks[i0].numStrips); \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].strips.size(); i3++) { \
-				skinPartitionBlocks[i0].strips[i3].resize(skinPartitionBlocks[i0].stripLengths[i3]); \
-				for (uint i4 = 0; i4 < skinPartitionBlocks[i0].stripLengths[i3]; i4++) { \
-					NifStream( skinPartitionBlocks[i0].strips[i3][i4], in, version ); \
-				}; \
-			}; \
-		}; \
-	}; \
-	if ( (skinPartitionBlocks[i0].numStrips == 0) ) { \
-		skinPartitionBlocks[i0].triangles.resize(skinPartitionBlocks[i0].numTriangles); \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].triangles.size(); i2++) { \
-			NifStream( skinPartitionBlocks[i0].triangles[i2], in, version ); \
-		}; \
-	}; \
-	NifStream( skinPartitionBlocks[i0].hasBoneIndices, in, version ); \
-	if ( (skinPartitionBlocks[i0].hasBoneIndices != 0) ) { \
-		skinPartitionBlocks[i0].boneIndices.resize(skinPartitionBlocks[i0].numVertices); \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].boneIndices.size(); i2++) { \
-			skinPartitionBlocks[i0].boneIndices[i2].resize(skinPartitionBlocks[i0].numWeightsPerVertex); \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].boneIndices[i2].size(); i3++) { \
-				NifStream( skinPartitionBlocks[i0].boneIndices[i2][i3], in, version ); \
-			}; \
-		}; \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SKIN_PARTITION_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( numSkinPartitionBlocks, out, version ); \
-for (uint i0 = 0; i0 < skinPartitionBlocks.size(); i0++) { \
-	NifStream( skinPartitionBlocks[i0].numVertices, out, version ); \
-	NifStream( skinPartitionBlocks[i0].numTriangles, out, version ); \
-	NifStream( skinPartitionBlocks[i0].numBones, out, version ); \
-	NifStream( skinPartitionBlocks[i0].numStrips, out, version ); \
-	NifStream( skinPartitionBlocks[i0].numWeightsPerVertex, out, version ); \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].bones.size(); i1++) { \
-		NifStream( skinPartitionBlocks[i0].bones[i1], out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( skinPartitionBlocks[i0].hasVertexMap, out, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].vertexMap.size(); i2++) { \
-			NifStream( skinPartitionBlocks[i0].vertexMap[i2], out, version ); \
-		}; \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		if ( (skinPartitionBlocks[i0].hasVertexMap != 0) ) { \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].vertexMap.size(); i3++) { \
-				NifStream( skinPartitionBlocks[i0].vertexMap[i3], out, version ); \
-			}; \
-		}; \
-		NifStream( skinPartitionBlocks[i0].hasVertexWeights, out, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].vertexWeights.size(); i2++) { \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].vertexWeights[i2].size(); i3++) { \
-				NifStream( skinPartitionBlocks[i0].vertexWeights[i2][i3], out, version ); \
-			}; \
-		}; \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		if ( (skinPartitionBlocks[i0].hasVertexWeights != 0) ) { \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].vertexWeights.size(); i3++) { \
-				for (uint i4 = 0; i4 < skinPartitionBlocks[i0].vertexWeights[i3].size(); i4++) { \
-					NifStream( skinPartitionBlocks[i0].vertexWeights[i3][i4], out, version ); \
-				}; \
-			}; \
-		}; \
-	}; \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].stripLengths.size(); i1++) { \
-		NifStream( skinPartitionBlocks[i0].stripLengths[i1], out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( skinPartitionBlocks[i0].hasStrips, out, version ); \
-	}; \
-	if ( version <= 0x0A000102 ) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].strips.size(); i2++) { \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].stripLengths[i2]; i3++) { \
-				NifStream( skinPartitionBlocks[i0].strips[i2][i3], out, version ); \
-			}; \
-		}; \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		if ( (skinPartitionBlocks[i0].hasStrips != 0) ) { \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].strips.size(); i3++) { \
-				for (uint i4 = 0; i4 < skinPartitionBlocks[i0].stripLengths[i3]; i4++) { \
-					NifStream( skinPartitionBlocks[i0].strips[i3][i4], out, version ); \
-				}; \
-			}; \
-		}; \
-	}; \
-	if ( (skinPartitionBlocks[i0].numStrips == 0) ) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].triangles.size(); i2++) { \
-			NifStream( skinPartitionBlocks[i0].triangles[i2], out, version ); \
-		}; \
-	}; \
-	NifStream( skinPartitionBlocks[i0].hasBoneIndices, out, version ); \
-	if ( (skinPartitionBlocks[i0].hasBoneIndices != 0) ) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].boneIndices.size(); i2++) { \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].boneIndices[i2].size(); i3++) { \
-				NifStream( skinPartitionBlocks[i0].boneIndices[i2][i3], out, version ); \
-			}; \
-		}; \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SKIN_PARTITION_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Num Skin Partition Blocks:  " << numSkinPartitionBlocks << endl; \
-for (uint i0 = 0; i0 < skinPartitionBlocks.size(); i0++) { \
-	out << "  Num Vertices:  " << skinPartitionBlocks[i0].numVertices << endl; \
-	out << "  Num Triangles:  " << skinPartitionBlocks[i0].numTriangles << endl; \
-	out << "  Num Bones:  " << skinPartitionBlocks[i0].numBones << endl; \
-	out << "  Num Strips:  " << skinPartitionBlocks[i0].numStrips << endl; \
-	out << "  Num Weights Per Vertex:  " << skinPartitionBlocks[i0].numWeightsPerVertex << endl; \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].bones.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Bones[" << i1 << "]:  " << skinPartitionBlocks[i0].bones[i1] << endl; \
-	}; \
-	out << "  Has Vertex Map:  " << skinPartitionBlocks[i0].hasVertexMap << endl; \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].vertexMap.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Vertex Map[" << i1 << "]:  " << skinPartitionBlocks[i0].vertexMap[i1] << endl; \
-	}; \
-	out << "  Has Vertex Weights:  " << skinPartitionBlocks[i0].hasVertexWeights << endl; \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].vertexWeights.size(); i1++) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].vertexWeights[i1].size(); i2++) { \
-			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) { \
-				out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-				break; \
-			}; \
-			out << "      Vertex Weights[" << i1 << "][" << i2 << "]:  " << skinPartitionBlocks[i0].vertexWeights[i1][i2] << endl; \
-		}; \
-	}; \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].stripLengths.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Strip Lengths[" << i1 << "]:  " << skinPartitionBlocks[i0].stripLengths[i1] << endl; \
-	}; \
-	out << "  Has Strips:  " << skinPartitionBlocks[i0].hasStrips << endl; \
-	for (uint i1 = 0; i1 < skinPartitionBlocks[i0].strips.size(); i1++) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].stripLengths[i1]; i2++) { \
-			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) { \
-				out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-				break; \
-			}; \
-			out << "      Strips[" << i1 << "][" << i2 << "]:  " << skinPartitionBlocks[i0].strips[i1][i2] << endl; \
-		}; \
-	}; \
-	if ( (skinPartitionBlocks[i0].numStrips == 0) ) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].triangles.size(); i2++) { \
-			if ( !verbose && ( i2 > MAXARRAYDUMP ) ) { \
-				out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-				break; \
-			}; \
-			out << "      Triangles[" << i2 << "]:  " << skinPartitionBlocks[i0].triangles[i2] << endl; \
-		}; \
-	}; \
-	out << "  Has Bone Indices:  " << skinPartitionBlocks[i0].hasBoneIndices << endl; \
-	if ( (skinPartitionBlocks[i0].hasBoneIndices != 0) ) { \
-		for (uint i2 = 0; i2 < skinPartitionBlocks[i0].boneIndices.size(); i2++) { \
-			for (uint i3 = 0; i3 < skinPartitionBlocks[i0].boneIndices[i2].size(); i3++) { \
-				if ( !verbose && ( i3 > MAXARRAYDUMP ) ) { \
-					out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-					break; \
-				}; \
-				out << "        Bone Indices[" << i2 << "][" << i3 << "]:  " << skinPartitionBlocks[i0].boneIndices[i2][i3] << endl; \
-			}; \
-		}; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SKIN_PARTITION_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SKIN_PARTITION_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SOURCE_TEXTURE_MEMBERS \
 byte useExternal; \
@@ -12122,132 +5035,19 @@ byte unknownByte2; \
  : useExternal((byte)1), unknownLink(NULL), unknownByte((byte)0), pixelData(NULL), pixelLayout((PixelLayout)5), useMipmaps((MipMapFormat)2), alphaFormat((AlphaFormat)3), unknownByte2((byte)1) \
 
 #define NI_SOURCE_TEXTURE_READ \
-uint block_num; \
-NiObjectNET::Read( in, link_stack, version, user_version ); \
-NifStream( useExternal, in, version ); \
-if ( (useExternal == 1) ) { \
-	NifStream( fileName, in, version ); \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (useExternal == 1) ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-	}; \
-}; \
-if ( version <= 0x0A000100 ) { \
-	if ( (useExternal == 0) ) { \
-		NifStream( unknownByte, in, version ); \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (useExternal == 0) ) { \
-		NifStream( originalFileName_, in, version ); \
-	}; \
-}; \
-if ( (useExternal == 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
-NifStream( pixelLayout, in, version ); \
-NifStream( useMipmaps, in, version ); \
-NifStream( alphaFormat, in, version ); \
-NifStream( unknownByte, in, version ); \
-if ( version >= 0x0A01006A ) { \
-	NifStream( unknownByte2, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SOURCE_TEXTURE_WRITE \
-NiObjectNET::Write( out, link_map, version, user_version ); \
-NifStream( useExternal, out, version ); \
-if ( (useExternal == 1) ) { \
-	NifStream( fileName, out, version ); \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (useExternal == 1) ) { \
-		if ( unknownLink != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(unknownLink)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-	}; \
-}; \
-if ( version <= 0x0A000100 ) { \
-	if ( (useExternal == 0) ) { \
-		NifStream( unknownByte, out, version ); \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (useExternal == 0) ) { \
-		NifStream( originalFileName_, out, version ); \
-	}; \
-}; \
-if ( (useExternal == 0) ) { \
-	if ( pixelData != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(pixelData)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
-NifStream( pixelLayout, out, version ); \
-NifStream( useMipmaps, out, version ); \
-NifStream( alphaFormat, out, version ); \
-NifStream( unknownByte, out, version ); \
-if ( version >= 0x0A01006A ) { \
-	NifStream( unknownByte2, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SOURCE_TEXTURE_STRING \
-stringstream out; \
-out << NiObjectNET::asString(); \
-out << "Use External:  " << useExternal << endl; \
-if ( (useExternal == 1) ) { \
-	out << "  File Name:  " << fileName << endl; \
-	out << "  Unknown Link:  " << unknownLink << endl; \
-}; \
-if ( (useExternal == 0) ) { \
-	out << "  Unknown Byte:  " << unknownByte << endl; \
-	out << "  Original File Name?:  " << originalFileName_ << endl; \
-	out << "  Pixel Data:  " << pixelData << endl; \
-}; \
-out << "Pixel Layout:  " << pixelLayout << endl; \
-out << "Use Mipmaps:  " << useMipmaps << endl; \
-out << "Alpha Format:  " << alphaFormat << endl; \
-out << "Unknown Byte 2:  " << unknownByte2 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SOURCE_TEXTURE_FIXLINKS \
-NiObjectNET::FixLinks( objects, link_stack, version, user_version ); \
-if ( version >= 0x0A010000 ) { \
-	if ( (useExternal == 1) ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			unknownLink = DynamicCast<NiObject>(objects[link_stack.front()]); \
-			if ( unknownLink == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			unknownLink = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
-if ( (useExternal == 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		pixelData = DynamicCast<NiPixelData>(objects[link_stack.front()]); \
-		if ( pixelData == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		pixelData = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SOURCE_TEXTURE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObjectNET::GetRefs(); \
-if ( unknownLink != NULL ) \
-	refs.push_back(StaticCast<NiObject>(unknownLink)); \
-if ( pixelData != NULL ) \
-	refs.push_back(StaticCast<NiObject>(pixelData)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SPECULAR_PROPERTY_MEMBERS \
 ushort flags; \
@@ -12260,26 +5060,19 @@ ushort flags; \
  : flags((ushort)0) \
 
 #define NI_SPECULAR_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SPECULAR_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SPECULAR_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SPECULAR_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SPECULAR_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SPHERICAL_COLLIDER_MEMBERS \
 float unknownFloat1; \
@@ -12297,41 +5090,19 @@ float unknownFloat5; \
  : unknownFloat1(0.0f), unknownShort((ushort)0), unknownFloat2(0.0f), unknownFloat3(0.0f), unknownFloat4(0.0f), unknownFloat5(0.0f) \
 
 #define NI_SPHERICAL_COLLIDER_READ \
-AParticleModifier::Read( in, link_stack, version, user_version ); \
-NifStream( unknownFloat1, in, version ); \
-NifStream( unknownShort, in, version ); \
-NifStream( unknownFloat2, in, version ); \
-NifStream( unknownFloat3, in, version ); \
-NifStream( unknownFloat4, in, version ); \
-NifStream( unknownFloat5, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SPHERICAL_COLLIDER_WRITE \
-AParticleModifier::Write( out, link_map, version, user_version ); \
-NifStream( unknownFloat1, out, version ); \
-NifStream( unknownShort, out, version ); \
-NifStream( unknownFloat2, out, version ); \
-NifStream( unknownFloat3, out, version ); \
-NifStream( unknownFloat4, out, version ); \
-NifStream( unknownFloat5, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SPHERICAL_COLLIDER_STRING \
-stringstream out; \
-out << AParticleModifier::asString(); \
-out << "Unknown Float 1:  " << unknownFloat1 << endl; \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Unknown Float 2:  " << unknownFloat2 << endl; \
-out << "Unknown Float 3:  " << unknownFloat3 << endl; \
-out << "Unknown Float 4:  " << unknownFloat4 << endl; \
-out << "Unknown Float 5:  " << unknownFloat5 << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SPHERICAL_COLLIDER_FIXLINKS \
-AParticleModifier::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SPHERICAL_COLLIDER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AParticleModifier::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_SPOT_LIGHT_MEMBERS \
 float cutoffAngle; \
@@ -12345,29 +5116,19 @@ float exponent; \
  : cutoffAngle(0.0f), exponent(0.0f) \
 
 #define NI_SPOT_LIGHT_READ \
-NiPointLight::Read( in, link_stack, version, user_version ); \
-NifStream( cutoffAngle, in, version ); \
-NifStream( exponent, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_SPOT_LIGHT_WRITE \
-NiPointLight::Write( out, link_map, version, user_version ); \
-NifStream( cutoffAngle, out, version ); \
-NifStream( exponent, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_SPOT_LIGHT_STRING \
-stringstream out; \
-out << NiPointLight::asString(); \
-out << "Cutoff Angle:  " << cutoffAngle << endl; \
-out << "Exponent:  " << exponent << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_SPOT_LIGHT_FIXLINKS \
-NiPointLight::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_SPOT_LIGHT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiPointLight::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_STENCIL_PROPERTY_MEMBERS \
 ushort flags; \
@@ -12388,54 +5149,19 @@ uint drawMode; \
  : flags((ushort)0), stencilEnabled(false), stencilFunction((uint)0), stencilRef((uint)0), stencilMask((uint)4294967295), failAction((uint)0), zFailAction((uint)0), passAction((uint)0), drawMode((uint)0) \
 
 #define NI_STENCIL_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x0A000102 ) { \
-	NifStream( flags, in, version ); \
-}; \
-NifStream( stencilEnabled, in, version ); \
-NifStream( stencilFunction, in, version ); \
-NifStream( stencilRef, in, version ); \
-NifStream( stencilMask, in, version ); \
-NifStream( failAction, in, version ); \
-NifStream( zFailAction, in, version ); \
-NifStream( passAction, in, version ); \
-NifStream( drawMode, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_STENCIL_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-if ( version <= 0x0A000102 ) { \
-	NifStream( flags, out, version ); \
-}; \
-NifStream( stencilEnabled, out, version ); \
-NifStream( stencilFunction, out, version ); \
-NifStream( stencilRef, out, version ); \
-NifStream( stencilMask, out, version ); \
-NifStream( failAction, out, version ); \
-NifStream( zFailAction, out, version ); \
-NifStream( passAction, out, version ); \
-NifStream( drawMode, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_STENCIL_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Stencil Enabled:  " << stencilEnabled << endl; \
-out << "Stencil Function:  " << stencilFunction << endl; \
-out << "Stencil Ref:  " << stencilRef << endl; \
-out << "Stencil Mask:  " << stencilMask << endl; \
-out << "Fail Action:  " << failAction << endl; \
-out << "Z Fail Action:  " << zFailAction << endl; \
-out << "Pass Action:  " << passAction << endl; \
-out << "Draw Mode:  " << drawMode << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_STENCIL_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_STENCIL_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_STRING_EXTRA_DATA_MEMBERS \
 uint bytesRemaining; \
@@ -12449,33 +5175,19 @@ string stringData; \
  : bytesRemaining((uint)0) \
 
 #define NI_STRING_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x04020200 ) { \
-	NifStream( bytesRemaining, in, version ); \
-}; \
-NifStream( stringData, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_STRING_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-if ( version <= 0x04020200 ) { \
-	NifStream( bytesRemaining, out, version ); \
-}; \
-NifStream( stringData, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_STRING_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Bytes Remaining:  " << bytesRemaining << endl; \
-out << "String Data:  " << stringData << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_STRING_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_STRING_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_STRING_PALETTE_MEMBERS \
 StringPalette palette; \
@@ -12487,32 +5199,22 @@ StringPalette palette; \
 #define NI_STRING_PALETTE_CONSTRUCT \
 
 #define NI_STRING_PALETTE_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-NifStream( palette.palette, in, version ); \
-NifStream( palette.length, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_STRING_PALETTE_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-NifStream( palette.palette, out, version ); \
-NifStream( palette.length, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_STRING_PALETTE_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-out << "Palette:  " << palette.palette << endl; \
-out << "Length:  " << palette.length << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_STRING_PALETTE_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_STRING_PALETTE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_STRINGS_EXTRA_DATA_MEMBERS \
-uint numStrings; \
+mutable uint numStrings; \
 vector<string > data; \
 
 #define NI_STRINGS_EXTRA_DATA_INCLUDE "NiExtraData.h" \
@@ -12523,44 +5225,23 @@ vector<string > data; \
  : numStrings((uint)0) \
 
 #define NI_STRINGS_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( numStrings, in, version ); \
-data.resize(numStrings); \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	NifStream( data[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_STRINGS_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( numStrings, out, version ); \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	NifStream( data[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_STRINGS_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Num Strings:  " << numStrings << endl; \
-for (uint i0 = 0; i0 < data.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Data[" << i0 << "]:  " << data[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_STRINGS_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_STRINGS_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TEXT_KEY_EXTRA_DATA_MEMBERS \
 uint unknownInt1; \
-uint numTextKeys; \
+mutable uint numTextKeys; \
 vector<Key<string > > textKeys; \
 
 #define NI_TEXT_KEY_EXTRA_DATA_INCLUDE "NiExtraData.h" \
@@ -12571,47 +5252,19 @@ vector<Key<string > > textKeys; \
  : unknownInt1((uint)0), numTextKeys((uint)0) \
 
 #define NI_TEXT_KEY_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x04020200 ) { \
-	NifStream( unknownInt1, in, version ); \
-}; \
-NifStream( numTextKeys, in, version ); \
-textKeys.resize(numTextKeys); \
-for (uint i0 = 0; i0 < textKeys.size(); i0++) { \
-	NifStream( textKeys[i0], in, version, 1 ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TEXT_KEY_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-if ( version <= 0x04020200 ) { \
-	NifStream( unknownInt1, out, version ); \
-}; \
-NifStream( numTextKeys, out, version ); \
-for (uint i0 = 0; i0 < textKeys.size(); i0++) { \
-	NifStream( textKeys[i0], out, version, 1 ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TEXT_KEY_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Unknown Int 1:  " << unknownInt1 << endl; \
-out << "Num Text Keys:  " << numTextKeys << endl; \
-for (uint i0 = 0; i0 < textKeys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Text Keys[" << i0 << "]:  " << textKeys[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TEXT_KEY_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TEXT_KEY_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TEXTURE_EFFECT_MEMBERS \
 Matrix33 modelProjectionMatrix; \
@@ -12636,86 +5289,19 @@ ushort unknownShort; \
  : textureFiltering((uint)0), textureClamping((uint)0), textureType((uint)0), coordinateGenerationType((uint)0), sourceTexture(NULL), clippingPlane((byte)0), unknownFloat(0.0f), ps2L((ushort)0), ps2K((ushort)0), unknownShort((ushort)0) \
 
 #define NI_TEXTURE_EFFECT_READ \
-uint block_num; \
-NiDynamicEffect::Read( in, link_stack, version, user_version ); \
-NifStream( modelProjectionMatrix, in, version ); \
-NifStream( modelProjectionTransform, in, version ); \
-NifStream( textureFiltering, in, version ); \
-NifStream( textureClamping, in, version ); \
-NifStream( textureType, in, version ); \
-NifStream( coordinateGenerationType, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
-NifStream( clippingPlane, in, version ); \
-NifStream( unknownVector, in, version ); \
-NifStream( unknownFloat, in, version ); \
-if ( version <= 0x0A020000 ) { \
-	NifStream( ps2L, in, version ); \
-	NifStream( ps2K, in, version ); \
-}; \
-if ( version <= 0x0401000C ) { \
-	NifStream( unknownShort, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TEXTURE_EFFECT_WRITE \
-NiDynamicEffect::Write( out, link_map, version, user_version ); \
-NifStream( modelProjectionMatrix, out, version ); \
-NifStream( modelProjectionTransform, out, version ); \
-NifStream( textureFiltering, out, version ); \
-NifStream( textureClamping, out, version ); \
-NifStream( textureType, out, version ); \
-NifStream( coordinateGenerationType, out, version ); \
-if ( sourceTexture != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(sourceTexture)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
-NifStream( clippingPlane, out, version ); \
-NifStream( unknownVector, out, version ); \
-NifStream( unknownFloat, out, version ); \
-if ( version <= 0x0A020000 ) { \
-	NifStream( ps2L, out, version ); \
-	NifStream( ps2K, out, version ); \
-}; \
-if ( version <= 0x0401000C ) { \
-	NifStream( unknownShort, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TEXTURE_EFFECT_STRING \
-stringstream out; \
-out << NiDynamicEffect::asString(); \
-out << "Model Projection Matrix:  " << modelProjectionMatrix << endl; \
-out << "Model Projection Transform:  " << modelProjectionTransform << endl; \
-out << "Texture Filtering:  " << textureFiltering << endl; \
-out << "Texture Clamping:  " << textureClamping << endl; \
-out << "Texture Type:  " << textureType << endl; \
-out << "Coordinate Generation Type:  " << coordinateGenerationType << endl; \
-out << "Source Texture:  " << sourceTexture << endl; \
-out << "Clipping Plane:  " << clippingPlane << endl; \
-out << "Unknown Vector:  " << unknownVector << endl; \
-out << "Unknown Float:  " << unknownFloat << endl; \
-out << "PS2 L:  " << ps2L << endl; \
-out << "PS2 K:  " << ps2K << endl; \
-out << "Unknown Short:  " << unknownShort << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TEXTURE_EFFECT_FIXLINKS \
-NiDynamicEffect::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	sourceTexture = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-	if ( sourceTexture == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	sourceTexture = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TEXTURE_EFFECT_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiDynamicEffect::GetRefs(); \
-if ( sourceTexture != NULL ) \
-	refs.push_back(StaticCast<NiObject>(sourceTexture)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TEXTURE_TRANSFORM_CONTROLLER_MEMBERS \
 byte unknown2; \
@@ -12731,57 +5317,19 @@ Ref<NiFloatData > data; \
  : unknown2((byte)0), textureSlot((uint)0), operation((uint)0), data(NULL) \
 
 #define NI_TEXTURE_TRANSFORM_CONTROLLER_READ \
-uint block_num; \
-NiSingleInterpolatorController::Read( in, link_stack, version, user_version ); \
-NifStream( unknown2, in, version ); \
-NifStream( textureSlot, in, version ); \
-NifStream( operation, in, version ); \
-if ( version <= 0x0A010000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TEXTURE_TRANSFORM_CONTROLLER_WRITE \
-NiSingleInterpolatorController::Write( out, link_map, version, user_version ); \
-NifStream( unknown2, out, version ); \
-NifStream( textureSlot, out, version ); \
-NifStream( operation, out, version ); \
-if ( version <= 0x0A010000 ) { \
-	if ( data != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TEXTURE_TRANSFORM_CONTROLLER_STRING \
-stringstream out; \
-out << NiSingleInterpolatorController::asString(); \
-out << "Unknown2:  " << unknown2 << endl; \
-out << "Texture Slot:  " << textureSlot << endl; \
-out << "Operation:  " << operation << endl; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TEXTURE_TRANSFORM_CONTROLLER_FIXLINKS \
-NiSingleInterpolatorController::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		data = DynamicCast<NiFloatData>(objects[link_stack.front()]); \
-		if ( data == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		data = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TEXTURE_TRANSFORM_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiSingleInterpolatorController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TEXTURING_PROPERTY_MEMBERS \
 ushort flags; \
@@ -12806,7 +5354,7 @@ bool hasDecal0Texture; \
 TexDesc decal0Texture; \
 bool hasDecal1Texture; \
 TexDesc decal1Texture; \
-uint numShaderTextures; \
+mutable uint numShaderTextures; \
 vector<ShaderTexDesc > shaderTextures; \
 
 #define NI_TEXTURING_PROPERTY_INCLUDE "NiProperty.h" \
@@ -12817,828 +5365,19 @@ vector<ShaderTexDesc > shaderTextures; \
  : flags((ushort)0), applyMode((ApplyMode)2), textureCount((uint)7), hasBaseTexture(false), hasDarkTexture(false), hasDetailTexture(false), hasGlossTexture(false), hasGlowTexture(false), hasBumpMapTexture(false), bumpMapLumaScale(0.0f), bumpMapLumaOffset(0.0f), hasDecal0Texture(false), hasDecal1Texture(false), numShaderTextures((uint)0) \
 
 #define NI_TEXTURING_PROPERTY_READ \
-uint block_num; \
-NiProperty::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x0A000102 ) { \
-	NifStream( flags, in, version ); \
-}; \
-NifStream( applyMode, in, version ); \
-NifStream( textureCount, in, version ); \
-NifStream( hasBaseTexture, in, version ); \
-if ( (hasBaseTexture != 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( baseTexture.clampMode, in, version ); \
-	NifStream( baseTexture.filterMode, in, version ); \
-	NifStream( baseTexture.textureSet, in, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( baseTexture.ps2L, in, version ); \
-		NifStream( baseTexture.ps2K, in, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( baseTexture.unknown1, in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( baseTexture.hasTextureTransform, in, version ); \
-		if ( (baseTexture.hasTextureTransform != 0) ) { \
-			NifStream( baseTexture.translation, in, version ); \
-			NifStream( baseTexture.tiling, in, version ); \
-			NifStream( baseTexture.wRotation, in, version ); \
-			NifStream( baseTexture.transformType_, in, version ); \
-			NifStream( baseTexture.centerOffset, in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasDarkTexture, in, version ); \
-if ( (hasDarkTexture != 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( darkTexture.clampMode, in, version ); \
-	NifStream( darkTexture.filterMode, in, version ); \
-	NifStream( darkTexture.textureSet, in, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( darkTexture.ps2L, in, version ); \
-		NifStream( darkTexture.ps2K, in, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( darkTexture.unknown1, in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( darkTexture.hasTextureTransform, in, version ); \
-		if ( (darkTexture.hasTextureTransform != 0) ) { \
-			NifStream( darkTexture.translation, in, version ); \
-			NifStream( darkTexture.tiling, in, version ); \
-			NifStream( darkTexture.wRotation, in, version ); \
-			NifStream( darkTexture.transformType_, in, version ); \
-			NifStream( darkTexture.centerOffset, in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasDetailTexture, in, version ); \
-if ( (hasDetailTexture != 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( detailTexture.clampMode, in, version ); \
-	NifStream( detailTexture.filterMode, in, version ); \
-	NifStream( detailTexture.textureSet, in, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( detailTexture.ps2L, in, version ); \
-		NifStream( detailTexture.ps2K, in, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( detailTexture.unknown1, in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( detailTexture.hasTextureTransform, in, version ); \
-		if ( (detailTexture.hasTextureTransform != 0) ) { \
-			NifStream( detailTexture.translation, in, version ); \
-			NifStream( detailTexture.tiling, in, version ); \
-			NifStream( detailTexture.wRotation, in, version ); \
-			NifStream( detailTexture.transformType_, in, version ); \
-			NifStream( detailTexture.centerOffset, in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasGlossTexture, in, version ); \
-if ( (hasGlossTexture != 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( glossTexture.clampMode, in, version ); \
-	NifStream( glossTexture.filterMode, in, version ); \
-	NifStream( glossTexture.textureSet, in, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( glossTexture.ps2L, in, version ); \
-		NifStream( glossTexture.ps2K, in, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( glossTexture.unknown1, in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( glossTexture.hasTextureTransform, in, version ); \
-		if ( (glossTexture.hasTextureTransform != 0) ) { \
-			NifStream( glossTexture.translation, in, version ); \
-			NifStream( glossTexture.tiling, in, version ); \
-			NifStream( glossTexture.wRotation, in, version ); \
-			NifStream( glossTexture.transformType_, in, version ); \
-			NifStream( glossTexture.centerOffset, in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasGlowTexture, in, version ); \
-if ( (hasGlowTexture != 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( glowTexture.clampMode, in, version ); \
-	NifStream( glowTexture.filterMode, in, version ); \
-	NifStream( glowTexture.textureSet, in, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( glowTexture.ps2L, in, version ); \
-		NifStream( glowTexture.ps2K, in, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( glowTexture.unknown1, in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( glowTexture.hasTextureTransform, in, version ); \
-		if ( (glowTexture.hasTextureTransform != 0) ) { \
-			NifStream( glowTexture.translation, in, version ); \
-			NifStream( glowTexture.tiling, in, version ); \
-			NifStream( glowTexture.wRotation, in, version ); \
-			NifStream( glowTexture.transformType_, in, version ); \
-			NifStream( glowTexture.centerOffset, in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasBumpMapTexture, in, version ); \
-if ( (hasBumpMapTexture != 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( bumpMapTexture.clampMode, in, version ); \
-	NifStream( bumpMapTexture.filterMode, in, version ); \
-	NifStream( bumpMapTexture.textureSet, in, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( bumpMapTexture.ps2L, in, version ); \
-		NifStream( bumpMapTexture.ps2K, in, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( bumpMapTexture.unknown1, in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( bumpMapTexture.hasTextureTransform, in, version ); \
-		if ( (bumpMapTexture.hasTextureTransform != 0) ) { \
-			NifStream( bumpMapTexture.translation, in, version ); \
-			NifStream( bumpMapTexture.tiling, in, version ); \
-			NifStream( bumpMapTexture.wRotation, in, version ); \
-			NifStream( bumpMapTexture.transformType_, in, version ); \
-			NifStream( bumpMapTexture.centerOffset, in, version ); \
-		}; \
-	}; \
-	NifStream( bumpMapLumaScale, in, version ); \
-	NifStream( bumpMapLumaOffset, in, version ); \
-	NifStream( bumpMapMatrix, in, version ); \
-}; \
-NifStream( hasDecal0Texture, in, version ); \
-if ( (hasDecal0Texture != 0) ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-	NifStream( decal0Texture.clampMode, in, version ); \
-	NifStream( decal0Texture.filterMode, in, version ); \
-	NifStream( decal0Texture.textureSet, in, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( decal0Texture.ps2L, in, version ); \
-		NifStream( decal0Texture.ps2K, in, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( decal0Texture.unknown1, in, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( decal0Texture.hasTextureTransform, in, version ); \
-		if ( (decal0Texture.hasTextureTransform != 0) ) { \
-			NifStream( decal0Texture.translation, in, version ); \
-			NifStream( decal0Texture.tiling, in, version ); \
-			NifStream( decal0Texture.wRotation, in, version ); \
-			NifStream( decal0Texture.transformType_, in, version ); \
-			NifStream( decal0Texture.centerOffset, in, version ); \
-		}; \
-	}; \
-}; \
-if ( (textureCount == 8) ) { \
-	NifStream( hasDecal1Texture, in, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	if ( (((textureCount == 8)) && ((hasDecal1Texture != 0))) ) { \
-		NifStream( block_num, in, version ); \
-		link_stack.push_back( block_num ); \
-		NifStream( decal1Texture.clampMode, in, version ); \
-		NifStream( decal1Texture.filterMode, in, version ); \
-		NifStream( decal1Texture.textureSet, in, version ); \
-		if ( version <= 0x0A020000 ) { \
-			NifStream( decal1Texture.ps2L, in, version ); \
-			NifStream( decal1Texture.ps2K, in, version ); \
-		}; \
-		if ( version <= 0x0401000C ) { \
-			NifStream( decal1Texture.unknown1, in, version ); \
-		}; \
-		if ( version >= 0x0A010000 ) { \
-			NifStream( decal1Texture.hasTextureTransform, in, version ); \
-			if ( (decal1Texture.hasTextureTransform != 0) ) { \
-				NifStream( decal1Texture.translation, in, version ); \
-				NifStream( decal1Texture.tiling, in, version ); \
-				NifStream( decal1Texture.wRotation, in, version ); \
-				NifStream( decal1Texture.transformType_, in, version ); \
-				NifStream( decal1Texture.centerOffset, in, version ); \
-			}; \
-		}; \
-	}; \
-}; \
-if ( version >= 0x0A000100 ) { \
-	NifStream( numShaderTextures, in, version ); \
-	shaderTextures.resize(numShaderTextures); \
-	for (uint i1 = 0; i1 < shaderTextures.size(); i1++) { \
-		NifStream( shaderTextures[i1].isUsed, in, version ); \
-		if ( (shaderTextures[i1].isUsed != 0) ) { \
-			NifStream( block_num, in, version ); \
-			link_stack.push_back( block_num ); \
-			NifStream( shaderTextures[i1].textureData.clampMode, in, version ); \
-			NifStream( shaderTextures[i1].textureData.filterMode, in, version ); \
-			NifStream( shaderTextures[i1].textureData.textureSet, in, version ); \
-			if ( version <= 0x0A020000 ) { \
-				NifStream( shaderTextures[i1].textureData.ps2L, in, version ); \
-				NifStream( shaderTextures[i1].textureData.ps2K, in, version ); \
-			}; \
-			if ( version <= 0x0401000C ) { \
-				NifStream( shaderTextures[i1].textureData.unknown1, in, version ); \
-			}; \
-			if ( version >= 0x0A010000 ) { \
-				NifStream( shaderTextures[i1].textureData.hasTextureTransform, in, version ); \
-				if ( (shaderTextures[i1].textureData.hasTextureTransform != 0) ) { \
-					NifStream( shaderTextures[i1].textureData.translation, in, version ); \
-					NifStream( shaderTextures[i1].textureData.tiling, in, version ); \
-					NifStream( shaderTextures[i1].textureData.wRotation, in, version ); \
-					NifStream( shaderTextures[i1].textureData.transformType_, in, version ); \
-					NifStream( shaderTextures[i1].textureData.centerOffset, in, version ); \
-				}; \
-			}; \
-			NifStream( shaderTextures[i1].unknownInt, in, version ); \
-		}; \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TEXTURING_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-if ( version <= 0x0A000102 ) { \
-	NifStream( flags, out, version ); \
-}; \
-NifStream( applyMode, out, version ); \
-NifStream( textureCount, out, version ); \
-NifStream( hasBaseTexture, out, version ); \
-if ( (hasBaseTexture != 0) ) { \
-	if ( baseTexture.source != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(baseTexture.source)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( baseTexture.clampMode, out, version ); \
-	NifStream( baseTexture.filterMode, out, version ); \
-	NifStream( baseTexture.textureSet, out, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( baseTexture.ps2L, out, version ); \
-		NifStream( baseTexture.ps2K, out, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( baseTexture.unknown1, out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( baseTexture.hasTextureTransform, out, version ); \
-		if ( (baseTexture.hasTextureTransform != 0) ) { \
-			NifStream( baseTexture.translation, out, version ); \
-			NifStream( baseTexture.tiling, out, version ); \
-			NifStream( baseTexture.wRotation, out, version ); \
-			NifStream( baseTexture.transformType_, out, version ); \
-			NifStream( baseTexture.centerOffset, out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasDarkTexture, out, version ); \
-if ( (hasDarkTexture != 0) ) { \
-	if ( darkTexture.source != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(darkTexture.source)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( darkTexture.clampMode, out, version ); \
-	NifStream( darkTexture.filterMode, out, version ); \
-	NifStream( darkTexture.textureSet, out, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( darkTexture.ps2L, out, version ); \
-		NifStream( darkTexture.ps2K, out, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( darkTexture.unknown1, out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( darkTexture.hasTextureTransform, out, version ); \
-		if ( (darkTexture.hasTextureTransform != 0) ) { \
-			NifStream( darkTexture.translation, out, version ); \
-			NifStream( darkTexture.tiling, out, version ); \
-			NifStream( darkTexture.wRotation, out, version ); \
-			NifStream( darkTexture.transformType_, out, version ); \
-			NifStream( darkTexture.centerOffset, out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasDetailTexture, out, version ); \
-if ( (hasDetailTexture != 0) ) { \
-	if ( detailTexture.source != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(detailTexture.source)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( detailTexture.clampMode, out, version ); \
-	NifStream( detailTexture.filterMode, out, version ); \
-	NifStream( detailTexture.textureSet, out, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( detailTexture.ps2L, out, version ); \
-		NifStream( detailTexture.ps2K, out, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( detailTexture.unknown1, out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( detailTexture.hasTextureTransform, out, version ); \
-		if ( (detailTexture.hasTextureTransform != 0) ) { \
-			NifStream( detailTexture.translation, out, version ); \
-			NifStream( detailTexture.tiling, out, version ); \
-			NifStream( detailTexture.wRotation, out, version ); \
-			NifStream( detailTexture.transformType_, out, version ); \
-			NifStream( detailTexture.centerOffset, out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasGlossTexture, out, version ); \
-if ( (hasGlossTexture != 0) ) { \
-	if ( glossTexture.source != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(glossTexture.source)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( glossTexture.clampMode, out, version ); \
-	NifStream( glossTexture.filterMode, out, version ); \
-	NifStream( glossTexture.textureSet, out, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( glossTexture.ps2L, out, version ); \
-		NifStream( glossTexture.ps2K, out, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( glossTexture.unknown1, out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( glossTexture.hasTextureTransform, out, version ); \
-		if ( (glossTexture.hasTextureTransform != 0) ) { \
-			NifStream( glossTexture.translation, out, version ); \
-			NifStream( glossTexture.tiling, out, version ); \
-			NifStream( glossTexture.wRotation, out, version ); \
-			NifStream( glossTexture.transformType_, out, version ); \
-			NifStream( glossTexture.centerOffset, out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasGlowTexture, out, version ); \
-if ( (hasGlowTexture != 0) ) { \
-	if ( glowTexture.source != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(glowTexture.source)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( glowTexture.clampMode, out, version ); \
-	NifStream( glowTexture.filterMode, out, version ); \
-	NifStream( glowTexture.textureSet, out, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( glowTexture.ps2L, out, version ); \
-		NifStream( glowTexture.ps2K, out, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( glowTexture.unknown1, out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( glowTexture.hasTextureTransform, out, version ); \
-		if ( (glowTexture.hasTextureTransform != 0) ) { \
-			NifStream( glowTexture.translation, out, version ); \
-			NifStream( glowTexture.tiling, out, version ); \
-			NifStream( glowTexture.wRotation, out, version ); \
-			NifStream( glowTexture.transformType_, out, version ); \
-			NifStream( glowTexture.centerOffset, out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( hasBumpMapTexture, out, version ); \
-if ( (hasBumpMapTexture != 0) ) { \
-	if ( bumpMapTexture.source != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(bumpMapTexture.source)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( bumpMapTexture.clampMode, out, version ); \
-	NifStream( bumpMapTexture.filterMode, out, version ); \
-	NifStream( bumpMapTexture.textureSet, out, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( bumpMapTexture.ps2L, out, version ); \
-		NifStream( bumpMapTexture.ps2K, out, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( bumpMapTexture.unknown1, out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( bumpMapTexture.hasTextureTransform, out, version ); \
-		if ( (bumpMapTexture.hasTextureTransform != 0) ) { \
-			NifStream( bumpMapTexture.translation, out, version ); \
-			NifStream( bumpMapTexture.tiling, out, version ); \
-			NifStream( bumpMapTexture.wRotation, out, version ); \
-			NifStream( bumpMapTexture.transformType_, out, version ); \
-			NifStream( bumpMapTexture.centerOffset, out, version ); \
-		}; \
-	}; \
-	NifStream( bumpMapLumaScale, out, version ); \
-	NifStream( bumpMapLumaOffset, out, version ); \
-	NifStream( bumpMapMatrix, out, version ); \
-}; \
-NifStream( hasDecal0Texture, out, version ); \
-if ( (hasDecal0Texture != 0) ) { \
-	if ( decal0Texture.source != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(decal0Texture.source)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-	NifStream( decal0Texture.clampMode, out, version ); \
-	NifStream( decal0Texture.filterMode, out, version ); \
-	NifStream( decal0Texture.textureSet, out, version ); \
-	if ( version <= 0x0A020000 ) { \
-		NifStream( decal0Texture.ps2L, out, version ); \
-		NifStream( decal0Texture.ps2K, out, version ); \
-	}; \
-	if ( version <= 0x0401000C ) { \
-		NifStream( decal0Texture.unknown1, out, version ); \
-	}; \
-	if ( version >= 0x0A010000 ) { \
-		NifStream( decal0Texture.hasTextureTransform, out, version ); \
-		if ( (decal0Texture.hasTextureTransform != 0) ) { \
-			NifStream( decal0Texture.translation, out, version ); \
-			NifStream( decal0Texture.tiling, out, version ); \
-			NifStream( decal0Texture.wRotation, out, version ); \
-			NifStream( decal0Texture.transformType_, out, version ); \
-			NifStream( decal0Texture.centerOffset, out, version ); \
-		}; \
-	}; \
-}; \
-if ( (textureCount == 8) ) { \
-	NifStream( hasDecal1Texture, out, version ); \
-}; \
-if ( version >= 0x14000004 ) { \
-	if ( (((textureCount == 8)) && ((hasDecal1Texture != 0))) ) { \
-		if ( decal1Texture.source != NULL ) \
-			NifStream( link_map[StaticCast<NiObject>(decal1Texture.source)], out, version ); \
-		else \
-			NifStream( 0xffffffff, out, version ); \
-		NifStream( decal1Texture.clampMode, out, version ); \
-		NifStream( decal1Texture.filterMode, out, version ); \
-		NifStream( decal1Texture.textureSet, out, version ); \
-		if ( version <= 0x0A020000 ) { \
-			NifStream( decal1Texture.ps2L, out, version ); \
-			NifStream( decal1Texture.ps2K, out, version ); \
-		}; \
-		if ( version <= 0x0401000C ) { \
-			NifStream( decal1Texture.unknown1, out, version ); \
-		}; \
-		if ( version >= 0x0A010000 ) { \
-			NifStream( decal1Texture.hasTextureTransform, out, version ); \
-			if ( (decal1Texture.hasTextureTransform != 0) ) { \
-				NifStream( decal1Texture.translation, out, version ); \
-				NifStream( decal1Texture.tiling, out, version ); \
-				NifStream( decal1Texture.wRotation, out, version ); \
-				NifStream( decal1Texture.transformType_, out, version ); \
-				NifStream( decal1Texture.centerOffset, out, version ); \
-			}; \
-		}; \
-	}; \
-}; \
-if ( version >= 0x0A000100 ) { \
-	NifStream( numShaderTextures, out, version ); \
-	for (uint i1 = 0; i1 < shaderTextures.size(); i1++) { \
-		NifStream( shaderTextures[i1].isUsed, out, version ); \
-		if ( (shaderTextures[i1].isUsed != 0) ) { \
-			if ( shaderTextures[i1].textureData.source != NULL ) \
-				NifStream( link_map[StaticCast<NiObject>(shaderTextures[i1].textureData.source)], out, version ); \
-			else \
-				NifStream( 0xffffffff, out, version ); \
-			NifStream( shaderTextures[i1].textureData.clampMode, out, version ); \
-			NifStream( shaderTextures[i1].textureData.filterMode, out, version ); \
-			NifStream( shaderTextures[i1].textureData.textureSet, out, version ); \
-			if ( version <= 0x0A020000 ) { \
-				NifStream( shaderTextures[i1].textureData.ps2L, out, version ); \
-				NifStream( shaderTextures[i1].textureData.ps2K, out, version ); \
-			}; \
-			if ( version <= 0x0401000C ) { \
-				NifStream( shaderTextures[i1].textureData.unknown1, out, version ); \
-			}; \
-			if ( version >= 0x0A010000 ) { \
-				NifStream( shaderTextures[i1].textureData.hasTextureTransform, out, version ); \
-				if ( (shaderTextures[i1].textureData.hasTextureTransform != 0) ) { \
-					NifStream( shaderTextures[i1].textureData.translation, out, version ); \
-					NifStream( shaderTextures[i1].textureData.tiling, out, version ); \
-					NifStream( shaderTextures[i1].textureData.wRotation, out, version ); \
-					NifStream( shaderTextures[i1].textureData.transformType_, out, version ); \
-					NifStream( shaderTextures[i1].textureData.centerOffset, out, version ); \
-				}; \
-			}; \
-			NifStream( shaderTextures[i1].unknownInt, out, version ); \
-		}; \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TEXTURING_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Apply Mode:  " << applyMode << endl; \
-out << "Texture Count:  " << textureCount << endl; \
-out << "Has Base Texture:  " << hasBaseTexture << endl; \
-if ( (hasBaseTexture != 0) ) { \
-	out << "  Source:  " << baseTexture.source << endl; \
-	out << "  Clamp Mode:  " << baseTexture.clampMode << endl; \
-	out << "  Filter Mode:  " << baseTexture.filterMode << endl; \
-	out << "  Texture Set:  " << baseTexture.textureSet << endl; \
-	out << "  PS2 L:  " << baseTexture.ps2L << endl; \
-	out << "  PS2 K:  " << baseTexture.ps2K << endl; \
-	out << "  Unknown1:  " << baseTexture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << baseTexture.hasTextureTransform << endl; \
-	if ( (baseTexture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << baseTexture.translation << endl; \
-		out << "    Tiling:  " << baseTexture.tiling << endl; \
-		out << "    W Rotation:  " << baseTexture.wRotation << endl; \
-		out << "    Transform Type?:  " << baseTexture.transformType_ << endl; \
-		out << "    Center Offset:  " << baseTexture.centerOffset << endl; \
-	}; \
-}; \
-out << "Has Dark Texture:  " << hasDarkTexture << endl; \
-if ( (hasDarkTexture != 0) ) { \
-	out << "  Source:  " << darkTexture.source << endl; \
-	out << "  Clamp Mode:  " << darkTexture.clampMode << endl; \
-	out << "  Filter Mode:  " << darkTexture.filterMode << endl; \
-	out << "  Texture Set:  " << darkTexture.textureSet << endl; \
-	out << "  PS2 L:  " << darkTexture.ps2L << endl; \
-	out << "  PS2 K:  " << darkTexture.ps2K << endl; \
-	out << "  Unknown1:  " << darkTexture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << darkTexture.hasTextureTransform << endl; \
-	if ( (darkTexture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << darkTexture.translation << endl; \
-		out << "    Tiling:  " << darkTexture.tiling << endl; \
-		out << "    W Rotation:  " << darkTexture.wRotation << endl; \
-		out << "    Transform Type?:  " << darkTexture.transformType_ << endl; \
-		out << "    Center Offset:  " << darkTexture.centerOffset << endl; \
-	}; \
-}; \
-out << "Has Detail Texture:  " << hasDetailTexture << endl; \
-if ( (hasDetailTexture != 0) ) { \
-	out << "  Source:  " << detailTexture.source << endl; \
-	out << "  Clamp Mode:  " << detailTexture.clampMode << endl; \
-	out << "  Filter Mode:  " << detailTexture.filterMode << endl; \
-	out << "  Texture Set:  " << detailTexture.textureSet << endl; \
-	out << "  PS2 L:  " << detailTexture.ps2L << endl; \
-	out << "  PS2 K:  " << detailTexture.ps2K << endl; \
-	out << "  Unknown1:  " << detailTexture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << detailTexture.hasTextureTransform << endl; \
-	if ( (detailTexture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << detailTexture.translation << endl; \
-		out << "    Tiling:  " << detailTexture.tiling << endl; \
-		out << "    W Rotation:  " << detailTexture.wRotation << endl; \
-		out << "    Transform Type?:  " << detailTexture.transformType_ << endl; \
-		out << "    Center Offset:  " << detailTexture.centerOffset << endl; \
-	}; \
-}; \
-out << "Has Gloss Texture:  " << hasGlossTexture << endl; \
-if ( (hasGlossTexture != 0) ) { \
-	out << "  Source:  " << glossTexture.source << endl; \
-	out << "  Clamp Mode:  " << glossTexture.clampMode << endl; \
-	out << "  Filter Mode:  " << glossTexture.filterMode << endl; \
-	out << "  Texture Set:  " << glossTexture.textureSet << endl; \
-	out << "  PS2 L:  " << glossTexture.ps2L << endl; \
-	out << "  PS2 K:  " << glossTexture.ps2K << endl; \
-	out << "  Unknown1:  " << glossTexture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << glossTexture.hasTextureTransform << endl; \
-	if ( (glossTexture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << glossTexture.translation << endl; \
-		out << "    Tiling:  " << glossTexture.tiling << endl; \
-		out << "    W Rotation:  " << glossTexture.wRotation << endl; \
-		out << "    Transform Type?:  " << glossTexture.transformType_ << endl; \
-		out << "    Center Offset:  " << glossTexture.centerOffset << endl; \
-	}; \
-}; \
-out << "Has Glow Texture:  " << hasGlowTexture << endl; \
-if ( (hasGlowTexture != 0) ) { \
-	out << "  Source:  " << glowTexture.source << endl; \
-	out << "  Clamp Mode:  " << glowTexture.clampMode << endl; \
-	out << "  Filter Mode:  " << glowTexture.filterMode << endl; \
-	out << "  Texture Set:  " << glowTexture.textureSet << endl; \
-	out << "  PS2 L:  " << glowTexture.ps2L << endl; \
-	out << "  PS2 K:  " << glowTexture.ps2K << endl; \
-	out << "  Unknown1:  " << glowTexture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << glowTexture.hasTextureTransform << endl; \
-	if ( (glowTexture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << glowTexture.translation << endl; \
-		out << "    Tiling:  " << glowTexture.tiling << endl; \
-		out << "    W Rotation:  " << glowTexture.wRotation << endl; \
-		out << "    Transform Type?:  " << glowTexture.transformType_ << endl; \
-		out << "    Center Offset:  " << glowTexture.centerOffset << endl; \
-	}; \
-}; \
-out << "Has Bump Map Texture:  " << hasBumpMapTexture << endl; \
-if ( (hasBumpMapTexture != 0) ) { \
-	out << "  Source:  " << bumpMapTexture.source << endl; \
-	out << "  Clamp Mode:  " << bumpMapTexture.clampMode << endl; \
-	out << "  Filter Mode:  " << bumpMapTexture.filterMode << endl; \
-	out << "  Texture Set:  " << bumpMapTexture.textureSet << endl; \
-	out << "  PS2 L:  " << bumpMapTexture.ps2L << endl; \
-	out << "  PS2 K:  " << bumpMapTexture.ps2K << endl; \
-	out << "  Unknown1:  " << bumpMapTexture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << bumpMapTexture.hasTextureTransform << endl; \
-	if ( (bumpMapTexture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << bumpMapTexture.translation << endl; \
-		out << "    Tiling:  " << bumpMapTexture.tiling << endl; \
-		out << "    W Rotation:  " << bumpMapTexture.wRotation << endl; \
-		out << "    Transform Type?:  " << bumpMapTexture.transformType_ << endl; \
-		out << "    Center Offset:  " << bumpMapTexture.centerOffset << endl; \
-	}; \
-	out << "  Bump Map Luma Scale:  " << bumpMapLumaScale << endl; \
-	out << "  Bump Map Luma Offset:  " << bumpMapLumaOffset << endl; \
-	out << "  Bump Map Matrix:  " << bumpMapMatrix << endl; \
-}; \
-out << "Has Decal 0 Texture:  " << hasDecal0Texture << endl; \
-if ( (hasDecal0Texture != 0) ) { \
-	out << "  Source:  " << decal0Texture.source << endl; \
-	out << "  Clamp Mode:  " << decal0Texture.clampMode << endl; \
-	out << "  Filter Mode:  " << decal0Texture.filterMode << endl; \
-	out << "  Texture Set:  " << decal0Texture.textureSet << endl; \
-	out << "  PS2 L:  " << decal0Texture.ps2L << endl; \
-	out << "  PS2 K:  " << decal0Texture.ps2K << endl; \
-	out << "  Unknown1:  " << decal0Texture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << decal0Texture.hasTextureTransform << endl; \
-	if ( (decal0Texture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << decal0Texture.translation << endl; \
-		out << "    Tiling:  " << decal0Texture.tiling << endl; \
-		out << "    W Rotation:  " << decal0Texture.wRotation << endl; \
-		out << "    Transform Type?:  " << decal0Texture.transformType_ << endl; \
-		out << "    Center Offset:  " << decal0Texture.centerOffset << endl; \
-	}; \
-}; \
-if ( (textureCount == 8) ) { \
-	out << "  Has Decal 1 Texture:  " << hasDecal1Texture << endl; \
-}; \
-if ( (((textureCount == 8)) && ((hasDecal1Texture != 0))) ) { \
-	out << "  Source:  " << decal1Texture.source << endl; \
-	out << "  Clamp Mode:  " << decal1Texture.clampMode << endl; \
-	out << "  Filter Mode:  " << decal1Texture.filterMode << endl; \
-	out << "  Texture Set:  " << decal1Texture.textureSet << endl; \
-	out << "  PS2 L:  " << decal1Texture.ps2L << endl; \
-	out << "  PS2 K:  " << decal1Texture.ps2K << endl; \
-	out << "  Unknown1:  " << decal1Texture.unknown1 << endl; \
-	out << "  Has Texture Transform:  " << decal1Texture.hasTextureTransform << endl; \
-	if ( (decal1Texture.hasTextureTransform != 0) ) { \
-		out << "    Translation:  " << decal1Texture.translation << endl; \
-		out << "    Tiling:  " << decal1Texture.tiling << endl; \
-		out << "    W Rotation:  " << decal1Texture.wRotation << endl; \
-		out << "    Transform Type?:  " << decal1Texture.transformType_ << endl; \
-		out << "    Center Offset:  " << decal1Texture.centerOffset << endl; \
-	}; \
-}; \
-out << "Num Shader Textures:  " << numShaderTextures << endl; \
-for (uint i0 = 0; i0 < shaderTextures.size(); i0++) { \
-	out << "  Is Used:  " << shaderTextures[i0].isUsed << endl; \
-	if ( (shaderTextures[i0].isUsed != 0) ) { \
-		out << "    Source:  " << shaderTextures[i0].textureData.source << endl; \
-		out << "    Clamp Mode:  " << shaderTextures[i0].textureData.clampMode << endl; \
-		out << "    Filter Mode:  " << shaderTextures[i0].textureData.filterMode << endl; \
-		out << "    Texture Set:  " << shaderTextures[i0].textureData.textureSet << endl; \
-		out << "    PS2 L:  " << shaderTextures[i0].textureData.ps2L << endl; \
-		out << "    PS2 K:  " << shaderTextures[i0].textureData.ps2K << endl; \
-		out << "    Unknown1:  " << shaderTextures[i0].textureData.unknown1 << endl; \
-		out << "    Has Texture Transform:  " << shaderTextures[i0].textureData.hasTextureTransform << endl; \
-		if ( (shaderTextures[i0].textureData.hasTextureTransform != 0) ) { \
-			out << "      Translation:  " << shaderTextures[i0].textureData.translation << endl; \
-			out << "      Tiling:  " << shaderTextures[i0].textureData.tiling << endl; \
-			out << "      W Rotation:  " << shaderTextures[i0].textureData.wRotation << endl; \
-			out << "      Transform Type?:  " << shaderTextures[i0].textureData.transformType_ << endl; \
-			out << "      Center Offset:  " << shaderTextures[i0].textureData.centerOffset << endl; \
-		}; \
-		out << "    Unknown Int:  " << shaderTextures[i0].unknownInt << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TEXTURING_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
-if ( (hasBaseTexture != 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		baseTexture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( baseTexture.source == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		baseTexture.source = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( (hasDarkTexture != 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		darkTexture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( darkTexture.source == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		darkTexture.source = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( (hasDetailTexture != 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		detailTexture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( detailTexture.source == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		detailTexture.source = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( (hasGlossTexture != 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		glossTexture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( glossTexture.source == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		glossTexture.source = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( (hasGlowTexture != 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		glowTexture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( glowTexture.source == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		glowTexture.source = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( (hasBumpMapTexture != 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		bumpMapTexture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( bumpMapTexture.source == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		bumpMapTexture.source = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( (hasDecal0Texture != 0) ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		decal0Texture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-		if ( decal0Texture.source == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		decal0Texture.source = NULL; \
-	link_stack.pop_front(); \
-}; \
-if ( version >= 0x14000004 ) { \
-	if ( (((textureCount == 8)) && ((hasDecal1Texture != 0))) ) { \
-		if (link_stack.empty()) \
-			throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-		if (link_stack.front() != 0xffffffff) { \
-			decal1Texture.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-			if ( decal1Texture.source == NULL ) \
-				throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-		} else \
-			decal1Texture.source = NULL; \
-		link_stack.pop_front(); \
-	}; \
-}; \
-if ( version >= 0x0A000100 ) { \
-	for (uint i1 = 0; i1 < shaderTextures.size(); i1++) { \
-		if ( (shaderTextures[i1].isUsed != 0) ) { \
-			if (link_stack.empty()) \
-				throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-			if (link_stack.front() != 0xffffffff) { \
-				shaderTextures[i1].textureData.source = DynamicCast<NiSourceTexture>(objects[link_stack.front()]); \
-				if ( shaderTextures[i1].textureData.source == NULL ) \
-					throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-			} else \
-				shaderTextures[i1].textureData.source = NULL; \
-			link_stack.pop_front(); \
-		}; \
-	}; \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TEXTURING_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-if ( baseTexture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(baseTexture.source)); \
-if ( darkTexture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(darkTexture.source)); \
-if ( detailTexture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(detailTexture.source)); \
-if ( glossTexture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(glossTexture.source)); \
-if ( glowTexture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(glowTexture.source)); \
-if ( bumpMapTexture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(bumpMapTexture.source)); \
-if ( decal0Texture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(decal0Texture.source)); \
-if ( decal1Texture.source != NULL ) \
-	refs.push_back(StaticCast<NiObject>(decal1Texture.source)); \
-for (uint i0 = 0; i0 < shaderTextures.size(); i0++) { \
-	if ( shaderTextures[i0].textureData.source != NULL ) \
-		refs.push_back(StaticCast<NiObject>(shaderTextures[i0].textureData.source)); \
-}; \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRANSFORM_CONTROLLER_MEMBERS \
 
@@ -13649,23 +5388,19 @@ return refs; \
 #define NI_TRANSFORM_CONTROLLER_CONSTRUCT \
 
 #define NI_TRANSFORM_CONTROLLER_READ \
-NiSingleInterpolatorController::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRANSFORM_CONTROLLER_WRITE \
-NiSingleInterpolatorController::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRANSFORM_CONTROLLER_STRING \
-stringstream out; \
-out << NiSingleInterpolatorController::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRANSFORM_CONTROLLER_FIXLINKS \
-NiSingleInterpolatorController::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRANSFORM_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiSingleInterpolatorController::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRANSFORM_DATA_MEMBERS \
 
@@ -13676,29 +5411,25 @@ return refs; \
 #define NI_TRANSFORM_DATA_CONSTRUCT \
 
 #define NI_TRANSFORM_DATA_READ \
-NiKeyframeData::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRANSFORM_DATA_WRITE \
-NiKeyframeData::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRANSFORM_DATA_STRING \
-stringstream out; \
-out << NiKeyframeData::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRANSFORM_DATA_FIXLINKS \
-NiKeyframeData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRANSFORM_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiKeyframeData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRANSFORM_INTERPOLATOR_MEMBERS \
 Vector3 translation; \
 Quaternion rotation; \
 float scale; \
-byte unknownBytes[3]; \
+array<byte,3> unknownBytes; \
 Ref<NiTransformData > data; \
 
 #define NI_TRANSFORM_INTERPOLATOR_INCLUDE "NiInterpolator.h" \
@@ -13709,68 +5440,19 @@ Ref<NiTransformData > data; \
  : scale(0.0f), data(NULL) \
 
 #define NI_TRANSFORM_INTERPOLATOR_READ \
-uint block_num; \
-NiInterpolator::Read( in, link_stack, version, user_version ); \
-NifStream( translation, in, version ); \
-NifStream( rotation, in, version ); \
-NifStream( scale, in, version ); \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		NifStream( unknownBytes[i1], in, version ); \
-	}; \
-}; \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRANSFORM_INTERPOLATOR_WRITE \
-NiInterpolator::Write( out, link_map, version, user_version ); \
-NifStream( translation, out, version ); \
-NifStream( rotation, out, version ); \
-NifStream( scale, out, version ); \
-if ( ( version >= 0x0A01006A ) && ( version <= 0x0A01006A ) ) { \
-	for (uint i1 = 0; i1 < 3; i1++) { \
-		NifStream( unknownBytes[i1], out, version ); \
-	}; \
-}; \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRANSFORM_INTERPOLATOR_STRING \
-stringstream out; \
-out << NiInterpolator::asString(); \
-out << "Translation:  " << translation << endl; \
-out << "Rotation:  " << rotation << endl; \
-out << "Scale:  " << scale << endl; \
-for (uint i0 = 0; i0 < 3; i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Unknown Bytes[" << i0 << "]:  " << unknownBytes[i0] << endl; \
-}; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRANSFORM_INTERPOLATOR_FIXLINKS \
-NiInterpolator::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiTransformData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRANSFORM_INTERPOLATOR_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiInterpolator::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRI_SHAPE_MEMBERS \
 
@@ -13781,30 +5463,26 @@ return refs; \
 #define NI_TRI_SHAPE_CONSTRUCT \
 
 #define NI_TRI_SHAPE_READ \
-NiTriBasedGeom::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRI_SHAPE_WRITE \
-NiTriBasedGeom::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRI_SHAPE_STRING \
-stringstream out; \
-out << NiTriBasedGeom::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRI_SHAPE_FIXLINKS \
-NiTriBasedGeom::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRI_SHAPE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTriBasedGeom::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRI_SHAPE_DATA_MEMBERS \
-ushort numTriangles; \
+mutable ushort numTriangles; \
 uint numTrianglePoints; \
 bool hasTriangles; \
 vector<Triangle > triangles; \
-ushort numMatchGroups; \
+mutable ushort numMatchGroups; \
 vector<MatchGroup > matchGroups; \
 
 #define NI_TRI_SHAPE_DATA_INCLUDE "NiTriBasedGeomData.h" \
@@ -13815,96 +5493,19 @@ vector<MatchGroup > matchGroups; \
  : numTriangles((ushort)0), numTrianglePoints((uint)0), hasTriangles(false), numMatchGroups((ushort)0) \
 
 #define NI_TRI_SHAPE_DATA_READ \
-NiTriBasedGeomData::Read( in, link_stack, version, user_version ); \
-NifStream( numTriangles, in, version ); \
-NifStream( numTrianglePoints, in, version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( hasTriangles, in, version ); \
-}; \
-if ( version <= 0x0A000102 ) { \
-	triangles.resize(numTriangles); \
-	for (uint i1 = 0; i1 < triangles.size(); i1++) { \
-		NifStream( triangles[i1], in, version ); \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (hasTriangles != 0) ) { \
-		triangles.resize(numTriangles); \
-		for (uint i2 = 0; i2 < triangles.size(); i2++) { \
-			NifStream( triangles[i2], in, version ); \
-		}; \
-	}; \
-}; \
-NifStream( numMatchGroups, in, version ); \
-matchGroups.resize(numMatchGroups); \
-for (uint i0 = 0; i0 < matchGroups.size(); i0++) { \
-	NifStream( matchGroups[i0].numVertices, in, version ); \
-	matchGroups[i0].vertexIndices.resize(matchGroups[i0].numVertices); \
-	for (uint i1 = 0; i1 < matchGroups[i0].vertexIndices.size(); i1++) { \
-		NifStream( matchGroups[i0].vertexIndices[i1], in, version ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRI_SHAPE_DATA_WRITE \
-NiTriBasedGeomData::Write( out, link_map, version, user_version ); \
-NifStream( numTriangles, out, version ); \
-NifStream( numTrianglePoints, out, version ); \
-if ( version >= 0x0A010000 ) { \
-	NifStream( hasTriangles, out, version ); \
-}; \
-if ( version <= 0x0A000102 ) { \
-	for (uint i1 = 0; i1 < triangles.size(); i1++) { \
-		NifStream( triangles[i1], out, version ); \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (hasTriangles != 0) ) { \
-		for (uint i2 = 0; i2 < triangles.size(); i2++) { \
-			NifStream( triangles[i2], out, version ); \
-		}; \
-	}; \
-}; \
-NifStream( numMatchGroups, out, version ); \
-for (uint i0 = 0; i0 < matchGroups.size(); i0++) { \
-	NifStream( matchGroups[i0].numVertices, out, version ); \
-	for (uint i1 = 0; i1 < matchGroups[i0].vertexIndices.size(); i1++) { \
-		NifStream( matchGroups[i0].vertexIndices[i1], out, version ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRI_SHAPE_DATA_STRING \
-stringstream out; \
-out << NiTriBasedGeomData::asString(); \
-out << "Num Triangles:  " << numTriangles << endl; \
-out << "Num Triangle Points:  " << numTrianglePoints << endl; \
-out << "Has Triangles:  " << hasTriangles << endl; \
-for (uint i0 = 0; i0 < triangles.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Triangles[" << i0 << "]:  " << triangles[i0] << endl; \
-}; \
-out << "Num Match Groups:  " << numMatchGroups << endl; \
-for (uint i0 = 0; i0 < matchGroups.size(); i0++) { \
-	out << "  Num Vertices:  " << matchGroups[i0].numVertices << endl; \
-	for (uint i1 = 0; i1 < matchGroups[i0].vertexIndices.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Vertex Indices[" << i1 << "]:  " << matchGroups[i0].vertexIndices[i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRI_SHAPE_DATA_FIXLINKS \
-NiTriBasedGeomData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRI_SHAPE_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTriBasedGeomData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRI_STRIPS_MEMBERS \
 
@@ -13915,28 +5516,24 @@ return refs; \
 #define NI_TRI_STRIPS_CONSTRUCT \
 
 #define NI_TRI_STRIPS_READ \
-NiTriBasedGeom::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRI_STRIPS_WRITE \
-NiTriBasedGeom::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRI_STRIPS_STRING \
-stringstream out; \
-out << NiTriBasedGeom::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRI_STRIPS_FIXLINKS \
-NiTriBasedGeom::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRI_STRIPS_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTriBasedGeom::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_TRI_STRIPS_DATA_MEMBERS \
 ushort numTriangles; \
-ushort numStrips; \
-vector<ushort > stripLengths; \
+mutable ushort numStrips; \
+mutable vector<ushort > stripLengths; \
 bool hasPoints; \
 vector<vector<ushort > > points; \
 
@@ -13948,95 +5545,19 @@ vector<vector<ushort > > points; \
  : numTriangles((ushort)0), numStrips((ushort)0), hasPoints(false) \
 
 #define NI_TRI_STRIPS_DATA_READ \
-NiTriBasedGeomData::Read( in, link_stack, version, user_version ); \
-NifStream( numTriangles, in, version ); \
-NifStream( numStrips, in, version ); \
-stripLengths.resize(numStrips); \
-for (uint i0 = 0; i0 < stripLengths.size(); i0++) { \
-	NifStream( stripLengths[i0], in, version ); \
-}; \
-if ( version >= 0x0A010000 ) { \
-	NifStream( hasPoints, in, version ); \
-}; \
-if ( version <= 0x0A000102 ) { \
-	points.resize(numStrips); \
-	for (uint i1 = 0; i1 < points.size(); i1++) { \
-		points[i1].resize(stripLengths[i1]); \
-		for (uint i2 = 0; i2 < stripLengths[i1]; i2++) { \
-			NifStream( points[i1][i2], in, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (hasPoints != 0) ) { \
-		points.resize(numStrips); \
-		for (uint i2 = 0; i2 < points.size(); i2++) { \
-			points[i2].resize(stripLengths[i2]); \
-			for (uint i3 = 0; i3 < stripLengths[i2]; i3++) { \
-				NifStream( points[i2][i3], in, version ); \
-			}; \
-		}; \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_TRI_STRIPS_DATA_WRITE \
-NiTriBasedGeomData::Write( out, link_map, version, user_version ); \
-NifStream( numTriangles, out, version ); \
-NifStream( numStrips, out, version ); \
-for (uint i0 = 0; i0 < stripLengths.size(); i0++) { \
-	NifStream( stripLengths[i0], out, version ); \
-}; \
-if ( version >= 0x0A010000 ) { \
-	NifStream( hasPoints, out, version ); \
-}; \
-if ( version <= 0x0A000102 ) { \
-	for (uint i1 = 0; i1 < points.size(); i1++) { \
-		for (uint i2 = 0; i2 < stripLengths[i1]; i2++) { \
-			NifStream( points[i1][i2], out, version ); \
-		}; \
-	}; \
-}; \
-if ( version >= 0x0A010000 ) { \
-	if ( (hasPoints != 0) ) { \
-		for (uint i2 = 0; i2 < points.size(); i2++) { \
-			for (uint i3 = 0; i3 < stripLengths[i2]; i3++) { \
-				NifStream( points[i2][i3], out, version ); \
-			}; \
-		}; \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_TRI_STRIPS_DATA_STRING \
-stringstream out; \
-out << NiTriBasedGeomData::asString(); \
-out << "Num Triangles:  " << numTriangles << endl; \
-out << "Num Strips:  " << numStrips << endl; \
-for (uint i0 = 0; i0 < stripLengths.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Strip Lengths[" << i0 << "]:  " << stripLengths[i0] << endl; \
-}; \
-out << "Has Points:  " << hasPoints << endl; \
-for (uint i0 = 0; i0 < points.size(); i0++) { \
-	for (uint i1 = 0; i1 < stripLengths[i0]; i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Points[" << i0 << "][" << i1 << "]:  " << points[i0][i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_TRI_STRIPS_DATA_FIXLINKS \
-NiTriBasedGeomData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_TRI_STRIPS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTriBasedGeomData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_U_V_CONTROLLER_MEMBERS \
 ushort unknownShort; \
@@ -14050,48 +5571,22 @@ Ref<NiUVData > data; \
  : unknownShort((ushort)0), data(NULL) \
 
 #define NI_U_V_CONTROLLER_READ \
-uint block_num; \
-NiTimeController::Read( in, link_stack, version, user_version ); \
-NifStream( unknownShort, in, version ); \
-NifStream( block_num, in, version ); \
-link_stack.push_back( block_num ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_U_V_CONTROLLER_WRITE \
-NiTimeController::Write( out, link_map, version, user_version ); \
-NifStream( unknownShort, out, version ); \
-if ( data != NULL ) \
-	NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-else \
-	NifStream( 0xffffffff, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_U_V_CONTROLLER_STRING \
-stringstream out; \
-out << NiTimeController::asString(); \
-out << "Unknown Short:  " << unknownShort << endl; \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_U_V_CONTROLLER_FIXLINKS \
-NiTimeController::FixLinks( objects, link_stack, version, user_version ); \
-if (link_stack.empty()) \
-	throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-if (link_stack.front() != 0xffffffff) { \
-	data = DynamicCast<NiUVData>(objects[link_stack.front()]); \
-	if ( data == NULL ) \
-		throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-} else \
-	data = NULL; \
-link_stack.pop_front(); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_U_V_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiTimeController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_U_V_DATA_MEMBERS \
-KeyGroup<float > uvGroups[4]; \
+array<KeyGroup<float >,4> uvGroups; \
 
 #define NI_U_V_DATA_INCLUDE "NiObject.h" \
 
@@ -14100,55 +5595,19 @@ KeyGroup<float > uvGroups[4]; \
 #define NI_U_V_DATA_CONSTRUCT \
 
 #define NI_U_V_DATA_READ \
-NiObject::Read( in, link_stack, version, user_version ); \
-for (uint i0 = 0; i0 < 4; i0++) { \
-	NifStream( uvGroups[i0].numKeys, in, version ); \
-	if ( (uvGroups[i0].numKeys != 0) ) { \
-		NifStream( uvGroups[i0].interpolation, in, version ); \
-	}; \
-	uvGroups[i0].keys.resize(uvGroups[i0].numKeys); \
-	for (uint i1 = 0; i1 < uvGroups[i0].keys.size(); i1++) { \
-		NifStream( uvGroups[i0].keys[i1], in, version, uvGroups[i0].interpolation ); \
-	}; \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_U_V_DATA_WRITE \
-NiObject::Write( out, link_map, version, user_version ); \
-for (uint i0 = 0; i0 < 4; i0++) { \
-	NifStream( uvGroups[i0].numKeys, out, version ); \
-	if ( (uvGroups[i0].numKeys != 0) ) { \
-		NifStream( uvGroups[i0].interpolation, out, version ); \
-	}; \
-	for (uint i1 = 0; i1 < uvGroups[i0].keys.size(); i1++) { \
-		NifStream( uvGroups[i0].keys[i1], out, version, uvGroups[i0].interpolation ); \
-	}; \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_U_V_DATA_STRING \
-stringstream out; \
-out << NiObject::asString(); \
-for (uint i0 = 0; i0 < 4; i0++) { \
-	out << "  Num Keys:  " << uvGroups[i0].numKeys << endl; \
-	if ( (uvGroups[i0].numKeys != 0) ) { \
-		out << "    Interpolation:  " << uvGroups[i0].interpolation << endl; \
-	}; \
-	for (uint i1 = 0; i1 < uvGroups[i0].keys.size(); i1++) { \
-		if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { \
-			out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-			break; \
-		}; \
-		out << "    Keys[" << i1 << "]:  " << uvGroups[i0].keys[i1] << endl; \
-	}; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_U_V_DATA_FIXLINKS \
-NiObject::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_U_V_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiObject::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_VECTOR_EXTRA_DATA_MEMBERS \
 Vector3 vectorData; \
@@ -14162,29 +5621,19 @@ float unknownFloat; \
  : unknownFloat(0.0f) \
 
 #define NI_VECTOR_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( vectorData, in, version ); \
-NifStream( unknownFloat, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_VECTOR_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( vectorData, out, version ); \
-NifStream( unknownFloat, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_VECTOR_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Vector Data:  " << vectorData << endl; \
-out << "Unknown Float:  " << unknownFloat << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_VECTOR_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_VECTOR_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_VERTEX_COLOR_PROPERTY_MEMBERS \
 ushort flags; \
@@ -14199,36 +5648,23 @@ LightMode lightingMode; \
  : flags((ushort)0), vertexMode((VertMode)0), lightingMode((LightMode)0) \
 
 #define NI_VERTEX_COLOR_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
-NifStream( vertexMode, in, version ); \
-NifStream( lightingMode, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_VERTEX_COLOR_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
-NifStream( vertexMode, out, version ); \
-NifStream( lightingMode, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_VERTEX_COLOR_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Vertex Mode:  " << vertexMode << endl; \
-out << "Lighting Mode:  " << lightingMode << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_VERTEX_COLOR_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_VERTEX_COLOR_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_VERT_WEIGHTS_EXTRA_DATA_MEMBERS \
 uint numBytes; \
-ushort numVertices; \
+mutable ushort numVertices; \
 vector<float > weight; \
 
 #define NI_VERT_WEIGHTS_EXTRA_DATA_INCLUDE "NiExtraData.h" \
@@ -14239,43 +5675,19 @@ vector<float > weight; \
  : numBytes((uint)0), numVertices((ushort)0) \
 
 #define NI_VERT_WEIGHTS_EXTRA_DATA_READ \
-NiExtraData::Read( in, link_stack, version, user_version ); \
-NifStream( numBytes, in, version ); \
-NifStream( numVertices, in, version ); \
-weight.resize(numVertices); \
-for (uint i0 = 0; i0 < weight.size(); i0++) { \
-	NifStream( weight[i0], in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_VERT_WEIGHTS_EXTRA_DATA_WRITE \
-NiExtraData::Write( out, link_map, version, user_version ); \
-NifStream( numBytes, out, version ); \
-NifStream( numVertices, out, version ); \
-for (uint i0 = 0; i0 < weight.size(); i0++) { \
-	NifStream( weight[i0], out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_VERT_WEIGHTS_EXTRA_DATA_STRING \
-stringstream out; \
-out << NiExtraData::asString(); \
-out << "Num Bytes:  " << numBytes << endl; \
-out << "Num Vertices:  " << numVertices << endl; \
-for (uint i0 = 0; i0 < weight.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Weight[" << i0 << "]:  " << weight[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_VERT_WEIGHTS_EXTRA_DATA_FIXLINKS \
-NiExtraData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_VERT_WEIGHTS_EXTRA_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiExtraData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_VIS_CONTROLLER_MEMBERS \
 Ref<NiVisData > data; \
@@ -14288,51 +5700,22 @@ Ref<NiVisData > data; \
  : data(NULL) \
 
 #define NI_VIS_CONTROLLER_READ \
-uint block_num; \
-NiSingleInterpolatorController::Read( in, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	NifStream( block_num, in, version ); \
-	link_stack.push_back( block_num ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_VIS_CONTROLLER_WRITE \
-NiSingleInterpolatorController::Write( out, link_map, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if ( data != NULL ) \
-		NifStream( link_map[StaticCast<NiObject>(data)], out, version ); \
-	else \
-		NifStream( 0xffffffff, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_VIS_CONTROLLER_STRING \
-stringstream out; \
-out << NiSingleInterpolatorController::asString(); \
-out << "Data:  " << data << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_VIS_CONTROLLER_FIXLINKS \
-NiSingleInterpolatorController::FixLinks( objects, link_stack, version, user_version ); \
-if ( version <= 0x0A010000 ) { \
-	if (link_stack.empty()) \
-		throw runtime_error("Trying to pop a link from empty stack. This is probably a bug."); \
-	if (link_stack.front() != 0xffffffff) { \
-		data = DynamicCast<NiVisData>(objects[link_stack.front()]); \
-		if ( data == NULL ) \
-			throw runtime_error("Link could not be cast to required type during file read. This NIF file may be invalid or improperly understood."); \
-	} else \
-		data = NULL; \
-	link_stack.pop_front(); \
-}; \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_VIS_CONTROLLER_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiSingleInterpolatorController::GetRefs(); \
-if ( data != NULL ) \
-	refs.push_back(StaticCast<NiObject>(data)); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_VIS_DATA_MEMBERS \
-uint numVisKeys; \
+mutable uint numVisKeys; \
 vector<Key<byte > > visKeys; \
 
 #define NI_VIS_DATA_INCLUDE "AKeyedData.h" \
@@ -14343,40 +5726,19 @@ vector<Key<byte > > visKeys; \
  : numVisKeys((uint)0) \
 
 #define NI_VIS_DATA_READ \
-AKeyedData::Read( in, link_stack, version, user_version ); \
-NifStream( numVisKeys, in, version ); \
-visKeys.resize(numVisKeys); \
-for (uint i0 = 0; i0 < visKeys.size(); i0++) { \
-	NifStream( visKeys[i0], in, version, 1 ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_VIS_DATA_WRITE \
-AKeyedData::Write( out, link_map, version, user_version ); \
-NifStream( numVisKeys, out, version ); \
-for (uint i0 = 0; i0 < visKeys.size(); i0++) { \
-	NifStream( visKeys[i0], out, version, 1 ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_VIS_DATA_STRING \
-stringstream out; \
-out << AKeyedData::asString(); \
-out << "Num Vis Keys:  " << numVisKeys << endl; \
-for (uint i0 = 0; i0 < visKeys.size(); i0++) { \
-	if ( !verbose && ( i0 > MAXARRAYDUMP ) ) { \
-		out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; \
-		break; \
-	}; \
-	out << "  Vis Keys[" << i0 << "]:  " << visKeys[i0] << endl; \
-}; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_VIS_DATA_FIXLINKS \
-AKeyedData::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_VIS_DATA_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = AKeyedData::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_WIREFRAME_PROPERTY_MEMBERS \
 ushort flags; \
@@ -14389,26 +5751,19 @@ ushort flags; \
  : flags((ushort)0) \
 
 #define NI_WIREFRAME_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_WIREFRAME_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_WIREFRAME_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_WIREFRAME_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_WIREFRAME_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define NI_Z_BUFFER_PROPERTY_MEMBERS \
 ushort flags; \
@@ -14422,33 +5777,19 @@ uint function; \
  : flags((ushort)3), function((uint)3) \
 
 #define NI_Z_BUFFER_PROPERTY_READ \
-NiProperty::Read( in, link_stack, version, user_version ); \
-NifStream( flags, in, version ); \
-if ( version >= 0x0401000C ) { \
-	NifStream( function, in, version ); \
-}; \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define NI_Z_BUFFER_PROPERTY_WRITE \
-NiProperty::Write( out, link_map, version, user_version ); \
-NifStream( flags, out, version ); \
-if ( version >= 0x0401000C ) { \
-	NifStream( function, out, version ); \
-}; \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define NI_Z_BUFFER_PROPERTY_STRING \
-stringstream out; \
-out << NiProperty::asString(); \
-out << "Flags:  " << flags << endl; \
-out << "Function:  " << function << endl; \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define NI_Z_BUFFER_PROPERTY_FIXLINKS \
-NiProperty::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define NI_Z_BUFFER_PROPERTY_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiProperty::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #define ROOT_COLLISION_NODE_MEMBERS \
 
@@ -14459,22 +5800,18 @@ return refs; \
 #define ROOT_COLLISION_NODE_CONSTRUCT \
 
 #define ROOT_COLLISION_NODE_READ \
-NiNode::Read( in, link_stack, version, user_version ); \
+InternalRead( in, link_stack, version, user_version ); \
 
 #define ROOT_COLLISION_NODE_WRITE \
-NiNode::Write( out, link_map, version, user_version ); \
+InternalWrite( out, link_map, version, user_version ); \
 
 #define ROOT_COLLISION_NODE_STRING \
-stringstream out; \
-out << NiNode::asString(); \
-return out.str(); \
+return InternalAsString( verbose ); \
 
 #define ROOT_COLLISION_NODE_FIXLINKS \
-NiNode::FixLinks( objects, link_stack, version, user_version ); \
+InternalFixLinks( objects, link_stack, version, user_version ); \
 
 #define ROOT_COLLISION_NODE_GETREFS \
-list<Ref<NiObject> > refs; \
-refs = NiNode::GetRefs(); \
-return refs; \
+return InternalGetRefs(); \
 
 #endif
diff --git a/gen/obj_factories.cpp b/gen/obj_factories.cpp
index 91046aa48d4a115a0496b5b842850fce664edf2c..f36112c6c305187c8974ec71a00e8d435d9fafbd 100644
--- a/gen/obj_factories.cpp
+++ b/gen/obj_factories.cpp
@@ -2,8 +2,12 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "../obj/NiObject.h"
+using namespace NifLib;
+using namespace std;
+namespace NifLib {
 typedef NiObject*(*blk_factory_func)();
 extern map<string, blk_factory_func> global_block_map;
+}
 
 #include "../obj/bhkBlendCollisionObject.h"
 NiObject * CreatebhkBlendCollisionObject() { return new bhkBlendCollisionObject; }
@@ -366,6 +370,7 @@ NiObject * CreateNiZBufferProperty() { return new NiZBufferProperty; }
 #include "../obj/RootCollisionNode.h"
 NiObject * CreateRootCollisionNode() { return new RootCollisionNode; }
 
+namespace NifLib {
 //This function registers the factory functions with global_block_map which is used by CreateBlock
 void RegisterBlockFactories() {
 	global_block_map["bhkBlendCollisionObject"] = CreatebhkBlendCollisionObject;
@@ -549,3 +554,4 @@ void RegisterBlockFactories() {
 	global_block_map["NiZBufferProperty"] = CreateNiZBufferProperty;
 	global_block_map["RootCollisionNode"] = CreateRootCollisionNode;
 }
+}
diff --git a/nif_math.cpp b/nif_math.cpp
index 877a9c82618b4e2491a91d381e0bdb35ed0f35af..592991d2591e49a02e2f14ec8646fcaf478e6ee2 100644
--- a/nif_math.cpp
+++ b/nif_math.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "nif_math.h"
 #include <iomanip>
+using namespace NifLib;
 
 //Constants
 
@@ -188,7 +189,16 @@ float Matrix33::Determinant() const {
 		  + (*this)[0][2] * ( (*this)[1][0] * (*this)[2][1] - (*this)[1][1] * (*this)[2][0] );
 }
 
-
+Matrix33 Matrix33::operator*( const Matrix33 & m ) const
+{
+   Matrix33 m3;
+   for ( int r = 0; r < 3; r++ ){
+      for ( int c = 0; c < 3; c++ ){
+         m3[r][c] = (*this)[r][0]*m[0][c] + (*this)[r][1]*m[1][c] + (*this)[r][2]*m[2][c];
+      }
+   }
+   return m3;
+}
 
 /*
  * Matrix44 Methods
@@ -383,6 +393,23 @@ float Matrix44::Determinant() const {
 	      - t[0][3] * Submatrix(0, 3).Determinant();
 }
 
+void Matrix44::Decompose( Vector3 & translate, Matrix33 & rotation, Float3 & scale ) const {
+   translate = Vector3( (*this)[3][0], (*this)[3][1], (*this)[3][2] );
+   Matrix33 rotT;
+   for ( int i = 0; i < 3; i++ ){
+      for ( int j = 0; j < 3; j++ ){
+         rotation[j][i] = (*this)[i][j];
+         rotT[i][j] = (*this)[i][j];
+      }
+   }
+   Matrix33 mtx = rotation * rotT;
+   scale = Float3( sqrt(mtx[0][0]), sqrt(mtx[1][1]), sqrt(mtx[2][2]) );
+   for ( int i = 0; i < 3; i++ ){
+      for ( int j = 0; j < 3; j++ ){
+         rotation[i][j] /= scale[i];
+      }
+   }
+}
 /*
  * Quaternion Methods
  */
@@ -448,7 +475,7 @@ Matrix33 Quaternion::AsMatrix() {
 /*
  * ostream functions for printing with cout
  */
-
+namespace NifLib {
 ostream & operator<<( ostream & out, TexCoord const & val ) {
 	return out << "(" << setw(6) << val.u << "," << setw(6) << val.v << ")";
 }
@@ -508,3 +535,4 @@ ostream & operator<<( ostream & out, Color4 const & val ) {
 ostream & operator<<( ostream & out, Quaternion const & val ) {
 	return out << "[" << setw(6) << val.w << ",(" << setw(6) << val.x << "," << setw(6) << val.y << "," << setw(6) << val.z << ")]";
 }
+}
diff --git a/nif_math.h b/nif_math.h
index 890ffced714b802fbe02049b283c2b0e5720e842..162d803930bc1f91dbe2092f5700c7693100677f 100644
--- a/nif_math.h
+++ b/nif_math.h
@@ -10,6 +10,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "dll_export.h"
 
 using namespace std;
+namespace NifLib {
 
 #ifndef PI
 #define PI 3.14159265358979323846f  //Probably more accurate than a float can be, but it will just be rounded off anyway
@@ -19,6 +20,7 @@ using namespace std;
 struct TexCoord;
 struct Triangle;
 struct Vector3;
+struct Color3;
 struct Color4;
 struct Quaternion;
 struct Float2;
@@ -478,6 +480,8 @@ struct Matrix33 {
 		out[2][0] = rows[2][0]; out[2][1] = rows[2][1]; out[2][2] = rows[2][2];
 	}
 
+   NIFLIB_API Matrix33 operator*( const Matrix33 & m ) const;
+
 	//Python Operator Overloads
 	NIFLIB_API Float3 & __getitem__(int n) {
 		if (n > 2 || n < 0)
@@ -739,6 +743,9 @@ struct Matrix44 {
 		out[3][0] = rows[3][0]; out[3][1] = rows[3][1]; out[3][2] = rows[3][2]; out[3][3] = rows[3][3];
 	}
 
+   // undocumented
+   NIFLIB_API void Decompose( Vector3 & translate, Matrix33 & rotation, Float3 & scale ) const;
+
 	//Python Operator Overloads
 	NIFLIB_API Float4 & __getitem__(int n) {
 		if (n > 3 || n < 0)
@@ -880,4 +887,5 @@ ostream & operator<<( ostream & out, Color3 const & val );
 ostream & operator<<( ostream & out, Color4 const & val );
 ostream & operator<<( ostream & out, Quaternion const & val );
 
+}
 #endif
diff --git a/niflib.cpp b/niflib.cpp
index 326d351b61f2e69465d8b8917ebf290c73f84843..db21ebc9e5452de2054515907d2d35255f63b05c 100644
--- a/niflib.cpp
+++ b/niflib.cpp
@@ -10,6 +10,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "obj/NiAVObject.h"
 #include "obj/NiNode.h"
 #include "obj/NiTextKeyExtraData.h"
+#include "gen/header.h"
+namespace NifLib {
 
 //Stores the mapping between block names and factory function pointers to create them
 typedef IBlock * (*blk_factory_func)();
@@ -234,10 +236,11 @@ vector<NiObjectRef> ReadNifList( istream & in ) {
 //	uint user_version = 0;
 
 	//--Read Blocks--//
-	vector<NiObjectRef> blocks( header.numBlocks ); //List to hold the blocks
+   size_t numBlocks = header.numBlocks;
+	vector<NiObjectRef> blocks( numBlocks ); //List to hold the blocks
 	list<uint> link_stack; //List to add link values to as they're read in from the file
 	string objectType;
-	for (uint i = 0; i < header.numBlocks; i++) {
+	for (uint i = 0; i < numBlocks; i++) {
 
 		//Check for EOF
 		//if (in.eof() ) {
@@ -748,7 +751,7 @@ void MapParentNodeNames( map<string,NiAVObjectRef> & name_map, NiNodeRef & par )
 
 
 	//Add the par node to the map, and then call this function for each of its children
-	name_map[par->GetName()] = par;
+	name_map[par->GetName()] = StaticCast<NiAVObject>(par);
 
 	
 	vector<NiAVObjectRef> links = par->GetChildren();
@@ -862,3 +865,46 @@ void MergeNifTrees( NiNodeRef target, NiAVObjectRef right, unsigned int version
 	MergeSceneGraph( name_map, target, new_tree );
 }
 
+
+bool IsVersionSupported(unsigned int ver) {
+   switch (ver)
+   {
+   case VER_4_0_0_2:
+   case VER_4_1_0_12:
+   case VER_4_2_0_2:
+   case VER_4_2_1_0:
+   case VER_4_2_2_0:
+   case VER_10_0_1_0:
+   case VER_10_1_0_0:
+   case VER_10_2_0_0:
+   case VER_20_0_0_4:
+   case VER_20_0_0_5:
+      return true;
+   }
+   return false;
+}
+
+unsigned int GetVersion(string version){
+   unsigned int outver = 0;
+   string::size_type start = 0;
+   for(int offset = 3; offset >= 0 && start < version.length(); --offset) {
+      string::size_type end = version.find_first_of(".", start);
+      string::size_type len = (end == string.npos) ? end : end-start;
+      int num = 0;
+      stringstream sstr(version.substr(start, len));
+      sstr >> num;
+      if (num > 0xFF) {
+         outver = VER_INVALID;
+         break;
+      }
+      outver |= (num << (offset * 8));
+      if (len == string::npos) 
+         break;
+      start = start + len + 1;
+   }
+   if (outver == 0)
+      outver = VER_INVALID;
+   return outver;
+}
+
+} // namespace NifLib
\ No newline at end of file
diff --git a/niflib.h b/niflib.h
index fc4665f1439d9ee9ae8dcd9eeaeed3c92cc825a7..aa861b2fdb1102a252035d0d03c1978b6c07b402 100644
--- a/niflib.h
+++ b/niflib.h
@@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. */
 #include <vector>
 #include <list>
 #include <map>
+#include "dll_export.h"
 #include "nif_math.h"
 #include "NIF_IO.h"
 #include "obj/NiObject.h"
@@ -56,6 +57,7 @@ POSSIBILITY OF SUCH DAMAGE. */
 #include "kfm.h"
 
 using namespace std;
+namespace NifLib {
 
 #ifndef NULL
 #define NULL 0  /*!< Definition used to detect null pointers. */ 
@@ -222,6 +224,19 @@ NIFLIB_API void WriteFileGroup( string const & file_name, NiObjectRef const & ro
  */
 NIFLIB_API NiObjectRef CreateBlock( string block_type );
 
+/*!
+ * Returns whether the requested version is supported.
+ * \param version The version of the nif format to test for availablity.
+ * \return Whether the requested version is supported.
+ */
+NIFLIB_API bool IsVersionSupported(unsigned int ver);
+
+/*!
+ * Parses the version string and returns in the equivalent version as integer
+ * \param version The version of the nif format to parse.
+ * \return The version in integer format. Returns VER_INVALID for invalid version strings.
+ */
+NIFLIB_API unsigned int GetVersion(string version);
 
 
 //struct ComplexVertex {
@@ -508,4 +523,5 @@ You will probably also want to know the type of a block at some point.  You can
 
 */
 
+}
 #endif
diff --git a/niflib.vcproj b/niflib.vcproj
index 2701b1ee62ed3174329163383342d9a326bdb65c..2b8ec7831378999d9a8a58f0a54d3ce6adcd8446 100644
--- a/niflib.vcproj
+++ b/niflib.vcproj
@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
-			OutputDirectory="../Debug"
-			IntermediateDirectory="../Debug"
+			OutputDirectory="$(ProjectDir)../Debug"
+			IntermediateDirectory="$(ProjectDir)../Debug"
 			ConfigurationType="4"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -46,9 +46,10 @@
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="1"
 				UsePrecompiledHeader="0"
+				PrecompiledHeaderThrough="$(ProjectDir)pch.h"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -61,7 +62,7 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				OutputFile="../bin/niflib.lib"
+				OutputFile="$(ProjectDir)../bin/niflibd.lib"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -81,8 +82,8 @@
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
-			OutputDirectory="..\Release"
-			IntermediateDirectory="..\Release"
+			OutputDirectory="$(ProjectDir)..\Release"
+			IntermediateDirectory="$(ProjectDir)..\Release"
 			ConfigurationType="4"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -105,13 +106,13 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalOptions="/FI&quot;pch.h&quot;"
+				AdditionalOptions="/FI&quot;$(ProjectDir)pch.h&quot;"
 				Optimization="0"
 				WholeProgramOptimization="false"
 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="2"
-				PrecompiledHeaderThrough="pch.h"
+				PrecompiledHeaderThrough="$(ProjectDir)pch.h"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="true"
 				DebugInformationFormat="3"
@@ -279,6 +280,72 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="Debug - PCH|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/FI&quot;$(ProjectDir)pch.h&quot;"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="2"
+				PrecompiledHeaderThrough="$(ProjectDir)pch.h"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(ProjectDir)../bin/niflibd.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>
@@ -299,18 +366,19 @@
 			<File
 				RelativePath=".\niflib.cpp"
 				>
+			</File>
+			<File
+				RelativePath=".\pch.cpp"
+				>
 				<FileConfiguration
 					Name="Debug|Win32"
+					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
-						RuntimeLibrary="3"
+						UsePrecompiledHeader="0"
 					/>
 				</FileConfiguration>
-			</File>
-			<File
-				RelativePath=".\pch.cpp"
-				>
 				<FileConfiguration
 					Name="Release|Win32"
 					>
@@ -327,6 +395,14 @@
 						UsePrecompiledHeader="1"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug - PCH|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath=".\Type.cpp"
@@ -1251,6 +1327,10 @@
 					RelativePath=".\gen\obj_factories.cpp"
 					>
 				</File>
+				<File
+					RelativePath=".\gen\obj_impl.cpp"
+					>
+				</File>
 				<File
 					RelativePath=".\gen\Particle.cpp"
 					>
diff --git a/obj/ABoneLODController.cpp b/obj/ABoneLODController.cpp
index 1690bb9910fa5d3ef746611e9e70a6a61a735c9f..04f2b14b7c52ab63660edcfcb1e45b10133aae36 100644
--- a/obj/ABoneLODController.cpp
+++ b/obj/ABoneLODController.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "ABoneLODController.h"
 #include "../gen/NodeGroup.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type ABoneLODController::TYPE("ABoneLODController", &A_BONE_L_O_D_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/ABoneLODController.h b/obj/ABoneLODController.h
index dd730642146d360add059c6e0f4ac802be67bf75..68bf24a150b7cf63b57c62dcfb9c5cf9c80fc1cb 100644
--- a/obj/ABoneLODController.h
+++ b/obj/ABoneLODController.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _ABONELODCONTROLLER_H_
 
 #include "NiTimeController.h"
+
 // Include structures
 #include "../gen/NodeGroup.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +26,7 @@ public:
 	~ABoneLODController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +39,8 @@ public:
 	//TODO:  This is not a priority but needs to be implemented eventually
 protected:
 	A_BONE_L_O_D_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/AKeyedData.cpp b/obj/AKeyedData.cpp
index 82ca74163f0fda362d28e2e8bf95527ab2a667dd..e82e0b6e75a82a705656ded2de7b9fa303fee5d2 100644
--- a/obj/AKeyedData.cpp
+++ b/obj/AKeyedData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "AKeyedData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type AKeyedData::TYPE("AKeyedData", &A_KEYED_DATA_PARENT::TypeConst() );
diff --git a/obj/AKeyedData.h b/obj/AKeyedData.h
index 50f086b5a420667c0956150dd2eb5658b4b0bfc0..c3c1cc4d38fe99fa3fd2d126c5e6147190b0453b 100644
--- a/obj/AKeyedData.h
+++ b/obj/AKeyedData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _AKEYEDDATA_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~AKeyedData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	A_KEYED_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/APSysCtlr.cpp b/obj/APSysCtlr.cpp
index 26107f3f266fcfe6acb2c25c708445f44440cacf..7f9219935a2f6c8b49d0ce2495d870a37135a5ec 100644
--- a/obj/APSysCtlr.cpp
+++ b/obj/APSysCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "APSysCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type APSysCtlr::TYPE("APSysCtlr", &A_P_SYS_CTLR_PARENT::TypeConst() );
diff --git a/obj/APSysCtlr.h b/obj/APSysCtlr.h
index 7feefad35b972961540ea577cc7127268335a56f..1d6209ea3bef08050c42d0851d30d0a0ff76195a 100644
--- a/obj/APSysCtlr.h
+++ b/obj/APSysCtlr.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _APSYSCTLR_H_
 
 #include "NiSingleInterpolatorController.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~APSysCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	A_P_SYS_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/APSysData.cpp b/obj/APSysData.cpp
index b888caca3855276932ae836b040a352f44ecd80e..6d5f5630e00ae0267c4fc9e7b8e0ca66525905d1 100644
--- a/obj/APSysData.cpp
+++ b/obj/APSysData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "APSysData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type APSysData::TYPE("APSysData", &A_P_SYS_DATA_PARENT::TypeConst() );
diff --git a/obj/APSysData.h b/obj/APSysData.h
index 7fb36ccdfc1a56c8149cfdf9652b0298c89eedee..9fa50ae4543068bd88fd90d5e47fa8c862879946 100644
--- a/obj/APSysData.h
+++ b/obj/APSysData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _APSYSDATA_H_
 
 #include "NiTriBasedGeomData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~APSysData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	A_P_SYS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/AParticleModifier.cpp b/obj/AParticleModifier.cpp
index 2caf04107cbe535363104af6c0ec34577948f5e7..83809028af85578e6a398d4bf4ba4e71e4399e96 100644
--- a/obj/AParticleModifier.cpp
+++ b/obj/AParticleModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "AParticleModifier.h"
 #include "NiParticleSystemController.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type AParticleModifier::TYPE("AParticleModifier", &A_PARTICLE_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/AParticleModifier.h b/obj/AParticleModifier.h
index 9ee82fa56edc4abf0b5a0f739af7798258ae7328..2284bafec3fb5a9accc981807f2c3f2c774343d5 100644
--- a/obj/AParticleModifier.h
+++ b/obj/AParticleModifier.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiParticleSystemController;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~AParticleModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	A_PARTICLE_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/AbhkConstraint.cpp b/obj/AbhkConstraint.cpp
index c8363e7a5113a4e11b554c09843307ee5bf4038f..cee306e0ee0b23f7e55a00c75f0d9b9449e556c5 100644
--- a/obj/AbhkConstraint.cpp
+++ b/obj/AbhkConstraint.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "AbhkConstraint.h"
 #include "bhkShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type AbhkConstraint::TYPE("AbhkConstraint", &ABHK_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/AbhkConstraint.h b/obj/AbhkConstraint.h
index 04b4e043e2c5c84a89bdd5fded5eb7ea2e67831a..d506d6e1a3a379166a1119ddb4f7c1252d6c8594 100644
--- a/obj/AbhkConstraint.h
+++ b/obj/AbhkConstraint.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _ABHKCONSTRAINT_H_
 
 #include "bhkSerializable.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class bhkShape;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~AbhkConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	ABHK_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/AbhkRagdollConstraint.cpp b/obj/AbhkRagdollConstraint.cpp
index 1c8c91808026cd73900130d05c6e2140b672a26a..74e93679542520e0579d0ee0fd6b4b9c33b49c9f 100644
--- a/obj/AbhkRagdollConstraint.cpp
+++ b/obj/AbhkRagdollConstraint.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "AbhkRagdollConstraint.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type AbhkRagdollConstraint::TYPE("AbhkRagdollConstraint", &ABHK_RAGDOLL_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/AbhkRagdollConstraint.h b/obj/AbhkRagdollConstraint.h
index db8d7e6b39606817844cb0b6df50392e02287c91..467939a184dbcd6ea5bf48aa8901301143c474aa 100644
--- a/obj/AbhkRagdollConstraint.h
+++ b/obj/AbhkRagdollConstraint.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _ABHKRAGDOLLCONSTRAINT_H_
 
 #include "AbhkConstraint.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~AbhkRagdollConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	ABHK_RAGDOLL_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/AbhkShapeCollection.cpp b/obj/AbhkShapeCollection.cpp
index aa3f670d131126a4bfe7ce35faa9c17b072b3a63..6a3055976c98cf66591990d12d7a0cad0383cc21 100644
--- a/obj/AbhkShapeCollection.cpp
+++ b/obj/AbhkShapeCollection.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "AbhkShapeCollection.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type AbhkShapeCollection::TYPE("AbhkShapeCollection", &ABHK_SHAPE_COLLECTION_PARENT::TypeConst() );
diff --git a/obj/AbhkShapeCollection.h b/obj/AbhkShapeCollection.h
index 3a99d057c6e2d2844ac75672364d15969c0db625..d5b8e916f0ad3c6e84b6bf57a106d827fdc646f7 100644
--- a/obj/AbhkShapeCollection.h
+++ b/obj/AbhkShapeCollection.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _ABHKSHAPECOLLECTION_H_
 
 #include "bhkShape.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~AbhkShapeCollection();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	ABHK_SHAPE_COLLECTION_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/AvoidNode.cpp b/obj/AvoidNode.cpp
index c93d9f30c9a5fb9e87a9387b0ad312a5e81b5c16..fc6ae11c389bae90198bb9937a4aa80d368142a2 100644
--- a/obj/AvoidNode.cpp
+++ b/obj/AvoidNode.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "AvoidNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type AvoidNode::TYPE("AvoidNode", &AVOID_NODE_PARENT::TypeConst() );
diff --git a/obj/AvoidNode.h b/obj/AvoidNode.h
index 0ab912e87e87cd24d7668d447a3291f79357f6ae..f1804a76527037f4a1fe12ccaf2ebb52e4271b6d 100644
--- a/obj/AvoidNode.h
+++ b/obj/AvoidNode.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _AVOIDNODE_H_
 
 #include "NiNode.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~AvoidNode();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	AVOID_NODE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/BSBound.cpp b/obj/BSBound.cpp
index b4122762b270bb36341b63bde7b1153ff8c60675..bcaacabfeed8c05addca9cd2a5e465e3f002e6f4 100644
--- a/obj/BSBound.cpp
+++ b/obj/BSBound.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "BSBound.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type BSBound::TYPE("BSBound", &B_S_BOUND_PARENT::TypeConst() );
diff --git a/obj/BSBound.h b/obj/BSBound.h
index 9c830c355c2389110ab405d03b17ae5418998443..7756eb8214180035ed8c7cb6daae2a3e67010b73 100644
--- a/obj/BSBound.h
+++ b/obj/BSBound.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BSBOUND_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~BSBound();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	B_S_BOUND_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/BSFurnitureMarker.cpp b/obj/BSFurnitureMarker.cpp
index 4a06a29470b7ee9587f9c340c2dd7e56bee42390..732aadeda306d45a8a8c7b0eef1ed1f13fe0ae2e 100644
--- a/obj/BSFurnitureMarker.cpp
+++ b/obj/BSFurnitureMarker.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "BSFurnitureMarker.h"
 #include "../gen/FurniturePosition.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type BSFurnitureMarker::TYPE("BSFurnitureMarker", &B_S_FURNITURE_MARKER_PARENT::TypeConst() );
diff --git a/obj/BSFurnitureMarker.h b/obj/BSFurnitureMarker.h
index d5d4efb29c63af603ad742cc67d3fca3b9fe929f..8cd7ecaf749991c513f359182257fc0ced5aefe8 100644
--- a/obj/BSFurnitureMarker.h
+++ b/obj/BSFurnitureMarker.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BSFURNITUREMARKER_H_
 
 #include "NiExtraData.h"
+
 // Include structures
 #include "../gen/FurniturePosition.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +26,7 @@ public:
 	~BSFurnitureMarker();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -38,6 +41,8 @@ public:
 
 protected:
 	B_S_FURNITURE_MARKER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/BSKeyframeController.cpp b/obj/BSKeyframeController.cpp
index 9bb786ce3bb50cb174767623519e65e625860fd9..3ba64ef8cfa3ea42837e3059c66c1d77ed5cca7e 100644
--- a/obj/BSKeyframeController.cpp
+++ b/obj/BSKeyframeController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "BSKeyframeController.h"
 #include "NiKeyframeData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type BSKeyframeController::TYPE("BSKeyframeController", &B_S_KEYFRAME_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/BSKeyframeController.h b/obj/BSKeyframeController.h
index 3c44dba5152536b33dbdaa122e86b0673f270587..ea096a392196fe200c9f1785fa09a227d2b11f8e 100644
--- a/obj/BSKeyframeController.h
+++ b/obj/BSKeyframeController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiKeyframeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiKeyframeData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~BSKeyframeController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	B_S_KEYFRAME_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/BSPSysArrayEmitter.cpp b/obj/BSPSysArrayEmitter.cpp
index bc465e66f110a934d0dbb101c29f706165f9877c..dabd8ffb408a5a299c909c02e50b035f3e879e8f 100644
--- a/obj/BSPSysArrayEmitter.cpp
+++ b/obj/BSPSysArrayEmitter.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "BSPSysArrayEmitter.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type BSPSysArrayEmitter::TYPE("BSPSysArrayEmitter", &B_S_P_SYS_ARRAY_EMITTER_PARENT::TypeConst() );
diff --git a/obj/BSPSysArrayEmitter.h b/obj/BSPSysArrayEmitter.h
index 3011ec2bb8c97748c4f52552224ec490a22e054d..ff5142da745986d9e4b91fcecb0032b3c7680082 100644
--- a/obj/BSPSysArrayEmitter.h
+++ b/obj/BSPSysArrayEmitter.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BSPSYSARRAYEMITTER_H_
 
 #include "NiPSysVolumeEmitter.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~BSPSysArrayEmitter();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	B_S_P_SYS_ARRAY_EMITTER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/BSParentVelocityModifier.cpp b/obj/BSParentVelocityModifier.cpp
index fbfe0c6f9bff674d760049ee9936866855c19397..2008cd80e5c5f64b68a8a77518858f3db7482730 100644
--- a/obj/BSParentVelocityModifier.cpp
+++ b/obj/BSParentVelocityModifier.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "BSParentVelocityModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type BSParentVelocityModifier::TYPE("BSParentVelocityModifier", &B_S_PARENT_VELOCITY_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/BSParentVelocityModifier.h b/obj/BSParentVelocityModifier.h
index 04d051fc82d6244372a4cfb7f95f688847a6a57a..1e09728ba2116c9bbfd0f2b9af124f5de079c1a4 100644
--- a/obj/BSParentVelocityModifier.h
+++ b/obj/BSParentVelocityModifier.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BSPARENTVELOCITYMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~BSParentVelocityModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	B_S_PARENT_VELOCITY_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/BSXFlags.cpp b/obj/BSXFlags.cpp
index 172b27718ad214a337c007b029c73a8dba985aae..d372e030eab961ef5100cf4a125f638779c728b5 100644
--- a/obj/BSXFlags.cpp
+++ b/obj/BSXFlags.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "BSXFlags.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type BSXFlags::TYPE("BSXFlags", &B_S_X_FLAGS_PARENT::TypeConst() );
diff --git a/obj/BSXFlags.h b/obj/BSXFlags.h
index beee3235c8ab2a42e0aa444dec70c8975043f247..6607b9eda64b9c67058a892e73a23b899c25ae71 100644
--- a/obj/BSXFlags.h
+++ b/obj/BSXFlags.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BSXFLAGS_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~BSXFlags();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	B_S_X_FLAGS_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/FxButton.cpp b/obj/FxButton.cpp
index 1b6f9fc9da40d24c7d9e0d777e58eaa4c399e418..d6bca43b44f889217eb06076a4fe7a41b30ca2bf 100644
--- a/obj/FxButton.cpp
+++ b/obj/FxButton.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "FxButton.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type FxButton::TYPE("FxButton", &FX_BUTTON_PARENT::TypeConst() );
diff --git a/obj/FxButton.h b/obj/FxButton.h
index 574aa4eb4c8be2d6af5ae484b3dbe58e3d8e2be9..b33f98a9eb81d95e4f46da0fce24ba051db35e0d 100644
--- a/obj/FxButton.h
+++ b/obj/FxButton.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _FXBUTTON_H_
 
 #include "FxWidget.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~FxButton();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	FX_BUTTON_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/FxRadioButton.cpp b/obj/FxRadioButton.cpp
index f8eb243613912c8696399b66e3981719624e1643..abd48ef5635637c9ad14fd1273c485b1efb15af4 100644
--- a/obj/FxRadioButton.cpp
+++ b/obj/FxRadioButton.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "FxRadioButton.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type FxRadioButton::TYPE("FxRadioButton", &FX_RADIO_BUTTON_PARENT::TypeConst() );
diff --git a/obj/FxRadioButton.h b/obj/FxRadioButton.h
index ceffd817305bd28199c26d1704d243a521127b6b..db515e8d12516abcf4ed6fe1e867f031f5344f57 100644
--- a/obj/FxRadioButton.h
+++ b/obj/FxRadioButton.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "FxWidget.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiObject;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~FxRadioButton();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	FX_RADIO_BUTTON_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/FxWidget.cpp b/obj/FxWidget.cpp
index bb60ceaba80fea9fba29f0784eafab0e939ffe34..8c6564f7ad70588313a1ccf76c8689c212bc71ff 100644
--- a/obj/FxWidget.cpp
+++ b/obj/FxWidget.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "FxWidget.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type FxWidget::TYPE("FxWidget", &FX_WIDGET_PARENT::TypeConst() );
diff --git a/obj/FxWidget.h b/obj/FxWidget.h
index 7727d795e5826e4e233613b9532fcca89b392ccc..6f9077e9422f4736c8d639c4ac8a899abb4fe59a 100644
--- a/obj/FxWidget.h
+++ b/obj/FxWidget.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _FXWIDGET_H_
 
 #include "NiNode.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~FxWidget();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	FX_WIDGET_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiAVObject.cpp b/obj/NiAVObject.cpp
index eb84e35693b13c4129bf4141c0917c2d6e463085..66df202db205e381f8237173e6238532be87a7a8 100644
--- a/obj/NiAVObject.cpp
+++ b/obj/NiAVObject.cpp
@@ -6,6 +6,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiProperty.h"
 #include "NiCollisionData.h"
 #include "NiCollisionObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiAVObject::TYPE("NiAVObject", &NI_A_V_OBJECT_PARENT::TypeConst() );
diff --git a/obj/NiAVObject.h b/obj/NiAVObject.h
index 6355f5b2a80e05b9ced3a52775ae7fdd65be4799..d0a1723a9f0993a29d0e193978bd17f72aae8556 100644
--- a/obj/NiAVObject.h
+++ b/obj/NiAVObject.h
@@ -6,15 +6,16 @@ All rights reserved.  Please see niflib.h for licence. */
 
 // Includes
 #include "../gen/BoundingBox.h"
+#include "../gen/obj_defines.h"
+#include NI_A_V_OBJECT_INCLUDE
+namespace NifLib {
 
-//Forward Defines
+// Forward define of referenced blocks
 class NiProperty;
 class NiCollisionData;
 class NiCollisionObject;
 class NiNode;
 
-#include "../gen/obj_defines.h"
-#include NI_A_V_OBJECT_INCLUDE
 
 /*
  * NiAVObject - An audio/video object?  Part of the scene graph and has a position in 3D.
@@ -82,9 +83,10 @@ public:
 	void SetVelocity( const Vector3 & n );
 
 protected:
-	NI_A_V_OBJECT_MEMBERS
-
 	NiNode * parent;
+	NI_A_V_OBJECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiAlphaController.cpp b/obj/NiAlphaController.cpp
index 1491cff0bfa49bc8faab03df81d4e10dab2b1006..e9f16f01d6d3c7578ddf08e636d499d8f0c4f38e 100644
--- a/obj/NiAlphaController.cpp
+++ b/obj/NiAlphaController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAlphaController.h"
 #include "NiFloatData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiAlphaController::TYPE("NiAlphaController", &NI_ALPHA_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiAlphaController.h b/obj/NiAlphaController.h
index f413e035b068959ed4e596262a211e7ebec80a29..e406314a1b2a8332ebf0454b8acfc44ffc6d2f6a 100644
--- a/obj/NiAlphaController.h
+++ b/obj/NiAlphaController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSingleInterpolatorController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiFloatData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiAlphaController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_ALPHA_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiAlphaProperty.cpp b/obj/NiAlphaProperty.cpp
index b40552fd84027e9164a29f598ae95bf86d04e074..d86a605c58b865d175a6bcd645f78a20820df9c5 100644
--- a/obj/NiAlphaProperty.cpp
+++ b/obj/NiAlphaProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAlphaProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiAlphaProperty::TYPE("NiAlphaProperty", &NI_ALPHA_PROPERTY_PARENT::TypeConst() );
@@ -50,3 +51,55 @@ void NiAlphaProperty::SetAlphaTestThreshold( byte n ) {
 	threshold = n;
 }
 
+#define NIFLIB_GET_FLAG(value, shift, mask) \
+   (( value >> shift ) & mask)
+
+#define NIFLIB_MASK_FLAG(flag, value, shift, mask) \
+   ((flag ^ ~(mask << shift)) | ((value & mask) << shift))
+
+NiAlphaProperty::BlendMode NiAlphaProperty::GetSourceBlendMode() const {
+   return (NiAlphaProperty::BlendMode)NIFLIB_GET_FLAG(flags, 1, 0x0f);
+}
+
+void NiAlphaProperty::SetSourceBlendMode(BlendMode value) {
+   flags = NIFLIB_MASK_FLAG(flags, value, 1, 0x0f);
+}
+
+NiAlphaProperty::BlendMode NiAlphaProperty::GetDestBlendMode() const {
+   return (NiAlphaProperty::BlendMode)(( flags >> 5 ) & 0x0f);
+}
+
+void NiAlphaProperty::SetDestBlendMode(BlendMode value) {
+   flags = NIFLIB_MASK_FLAG(flags, value, 5, 0x0f);
+}
+
+NiAlphaProperty::TestMode NiAlphaProperty::GetTestMode() const {
+   return (NiAlphaProperty::TestMode)NIFLIB_GET_FLAG(flags, 10, 0x7);
+}
+
+void NiAlphaProperty::SetTestMode(TestMode value) {
+   flags = NIFLIB_MASK_FLAG(flags, value, 10, 0x7);
+}
+
+bool NiAlphaProperty::GetAlphaBlend() const {
+   return NIFLIB_GET_FLAG(flags, 0, 0x1) ? true : false;
+}
+
+void NiAlphaProperty::SetAlphaBlend(bool value) {
+   flags = NIFLIB_MASK_FLAG(flags, value?1:0, 0, 0x1);
+}
+
+bool NiAlphaProperty::GetAlphaTest() const {
+   return NIFLIB_GET_FLAG(flags, 9, 0x1) ? true : false;
+}
+
+void NiAlphaProperty::SetAlphaTest(bool value) {
+   flags = NIFLIB_MASK_FLAG(flags, value?1:0, 9, 0x1);
+}
+
+bool NiAlphaProperty::GetAlphaSort() const {
+   return NIFLIB_GET_FLAG(flags, 13, 0x1) ? false : true;
+}
+void NiAlphaProperty::SetAlphaSort(bool value) {
+   flags = NIFLIB_MASK_FLAG(flags, value?0:1, 13, 0x1);
+}
diff --git a/obj/NiAlphaProperty.h b/obj/NiAlphaProperty.h
index e7b0e2a3eb58eabb2876db82011ad3d19fd9346d..9f65030294b042e0661d3174a5d88b0878c2ce61 100644
--- a/obj/NiAlphaProperty.h
+++ b/obj/NiAlphaProperty.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIALPHAPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -31,6 +32,51 @@ public:
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
 
+   enum BlendMode
+   {
+      BM_ONE = 0x00,
+      BM_ZERO = 0x01,
+      BM_SRC_COLOR = 0x02,
+      BM_ONE_MINUS_SRC_COLOR = 0x03,
+      BM_DST_COLOR = 0x04,
+      BM_ONE_MINUS_DST_COLOR = 0x05,
+      BM_SRC_ALPHA = 0x06,
+      BM_ONE_MINUS_SRC_ALPHA = 0x07,
+      BM_DST_ALPHA = 0x08,
+      BM_ONE_MINUS_DST_ALPHA = 0x08,
+      BM_SRC_ALPHA_SATURATE = 0x09,
+   };
+
+   enum TestMode
+   {
+      TM_ALWAYS = 0x00,
+      TM_LESS = 0x01,
+      TM_EQUAL = 0x02,
+      TM_LEQUAL = 0x03,
+      TM_GREATER = 0x04,
+      TM_NOTEQUAL = 0x05,
+      TM_GEQUAL = 0x06,
+      TM_NEVER = 0x07,
+   };
+
+   BlendMode GetSourceBlendMode() const;
+   void SetSourceBlendMode(BlendMode value);
+
+   BlendMode GetDestBlendMode() const;
+   void SetDestBlendMode(BlendMode value);
+
+   TestMode GetTestMode() const;
+   void SetTestMode(TestMode value);
+
+   bool GetAlphaBlend() const;
+   void SetAlphaBlend(bool value);
+
+   bool GetAlphaTest() const;
+   void SetAlphaTest(bool value);
+
+   bool GetAlphaSort() const;
+   void SetAlphaSort(bool value);
+
 	ushort GetFlags() const;
 	void SetFlags( ushort n );
 
@@ -38,6 +84,8 @@ public:
 	void SetAlphaTestThreshold( byte n );
 protected:
 	NI_ALPHA_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiAmbientLight.cpp b/obj/NiAmbientLight.cpp
index af3b20cf66ddbe727bf79078ba243fa303ba33e9..7758d2c7a17eff460d6f6ecdce4dafe76084f88c 100644
--- a/obj/NiAmbientLight.cpp
+++ b/obj/NiAmbientLight.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAmbientLight.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiAmbientLight::TYPE("NiAmbientLight", &NI_AMBIENT_LIGHT_PARENT::TypeConst() );
diff --git a/obj/NiAmbientLight.h b/obj/NiAmbientLight.h
index f39d3c147ba305f4e68cc7e4c6f8a895da9ac92f..a822b02a6e88a0181aa551213f3cb31e0135946f 100644
--- a/obj/NiAmbientLight.h
+++ b/obj/NiAmbientLight.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIAMBIENTLIGHT_H_
 
 #include "NiLight.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiAmbientLight();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_AMBIENT_LIGHT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiAutoNormalParticles.cpp b/obj/NiAutoNormalParticles.cpp
index 97e3c74b12692ea6c693fac824e88270ef8143d4..f3579b4cda553075c71d53c78cbf279b63c8bad5 100644
--- a/obj/NiAutoNormalParticles.cpp
+++ b/obj/NiAutoNormalParticles.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAutoNormalParticles.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiAutoNormalParticles::TYPE("NiAutoNormalParticles", &NI_AUTO_NORMAL_PARTICLES_PARENT::TypeConst() );
diff --git a/obj/NiAutoNormalParticles.h b/obj/NiAutoNormalParticles.h
index 89a7940036e2cc9a8788aba91813807a86b239ea..5e420d30c60021453e8a74ee6c5fb3a4ebdbe688 100644
--- a/obj/NiAutoNormalParticles.h
+++ b/obj/NiAutoNormalParticles.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIAUTONORMALPARTICLES_H_
 
 #include "NiParticles.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiAutoNormalParticles();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_AUTO_NORMAL_PARTICLES_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiAutoNormalParticlesData.cpp b/obj/NiAutoNormalParticlesData.cpp
index 80b4bcf465c4b5261c20509af87fd8cfcf29d6fb..45aded21911932eae2f6c56f6418aea0c38b8b07 100644
--- a/obj/NiAutoNormalParticlesData.cpp
+++ b/obj/NiAutoNormalParticlesData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAutoNormalParticlesData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiAutoNormalParticlesData::TYPE("NiAutoNormalParticlesData", &NI_AUTO_NORMAL_PARTICLES_DATA_PARENT::TypeConst() );
diff --git a/obj/NiAutoNormalParticlesData.h b/obj/NiAutoNormalParticlesData.h
index e8ea880c6782df07f7a68e8100e5618a715a0172..34ae640b0e21580da81fb1e45a96dc0e6831e940 100644
--- a/obj/NiAutoNormalParticlesData.h
+++ b/obj/NiAutoNormalParticlesData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIAUTONORMALPARTICLESDATA_H_
 
 #include "NiTriBasedGeomData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +24,7 @@ public:
 	~NiAutoNormalParticlesData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +33,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_AUTO_NORMAL_PARTICLES_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSAnimationNode.cpp b/obj/NiBSAnimationNode.cpp
index ab5ba3db7fb1a23d0964b72617f9ec6926f342aa..e1012acac48aa912ab922fcccb74e5f1f9ac59b3 100644
--- a/obj/NiBSAnimationNode.cpp
+++ b/obj/NiBSAnimationNode.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSAnimationNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSAnimationNode::TYPE("NiBSAnimationNode", &NI_B_S_ANIMATION_NODE_PARENT::TypeConst() );
diff --git a/obj/NiBSAnimationNode.h b/obj/NiBSAnimationNode.h
index 41b0b0c5691836494222938721babfb17a1700dc..3f3fa9bb4f2cea4e912f372f157f7a7a7103e6ab 100644
--- a/obj/NiBSAnimationNode.h
+++ b/obj/NiBSAnimationNode.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSANIMATIONNODE_H_
 
 #include "NiNode.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~NiBSAnimationNode();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_S_ANIMATION_NODE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSBoneLODController.cpp b/obj/NiBSBoneLODController.cpp
index 5f63acb12a6a99b68c45766ff98cad71d786e1b8..aa108132e180f921c214bff2f1bf29b034fe1b82 100644
--- a/obj/NiBSBoneLODController.cpp
+++ b/obj/NiBSBoneLODController.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSBoneLODController.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSBoneLODController::TYPE("NiBSBoneLODController", &NI_B_S_BONE_L_O_D_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiBSBoneLODController.h b/obj/NiBSBoneLODController.h
index ad70373b411dbe3889d2de03266a596359f84ed2..c77092ef43979b2306e7d35ee77619a1f2b3930e 100644
--- a/obj/NiBSBoneLODController.h
+++ b/obj/NiBSBoneLODController.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSBONELODCONTROLLER_H_
 
 #include "ABoneLODController.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiBSBoneLODController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_S_BONE_L_O_D_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSPArrayController.cpp b/obj/NiBSPArrayController.cpp
index f5411537342ef3f52247cb3806f15105c53588bd..d469cc051b6cb5a2e612f8ffb2ba559f2f67a9c3 100644
--- a/obj/NiBSPArrayController.cpp
+++ b/obj/NiBSPArrayController.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSPArrayController.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSPArrayController::TYPE("NiBSPArrayController", &NI_B_S_P_ARRAY_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiBSPArrayController.h b/obj/NiBSPArrayController.h
index 1fb703c18e95e6daa25fce8f00559b39608fcbb2..a48cd05cc054c64dbe2752675012051dfe33f2a1 100644
--- a/obj/NiBSPArrayController.h
+++ b/obj/NiBSPArrayController.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSPARRAYCONTROLLER_H_
 
 #include "NiParticleSystemController.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~NiBSPArrayController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_S_P_ARRAY_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSParticleNode.cpp b/obj/NiBSParticleNode.cpp
index 55318a4bbc2f0480797bafe3bf861166be9701d6..b740cf7d06c037bd27855964c310eb10aa4cb696 100644
--- a/obj/NiBSParticleNode.cpp
+++ b/obj/NiBSParticleNode.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSParticleNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSParticleNode::TYPE("NiBSParticleNode", &NI_B_S_PARTICLE_NODE_PARENT::TypeConst() );
diff --git a/obj/NiBSParticleNode.h b/obj/NiBSParticleNode.h
index daebbb1954b12abd3bba68544e7b0bfb8449511c..9cb8d1c29efd903f3998d1bef2a236cc130daee4 100644
--- a/obj/NiBSParticleNode.h
+++ b/obj/NiBSParticleNode.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSPARTICLENODE_H_
 
 #include "NiNode.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiBSParticleNode();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_S_PARTICLE_NODE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSplineBasisData.cpp b/obj/NiBSplineBasisData.cpp
index c0f782c0b4ad4382a9c687a64c5dd0a0051ff96a..fc5e83f52501447526fc961f8f03c0e0de183673 100644
--- a/obj/NiBSplineBasisData.cpp
+++ b/obj/NiBSplineBasisData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSplineBasisData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSplineBasisData::TYPE("NiBSplineBasisData", &NI_B_SPLINE_BASIS_DATA_PARENT::TypeConst() );
diff --git a/obj/NiBSplineBasisData.h b/obj/NiBSplineBasisData.h
index e3908da5d5469393fcd55feb2c83cdbd8c95a9b2..f30f5d56000c0804aa274bf1e2b26be7f4ed7be8 100644
--- a/obj/NiBSplineBasisData.h
+++ b/obj/NiBSplineBasisData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSPLINEBASISDATA_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiBSplineBasisData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_SPLINE_BASIS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSplineCompFloatInterpolator.cpp b/obj/NiBSplineCompFloatInterpolator.cpp
index 2eb572f21348d716e63ec391652a60003b6f66dc..d30421f78aa7bde5892379cded657cb7f62cf96d 100644
--- a/obj/NiBSplineCompFloatInterpolator.cpp
+++ b/obj/NiBSplineCompFloatInterpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSplineCompFloatInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSplineCompFloatInterpolator::TYPE("NiBSplineCompFloatInterpolator", &NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBSplineCompFloatInterpolator.h b/obj/NiBSplineCompFloatInterpolator.h
index 2c117f84c38caebb08947aae4ed4f917cb17b374..a6b02d7bdacb0426fc05c8af809bd2498e24f442 100644
--- a/obj/NiBSplineCompFloatInterpolator.h
+++ b/obj/NiBSplineCompFloatInterpolator.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSPLINECOMPFLOATINTERPOLATOR_H_
 
 #include "NiBSplineInterpolator.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiBSplineCompFloatInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_SPLINE_COMP_FLOAT_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSplineCompPoint3Interpolator.cpp b/obj/NiBSplineCompPoint3Interpolator.cpp
index c1091f4e613667d5dcb8edc442fdd5a1a2841db4..b9f056df8c9e8ab9a371b963300722765948d303 100644
--- a/obj/NiBSplineCompPoint3Interpolator.cpp
+++ b/obj/NiBSplineCompPoint3Interpolator.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiBSplineCompPoint3Interpolator.h"
 #include "NiBSplineData.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSplineCompPoint3Interpolator::TYPE("NiBSplineCompPoint3Interpolator", &NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBSplineCompPoint3Interpolator.h b/obj/NiBSplineCompPoint3Interpolator.h
index 2a9a3ec3bee9fa26d0c2e8bc999df8e400923a77..c7516f88c5dd325b3e1b46eb20bc3a7adeb7f893 100644
--- a/obj/NiBSplineCompPoint3Interpolator.h
+++ b/obj/NiBSplineCompPoint3Interpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSplineInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiBSplineData;
 class NiObject;
 
@@ -26,7 +29,7 @@ public:
 	~NiBSplineCompPoint3Interpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_SPLINE_COMP_POINT3_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSplineCompTransformInterpolator.cpp b/obj/NiBSplineCompTransformInterpolator.cpp
index 3eb0caac733d00eb84940b6eeed93d5babc04caa..83148da5d32a5cd9acd4c34d30f674dee9a75eda 100644
--- a/obj/NiBSplineCompTransformInterpolator.cpp
+++ b/obj/NiBSplineCompTransformInterpolator.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiBSplineCompTransformInterpolator.h"
 #include "NiBSplineData.h"
 #include "NiBSplineBasisData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSplineCompTransformInterpolator::TYPE("NiBSplineCompTransformInterpolator", &NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBSplineCompTransformInterpolator.h b/obj/NiBSplineCompTransformInterpolator.h
index f46e7fc5fe6931532b12dd5df5df7fadb61ad525..bdc5d3a7e9b45fe7f3e83ff1832cbc65098821ac 100644
--- a/obj/NiBSplineCompTransformInterpolator.h
+++ b/obj/NiBSplineCompTransformInterpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSplineInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiBSplineData;
 class NiBSplineBasisData;
 
@@ -26,7 +29,7 @@ public:
 	~NiBSplineCompTransformInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_SPLINE_COMP_TRANSFORM_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSplineData.cpp b/obj/NiBSplineData.cpp
index da79950cf136529aeea491a51bf15f8f14f468c9..0ac937f82363e97cbe16f30c72984b883792dda7 100644
--- a/obj/NiBSplineData.cpp
+++ b/obj/NiBSplineData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSplineData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSplineData::TYPE("NiBSplineData", &NI_B_SPLINE_DATA_PARENT::TypeConst() );
diff --git a/obj/NiBSplineData.h b/obj/NiBSplineData.h
index 3a98911bcf2e2b531c23281eb72082edfe0693b6..109bbf55c215e51a01a57ffd80c6bdea94eec1d8 100644
--- a/obj/NiBSplineData.h
+++ b/obj/NiBSplineData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSPLINEDATA_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -15,13 +16,13 @@ typedef Ref<NiBSplineData> NiBSplineDataRef;
  * NiBSplineData - Unknown.
  */
 
-class NiBSplineData : public NI_B_SPLINE_DATA_PARENT {
+class NIFLIB_API NiBSplineData : public NI_B_SPLINE_DATA_PARENT {
 public:
 	NiBSplineData();
 	~NiBSplineData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_SPLINE_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBSplineInterpolator.cpp b/obj/NiBSplineInterpolator.cpp
index 96a24942c57005b33e1c3f4a71e66c025a2a4f15..4b00e6d4e4863c3d3c36f63e034f69b8ba73e2cf 100644
--- a/obj/NiBSplineInterpolator.cpp
+++ b/obj/NiBSplineInterpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBSplineInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBSplineInterpolator::TYPE("NiBSplineInterpolator", &NI_B_SPLINE_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBSplineInterpolator.h b/obj/NiBSplineInterpolator.h
index d7f1f13484dc69aa6a492fdb0298cecabca82160..3961d3e4e08cc54831bb203dbcb0122150dbc80f 100644
--- a/obj/NiBSplineInterpolator.h
+++ b/obj/NiBSplineInterpolator.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBSPLINEINTERPOLATOR_H_
 
 #include "NiInterpolator.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiBSplineInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_B_SPLINE_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBillboardNode.cpp b/obj/NiBillboardNode.cpp
index 3debb58c8de756dedd26e5f9fde91011c98a8912..93a16e95bbe2971ae23c5222aed476a892666fe7 100644
--- a/obj/NiBillboardNode.cpp
+++ b/obj/NiBillboardNode.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBillboardNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBillboardNode::TYPE("NiBillboardNode", &NI_BILLBOARD_NODE_PARENT::TypeConst() );
diff --git a/obj/NiBillboardNode.h b/obj/NiBillboardNode.h
index 116fcfab2d6782c794674177d7f79395840043a2..acf7d90d24d09899c1cd604d10151e6bc4da13c7 100644
--- a/obj/NiBillboardNode.h
+++ b/obj/NiBillboardNode.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBILLBOARDNODE_H_
 
 #include "NiNode.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +24,7 @@ public:
 	~NiBillboardNode();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +33,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BILLBOARD_NODE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBinaryExtraData.cpp b/obj/NiBinaryExtraData.cpp
index dfa649c68c1b2603204b07a069f76e3d19c8b5db..7f541a88569ededbd536d9076d21ea583e82c7a9 100644
--- a/obj/NiBinaryExtraData.cpp
+++ b/obj/NiBinaryExtraData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBinaryExtraData.h"
 #include "../gen/ByteArray.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBinaryExtraData::TYPE("NiBinaryExtraData", &NI_BINARY_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiBinaryExtraData.h b/obj/NiBinaryExtraData.h
index d0f37b85c3539bb58667ba22f678a4df05595ce7..24aaff0ed9cc4dbb88ba2ddce73685c094f2edba 100644
--- a/obj/NiBinaryExtraData.h
+++ b/obj/NiBinaryExtraData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiExtraData.h"
 // Include structures
 #include "../gen/ByteArray.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -39,6 +40,8 @@ public:
 
 protected:
 	NI_BINARY_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBlendBoolInterpolator.cpp b/obj/NiBlendBoolInterpolator.cpp
index 1c2409b8dc8cbb487c01570b7ac8865de517062a..e38539676c6a3dd62733287eb21616550bfce30c 100644
--- a/obj/NiBlendBoolInterpolator.cpp
+++ b/obj/NiBlendBoolInterpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBlendBoolInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBlendBoolInterpolator::TYPE("NiBlendBoolInterpolator", &NI_BLEND_BOOL_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBlendBoolInterpolator.h b/obj/NiBlendBoolInterpolator.h
index 4b19a585cdf1ba34f09161dba837a7f13d4737e4..f248236cd75863514b0d921128b64026ed051ab9 100644
--- a/obj/NiBlendBoolInterpolator.h
+++ b/obj/NiBlendBoolInterpolator.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBLENDBOOLINTERPOLATOR_H_
 
 #include "NiBlendInterpolator.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiBlendBoolInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BLEND_BOOL_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBlendFloatInterpolator.cpp b/obj/NiBlendFloatInterpolator.cpp
index ae3f3a7b31f3ae04842debc2c7adf96f469e7967..68b858da8ae9c5688793d1471ad188394a1436be 100644
--- a/obj/NiBlendFloatInterpolator.cpp
+++ b/obj/NiBlendFloatInterpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBlendFloatInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBlendFloatInterpolator::TYPE("NiBlendFloatInterpolator", &NI_BLEND_FLOAT_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBlendFloatInterpolator.h b/obj/NiBlendFloatInterpolator.h
index 41f1ee74398599190c42f1842834ee3c291512d3..c06a9b71f57cbbc53a90da7b9899bf7c8e5f34f9 100644
--- a/obj/NiBlendFloatInterpolator.h
+++ b/obj/NiBlendFloatInterpolator.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBLENDFLOATINTERPOLATOR_H_
 
 #include "NiBlendInterpolator.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiBlendFloatInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BLEND_FLOAT_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBlendInterpolator.cpp b/obj/NiBlendInterpolator.cpp
index 3eed1713d68d751ce8787644a3860c85b7a49414..b273cfb2cc7ffe28af22dec88664e339bb4beda1 100644
--- a/obj/NiBlendInterpolator.cpp
+++ b/obj/NiBlendInterpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBlendInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBlendInterpolator::TYPE("NiBlendInterpolator", &NI_BLEND_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBlendInterpolator.h b/obj/NiBlendInterpolator.h
index ce5dd27336789f05e2e1bec794c69cc2bb7ff3e1..f17b9fa5a971cce098f2657bba3d86be6ab9003c 100644
--- a/obj/NiBlendInterpolator.h
+++ b/obj/NiBlendInterpolator.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBLENDINTERPOLATOR_H_
 
 #include "NiInterpolator.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiBlendInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BLEND_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBlendPoint3Interpolator.cpp b/obj/NiBlendPoint3Interpolator.cpp
index 3b2324b176d70c2f1255a35676c2a7c961ffc683..1f357b587d0109c2e5dfbc41b18c631811668d61 100644
--- a/obj/NiBlendPoint3Interpolator.cpp
+++ b/obj/NiBlendPoint3Interpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBlendPoint3Interpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBlendPoint3Interpolator::TYPE("NiBlendPoint3Interpolator", &NI_BLEND_POINT3_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBlendPoint3Interpolator.h b/obj/NiBlendPoint3Interpolator.h
index df6d38f58ec2ee422c83e338690d62c0bc5a6523..3c4de36b0532ef971ee48f5e65c32741fed08d27 100644
--- a/obj/NiBlendPoint3Interpolator.h
+++ b/obj/NiBlendPoint3Interpolator.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBLENDPOINT3INTERPOLATOR_H_
 
 #include "NiBlendInterpolator.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiBlendPoint3Interpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BLEND_POINT3_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBlendTransformInterpolator.cpp b/obj/NiBlendTransformInterpolator.cpp
index 8aef4c6d9fa8f663b0a80d6ae5bed65cfcf2df98..5728d994f60f621b98a0d053d51332592872d32c 100644
--- a/obj/NiBlendTransformInterpolator.cpp
+++ b/obj/NiBlendTransformInterpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBlendTransformInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBlendTransformInterpolator::TYPE("NiBlendTransformInterpolator", &NI_BLEND_TRANSFORM_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBlendTransformInterpolator.h b/obj/NiBlendTransformInterpolator.h
index ef17a888289d75f2ed6645e1aebaa55501d3de34..d39fc7039d5b33f0c5f93b7c46400722350fee90 100644
--- a/obj/NiBlendTransformInterpolator.h
+++ b/obj/NiBlendTransformInterpolator.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBLENDTRANSFORMINTERPOLATOR_H_
 
 #include "NiBlendInterpolator.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiBlendTransformInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BLEND_TRANSFORM_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBoneLODController.cpp b/obj/NiBoneLODController.cpp
index b89ef1566c18b097d25c2c518114338cc0be011b..c15dd13a7b0561ee841633a9bb6d65ce4bad250b 100644
--- a/obj/NiBoneLODController.cpp
+++ b/obj/NiBoneLODController.cpp
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiTriShape.h"
 #include "NiSkinInstance.h"
 #include "NiTriShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBoneLODController::TYPE("NiBoneLODController", &NI_BONE_L_O_D_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiBoneLODController.h b/obj/NiBoneLODController.h
index 6280bfc06b89fe8de116b9fd175081802b64d273..865d6e8e149b5150917e516cab648db9e022cfe0 100644
--- a/obj/NiBoneLODController.h
+++ b/obj/NiBoneLODController.h
@@ -5,11 +5,13 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBONELODCONTROLLER_H_
 
 #include "ABoneLODController.h"
+
 // Include structures
 #include "../gen/SkinShapeGroup.h"
+#include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiTriShape;
 
 #include "../gen/obj_defines.h"
@@ -27,7 +29,7 @@ public:
 	~NiBoneLODController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BONE_L_O_D_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBoolData.cpp b/obj/NiBoolData.cpp
index 95d465d0f916b2f7e42fc4fcd520cb175d9f0016..ffc503b9a944b82281e1bd0afb78c2b5b1b57958 100644
--- a/obj/NiBoolData.cpp
+++ b/obj/NiBoolData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBoolData.h"
 #include "../gen/KeyGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBoolData::TYPE("NiBoolData", &NI_BOOL_DATA_PARENT::TypeConst() );
diff --git a/obj/NiBoolData.h b/obj/NiBoolData.h
index 7de5637a0974b25ca917bcf0e0b9ee600a53dadf..9755bc334b7cbf1ec3dea8ee3d036df45d95cf55 100644
--- a/obj/NiBoolData.h
+++ b/obj/NiBoolData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "AKeyedData.h"
 // Include structures
 #include "../gen/KeyGroup.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -59,6 +60,8 @@ public:
 
 protected:
 	NI_BOOL_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBoolInterpolator.cpp b/obj/NiBoolInterpolator.cpp
index 3eb9e1aada51cec440ef42abd9a39647f9989d25..047f46710f2a2d393fc7ddbcc6bfe7849f656910 100644
--- a/obj/NiBoolInterpolator.cpp
+++ b/obj/NiBoolInterpolator.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBoolInterpolator.h"
 #include "NiBoolData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBoolInterpolator::TYPE("NiBoolInterpolator", &NI_BOOL_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBoolInterpolator.h b/obj/NiBoolInterpolator.h
index 3714a6202db344417227da97c31b3ecbaca9bb16..c159153d5c49e44d5ae68a1965d986c52454df4e 100644
--- a/obj/NiBoolInterpolator.h
+++ b/obj/NiBoolInterpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiBoolData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiBoolInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BOOL_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBoolTimelineInterpolator.cpp b/obj/NiBoolTimelineInterpolator.cpp
index bb5b82373f36b3e2e536b5da703340232cc3ca82..d988de3889c4f1d221088cc2ae8b08d2910604c7 100644
--- a/obj/NiBoolTimelineInterpolator.cpp
+++ b/obj/NiBoolTimelineInterpolator.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBoolTimelineInterpolator.h"
 #include "NiBoolData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBoolTimelineInterpolator::TYPE("NiBoolTimelineInterpolator", &NI_BOOL_TIMELINE_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiBoolTimelineInterpolator.h b/obj/NiBoolTimelineInterpolator.h
index 6a28c901f7c3fd3c7055c70dfaf5c6b54182c54b..56745cd402c2992f3abd654d293c78d1207d573d 100644
--- a/obj/NiBoolTimelineInterpolator.h
+++ b/obj/NiBoolTimelineInterpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiBoolData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiBoolTimelineInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_BOOL_TIMELINE_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiBooleanExtraData.cpp b/obj/NiBooleanExtraData.cpp
index ece75ba9db04eaf8eb257f3c378070e0aeaf7040..1b986cc67e17577d3d7bace127c1fa0ad5ea0070 100644
--- a/obj/NiBooleanExtraData.cpp
+++ b/obj/NiBooleanExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBooleanExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiBooleanExtraData::TYPE("NiBooleanExtraData", &NI_BOOLEAN_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiBooleanExtraData.h b/obj/NiBooleanExtraData.h
index c57ef1586ed4adf19ef7b4466c99b5df08d9e5a2..0fcc339cb4fd263b34fd35d78fbda9a2b126283b 100644
--- a/obj/NiBooleanExtraData.h
+++ b/obj/NiBooleanExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIBOOLEANEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiBooleanExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	NI_BOOLEAN_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiCamera.cpp b/obj/NiCamera.cpp
index 201d242deac89f4792e2ffe88ada5a7aa2c6151c..84e53ed743165f3c62de39adf98dd1058286871c 100644
--- a/obj/NiCamera.cpp
+++ b/obj/NiCamera.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiCamera.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiCamera::TYPE("NiCamera", &NI_CAMERA_PARENT::TypeConst() );
diff --git a/obj/NiCamera.h b/obj/NiCamera.h
index fb3607892c5b4728476703a775f9dfceebd3994d..c7dfefb3d576a5ec2dcc41e23c1db6cfc8d885c6 100644
--- a/obj/NiCamera.h
+++ b/obj/NiCamera.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAVObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiObject;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiCamera();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_CAMERA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiCollisionData.cpp b/obj/NiCollisionData.cpp
index 5357e86bb64b2fe7ae35de21f49e0692be340047..624e3ca7f09bf810a3941a245f63d10ecdbda358 100644
--- a/obj/NiCollisionData.cpp
+++ b/obj/NiCollisionData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiCollisionData.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiCollisionData::TYPE("NiCollisionData", &NI_COLLISION_DATA_PARENT::TypeConst() );
diff --git a/obj/NiCollisionData.h b/obj/NiCollisionData.h
index c84ad8326c0102966a1beca13ee52e4a0ed8d34b..665e1882043ca6ca1b3414a5004895a81a0e454e 100644
--- a/obj/NiCollisionData.h
+++ b/obj/NiCollisionData.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NICOLLISIONDATA_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiNode;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~NiCollisionData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_COLLISION_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiCollisionObject.cpp b/obj/NiCollisionObject.cpp
index a96ae35d1a183f879e86fe47b56a58d4a64b2c7c..b76e77fe7cbf2bcdfa9e928cd606942cbe2f0981 100644
--- a/obj/NiCollisionObject.cpp
+++ b/obj/NiCollisionObject.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiCollisionObject.h"
 #include "NiAVObject.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiCollisionObject::TYPE("NiCollisionObject", &NI_COLLISION_OBJECT_PARENT::TypeConst() );
diff --git a/obj/NiCollisionObject.h b/obj/NiCollisionObject.h
index 76137dca8c544004c9fb5e4ab772de36fca4e61c..787e0b2b0c2f78225cf023a4e77f192a5412fdee 100644
--- a/obj/NiCollisionObject.h
+++ b/obj/NiCollisionObject.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiAVObject;
 class NiObject;
 
@@ -26,7 +29,7 @@ public:
 	~NiCollisionObject();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,9 +38,12 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NiAVObject * NiCollisionObject::Parent() const;
 	NI_COLLISION_OBJECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiColorData.cpp b/obj/NiColorData.cpp
index 54e53c0e8f30c0ef877497e7deed0b4d14d992a8..4c190159fdb4a56a848a2c00577e94f3d192fc75 100644
--- a/obj/NiColorData.cpp
+++ b/obj/NiColorData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiColorData.h"
 #include "../gen/KeyGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiColorData::TYPE("NiColorData", &NI_COLOR_DATA_PARENT::TypeConst() );
diff --git a/obj/NiColorData.h b/obj/NiColorData.h
index 299c166f8156d7719138643e7be3f0802f7e46d1..a3288d2d4e3c42df92c70af1c2e177ba5744430b 100644
--- a/obj/NiColorData.h
+++ b/obj/NiColorData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "AKeyedData.h"
 // Include structures
 #include "../gen/KeyGroup.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -58,6 +59,8 @@ public:
 	void SetKeys( vector< Key<Color4> > const & keys );
 protected:
 	NI_COLOR_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiColorExtraData.cpp b/obj/NiColorExtraData.cpp
index 9ab7e769f31ee5289692544b94c6e2fa3832953d..5d6f1f403f28dd252ef8485fc9cd006af7845667 100644
--- a/obj/NiColorExtraData.cpp
+++ b/obj/NiColorExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiColorExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiColorExtraData::TYPE("NiColorExtraData", &NI_COLOR_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiColorExtraData.h b/obj/NiColorExtraData.h
index 3e1e55ef1da0f0f97f59c9fa0b4f3ada52f15a1b..ad936422fc40fd657fce87fb1abdba3009d485a3 100644
--- a/obj/NiColorExtraData.h
+++ b/obj/NiColorExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NICOLOREXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiColorExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	NI_COLOR_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiControllerManager.cpp b/obj/NiControllerManager.cpp
index e541f1b3c89285879141c8333e5b6ed687fe1b57..ae4e62a487fc63c1ccb5a5a9a4b2c68493032bd6 100644
--- a/obj/NiControllerManager.cpp
+++ b/obj/NiControllerManager.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiControllerManager.h"
 #include "NiControllerSequence.h"
 #include "NiDefaultAVObjectPalette.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiControllerManager::TYPE("NiControllerManager", &NI_CONTROLLER_MANAGER_PARENT::TypeConst() );
diff --git a/obj/NiControllerManager.h b/obj/NiControllerManager.h
index 08e08267efd8acc4c3181611e8abca456ed3239d..180d1aae4777866cff125142660fd291073f6b92 100644
--- a/obj/NiControllerManager.h
+++ b/obj/NiControllerManager.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiControllerSequence;
 class NiDefaultAVObjectPalette;
 
@@ -26,7 +29,7 @@ public:
 	~NiControllerManager();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -39,6 +42,8 @@ public:
 	//TODO:  This is not a priority but needs to be implemented eventually
 protected:
 	NI_CONTROLLER_MANAGER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiControllerSequence.cpp b/obj/NiControllerSequence.cpp
index 13f951181841c0572b3958d70d531d1e595222a8..a988b766073e4af3de760706e7fba181d4d14d11 100644
--- a/obj/NiControllerSequence.cpp
+++ b/obj/NiControllerSequence.cpp
@@ -14,6 +14,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiControllerManager.h"
 #include "NiStringPalette.h"
 #include "NiTimeController.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiControllerSequence::TYPE("NiControllerSequence", &NI_CONTROLLER_SEQUENCE_PARENT::TypeConst() );
@@ -234,4 +235,4 @@ string NiControllerSequence::GetSubStr( const string & pal, short offset ) const
 	}
 
 	return out;
-}
\ No newline at end of file
+}
diff --git a/obj/NiControllerSequence.h b/obj/NiControllerSequence.h
index e1f39660fd3b69f2cbe60c1c85702db332ca3f14..241d79c70ddf0e51c5f3bf40435e01e8a27e64fe 100644
--- a/obj/NiControllerSequence.h
+++ b/obj/NiControllerSequence.h
@@ -7,9 +7,10 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiObject.h"
 // Include structures
 #include "../gen/ControllerLink.h"
+#include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiTextKeyExtraData;
 class NiControllerManager;
 class NiStringPalette;
@@ -31,7 +32,7 @@ public:
 	~NiControllerSequence();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -73,6 +74,8 @@ private:
 protected:
 	NiControllerManager * NiControllerSequence::Parent() const;
 	NI_CONTROLLER_SEQUENCE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiDefaultAVObjectPalette.cpp b/obj/NiDefaultAVObjectPalette.cpp
index c31c293653c856465c4c26f264adcf133c6ff880..26b3a1cf4526153945d0b69121365367b4b863e4 100644
--- a/obj/NiDefaultAVObjectPalette.cpp
+++ b/obj/NiDefaultAVObjectPalette.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiDefaultAVObjectPalette.h"
 #include "../gen/AVObject.h"
 #include "NiAVObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiDefaultAVObjectPalette::TYPE("NiDefaultAVObjectPalette", &NI_DEFAULT_A_V_OBJECT_PALETTE_PARENT::TypeConst() );
diff --git a/obj/NiDefaultAVObjectPalette.h b/obj/NiDefaultAVObjectPalette.h
index 672782ca237c7e139271d388e9f7883fadfc2db6..07deca0b39ea9630a4dda04d645d6ccd9cbb8fc4 100644
--- a/obj/NiDefaultAVObjectPalette.h
+++ b/obj/NiDefaultAVObjectPalette.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIDEFAULTAVOBJECTPALETTE_H_
 
 #include "NiObject.h"
+
 // Include structures
 #include "../gen/AVObject.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -24,7 +27,7 @@ public:
 	~NiDefaultAVObjectPalette();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -33,8 +36,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_DEFAULT_A_V_OBJECT_PALETTE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiDirectionalLight.cpp b/obj/NiDirectionalLight.cpp
index fbe8fddb1dc6a985cf44c1ddb6892d914a9d6905..a128eb2401893d0e063cff01591a01e7cfcd8353 100644
--- a/obj/NiDirectionalLight.cpp
+++ b/obj/NiDirectionalLight.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiDirectionalLight.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiDirectionalLight::TYPE("NiDirectionalLight", &NI_DIRECTIONAL_LIGHT_PARENT::TypeConst() );
diff --git a/obj/NiDirectionalLight.h b/obj/NiDirectionalLight.h
index 7a4bcfbb02e07d01e92cf8226bfff111641bab8a..5dc676126e62e1779337d9774f8069db9cfaefff 100644
--- a/obj/NiDirectionalLight.h
+++ b/obj/NiDirectionalLight.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIDIRECTIONALLIGHT_H_
 
 #include "NiLight.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiDirectionalLight();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_DIRECTIONAL_LIGHT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiDitherProperty.cpp b/obj/NiDitherProperty.cpp
index 37af4b9029700e9bb0ae8a82571a9b5933c8cf4b..f6b549d7efa25ecbbf2dc2f166b57b9d1a3da1ac 100644
--- a/obj/NiDitherProperty.cpp
+++ b/obj/NiDitherProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiDitherProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiDitherProperty::TYPE("NiDitherProperty", &NI_DITHER_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiDitherProperty.h b/obj/NiDitherProperty.h
index 7050671f8564f4eb28163b79232369204d919777..3f3ded8e93670d8e5255583352273ba985465e7b 100644
--- a/obj/NiDitherProperty.h
+++ b/obj/NiDitherProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIDITHERPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiDitherProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	NI_DITHER_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiDynamicEffect.cpp b/obj/NiDynamicEffect.cpp
index 8cd25608127fe9935d5ab9f650c2cc69eb84bd48..0d13631634498398a87e129859f3f2a0adf6fa24 100644
--- a/obj/NiDynamicEffect.cpp
+++ b/obj/NiDynamicEffect.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiDynamicEffect.h"
 #include "NiAVObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiDynamicEffect::TYPE("NiDynamicEffect", &NI_DYNAMIC_EFFECT_PARENT::TypeConst() );
diff --git a/obj/NiDynamicEffect.h b/obj/NiDynamicEffect.h
index 2b1e8d0ac0fdd3cbd6d758130b50f6763f620060..684f5c4287f95e4488503f1587cc9115164bcd42 100644
--- a/obj/NiDynamicEffect.h
+++ b/obj/NiDynamicEffect.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAVObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiAVObject;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiDynamicEffect();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_DYNAMIC_EFFECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiExtraData.cpp b/obj/NiExtraData.cpp
index 2ca67ad364ceb2df212b6d2f10c91db48fba677e..43da28e799b40c38ae005e961a71c6f0c806c846 100644
--- a/obj/NiExtraData.cpp
+++ b/obj/NiExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiExtraData::TYPE("NiExtraData", &NI_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiExtraData.h b/obj/NiExtraData.h
index 5ddb183e224dbc80b0df441bbdc021bc4cf2eaf0..3849bf2aeb894cd5fef2caeea000d1103f0316f2 100644
--- a/obj/NiExtraData.h
+++ b/obj/NiExtraData.h
@@ -6,6 +6,10 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 
+// Include structures
+#include "../Ref.h"
+namespace NifLib {
+
 #include "../gen/obj_defines.h"
 
 class NiExtraData;
@@ -66,6 +70,8 @@ public:
 
 protected:
 	NI_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiFlipController.cpp b/obj/NiFlipController.cpp
index 75dcaae4dd7c4bfa960f43350c1e3c91bb0287e0..8cb42f1eb0b6672b8146f0069d39b64c56f98e93 100644
--- a/obj/NiFlipController.cpp
+++ b/obj/NiFlipController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiFlipController.h"
 #include "NiSourceTexture.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiFlipController::TYPE("NiFlipController", &NI_FLIP_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiFlipController.h b/obj/NiFlipController.h
index 5850eb37caf880be2e55b84188020b35e84d9695..0202de6e6ee10594277e9378060c089e4881c2e2 100644
--- a/obj/NiFlipController.h
+++ b/obj/NiFlipController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSingleInterpolatorController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiSourceTexture;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiFlipController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_FLIP_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiFloatData.cpp b/obj/NiFloatData.cpp
index 882a546c190a0e6e2a4cdc07c8e2653669d37bfc..101c74099bef2b977e2105ed0af0c3110cdfba50 100644
--- a/obj/NiFloatData.cpp
+++ b/obj/NiFloatData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiFloatData.h"
 #include "../gen/KeyGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiFloatData::TYPE("NiFloatData", &NI_FLOAT_DATA_PARENT::TypeConst() );
diff --git a/obj/NiFloatData.h b/obj/NiFloatData.h
index 9a67ea96931312a1d9676f138279cf08dfc6b1d2..26a5135a4b340dbb1cf2896cc02e14556c1e2e15 100644
--- a/obj/NiFloatData.h
+++ b/obj/NiFloatData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "AKeyedData.h"
 // Include structures
 #include "../gen/KeyGroup.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -59,6 +60,8 @@ public:
 
 protected:
 	NI_FLOAT_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiFloatExtraData.cpp b/obj/NiFloatExtraData.cpp
index 9c22636547fa27ee4f08e13a8a3b45419414942e..07abe9579cc6935c418be5a49d3a502fff2dd4ea 100644
--- a/obj/NiFloatExtraData.cpp
+++ b/obj/NiFloatExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiFloatExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiFloatExtraData::TYPE("NiFloatExtraData", &NI_FLOAT_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiFloatExtraData.h b/obj/NiFloatExtraData.h
index dfadf8514a008dd3661d2b46c6e24c2e14660799..a1022b4b5373d4f8bc5608b3ad5143fc5a955fd9 100644
--- a/obj/NiFloatExtraData.h
+++ b/obj/NiFloatExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIFLOATEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiFloatExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,12 +32,14 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
-	
+
 	float GetData() const;
 	void SetData( float n );
 
 protected:
 	NI_FLOAT_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiFloatExtraDataController.cpp b/obj/NiFloatExtraDataController.cpp
index d1e53042c26ebd0aa47664ba2060d05c4f23d5ae..188afb6d3e3bc0379e1c01314b682cc0d93e30e1 100644
--- a/obj/NiFloatExtraDataController.cpp
+++ b/obj/NiFloatExtraDataController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiFloatExtraDataController.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiFloatExtraDataController::TYPE("NiFloatExtraDataController", &NI_FLOAT_EXTRA_DATA_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiFloatExtraDataController.h b/obj/NiFloatExtraDataController.h
index 610c93e5cb3db5d671346f54fff867ca4a8a35c3..bd717d4920f25bb658ca2208cc56d23f8e55b17a 100644
--- a/obj/NiFloatExtraDataController.h
+++ b/obj/NiFloatExtraDataController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiObject;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiFloatExtraDataController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -38,6 +41,8 @@ public:
 	//TODO:  The function of all data is currently unknown.
 protected:
 	NI_FLOAT_EXTRA_DATA_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiFloatInterpolator.cpp b/obj/NiFloatInterpolator.cpp
index 98d971a836fc8d55a97025b26cd3a167c3bbadfe..cc4595fa45d221e65598801c88385dd72e59651d 100644
--- a/obj/NiFloatInterpolator.cpp
+++ b/obj/NiFloatInterpolator.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiFloatInterpolator.h"
 #include "NiFloatData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiFloatInterpolator::TYPE("NiFloatInterpolator", &NI_FLOAT_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiFloatInterpolator.h b/obj/NiFloatInterpolator.h
index baaf48bed68b17b4f2dfae89f241dcd54f3165cc..801174276e52a8470eedb36b937d37f52176c717 100644
--- a/obj/NiFloatInterpolator.h
+++ b/obj/NiFloatInterpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiFloatData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiFloatInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_FLOAT_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiFloatsExtraData.cpp b/obj/NiFloatsExtraData.cpp
index 80fd06d69e2e6d9a91b832471ce09a7a40ac002e..34efb6be593c3b00a9cf25bf0cccfcde27e425a9 100644
--- a/obj/NiFloatsExtraData.cpp
+++ b/obj/NiFloatsExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiFloatsExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiFloatsExtraData::TYPE("NiFloatsExtraData", &NI_FLOATS_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiFloatsExtraData.h b/obj/NiFloatsExtraData.h
index 4d7c37d60fdb3143b3e3d8bf5cdf862fd6df514a..3c0a76185e59aec74311cc64101b11547debdf2c 100644
--- a/obj/NiFloatsExtraData.h
+++ b/obj/NiFloatsExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIFLOATSEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiFloatsExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	NI_FLOATS_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiFogProperty.cpp b/obj/NiFogProperty.cpp
index aa6ca97ad315e130418a18d36576d08b5366fb4d..d532f9f69e501a6f8164b2f685c5b8e88013d96d 100644
--- a/obj/NiFogProperty.cpp
+++ b/obj/NiFogProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiFogProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiFogProperty::TYPE("NiFogProperty", &NI_FOG_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiFogProperty.h b/obj/NiFogProperty.h
index 0ea648d860057eea7033eb59520e2bc5530d7e1a..602439343cf358c5e825df4a27ca6e274561f2e6 100644
--- a/obj/NiFogProperty.h
+++ b/obj/NiFogProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIFOGPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiFogProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -42,6 +44,8 @@ public:
 
 protected:
 	NI_FOG_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiGeomMorpherController.cpp b/obj/NiGeomMorpherController.cpp
index b8014b83c1d776052ae94e5b5bc1d32d4282ff7a..cecc15048e98272f531c652797ca091a2398b650 100644
--- a/obj/NiGeomMorpherController.cpp
+++ b/obj/NiGeomMorpherController.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiGeomMorpherController.h"
 #include "NiMorphData.h"
 #include "NiInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiGeomMorpherController::TYPE("NiGeomMorpherController", &NI_GEOM_MORPHER_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiGeomMorpherController.h b/obj/NiGeomMorpherController.h
index 5dea8ee1c190e28dd0fc1f85c1de04e5e546ce83..c986e29f76242a4ac21c0275c4991833f5bf7021 100644
--- a/obj/NiGeomMorpherController.h
+++ b/obj/NiGeomMorpherController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiMorphData;
 class NiInterpolator;
 
@@ -26,7 +29,7 @@ public:
 	~NiGeomMorpherController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -44,6 +47,8 @@ public:
 	void SetData( const Ref<NiMorphData> & n );
 protected:
 	NI_GEOM_MORPHER_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiGravity.cpp b/obj/NiGravity.cpp
index 9b0c780255231ec4952ade2606ded69d0db9065f..bd719addfb7a95f1cc2bb547605138918c116749 100644
--- a/obj/NiGravity.cpp
+++ b/obj/NiGravity.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiGravity.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiGravity::TYPE("NiGravity", &NI_GRAVITY_PARENT::TypeConst() );
diff --git a/obj/NiGravity.h b/obj/NiGravity.h
index f07226c39229e1e895708e8d733150b46080fe50..3b72ae15ca5070c1c8153ddfb9cad013db408d01 100644
--- a/obj/NiGravity.h
+++ b/obj/NiGravity.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIGRAVITY_H_
 
 #include "AParticleModifier.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~NiGravity();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -33,6 +34,8 @@ public:
 	virtual const Type & GetType() const;
 protected:
 	NI_GRAVITY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiIntegerExtraData.cpp b/obj/NiIntegerExtraData.cpp
index 96a9a3b1416ac821706abcb215c804d5af4172cb..4d8329517418cf7471937ec46494f584addcadef 100644
--- a/obj/NiIntegerExtraData.cpp
+++ b/obj/NiIntegerExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiIntegerExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiIntegerExtraData::TYPE("NiIntegerExtraData", &NI_INTEGER_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiIntegerExtraData.h b/obj/NiIntegerExtraData.h
index c581004ac75ac91d3e428b00718b8688443da93a..167dcf7b5ac7b7e3dc69209aeba8cead84b98e73 100644
--- a/obj/NiIntegerExtraData.h
+++ b/obj/NiIntegerExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIINTEGEREXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiIntegerExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	NI_INTEGER_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiIntegersExtraData.cpp b/obj/NiIntegersExtraData.cpp
index 5b9cc50aa277706c5454c882935408dfbcb8c433..45352fdec91b744748955b374f56a25fd7cf6166 100644
--- a/obj/NiIntegersExtraData.cpp
+++ b/obj/NiIntegersExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiIntegersExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiIntegersExtraData::TYPE("NiIntegersExtraData", &NI_INTEGERS_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiIntegersExtraData.h b/obj/NiIntegersExtraData.h
index 13c679da4b1ffd1a7e873de653d08c6d3e6e4ca8..745ec7ae9b8342ee990c4d77f9251eba696e6050 100644
--- a/obj/NiIntegersExtraData.h
+++ b/obj/NiIntegersExtraData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIINTEGERSEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -31,11 +32,16 @@ public:
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
 
-	vector<uint> GetData() const;
-	void SetData( const vector<uint> & n );
+	/*!
+	 * Integers.
+	 */
+	vector<uint > GetData() const;
+	void SetData( const vector<uint >& value );
 
 protected:
 	NI_INTEGERS_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiInterpolator.cpp b/obj/NiInterpolator.cpp
index 2c95202e288e7708a072ffee69dca47b4076b9a9..cc8adf944625a731241ba7e569ced7337263e01a 100644
--- a/obj/NiInterpolator.cpp
+++ b/obj/NiInterpolator.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiInterpolator::TYPE("NiInterpolator", &NI_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiInterpolator.h b/obj/NiInterpolator.h
index 958e702c210a2f0b632dd2c14eb9f4a8a9e95bdb..14eac07f8da078a73941df9f7ebaa018209f52a3 100644
--- a/obj/NiInterpolator.h
+++ b/obj/NiInterpolator.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIINTERPOLATOR_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiKeyframeController.cpp b/obj/NiKeyframeController.cpp
index 026f17e46539d58204a0e864ab32708dd7092062..3bed1b02698827c208fd31579a1965e2a4c72902 100644
--- a/obj/NiKeyframeController.cpp
+++ b/obj/NiKeyframeController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiKeyframeController.h"
 #include "NiKeyframeData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiKeyframeController::TYPE("NiKeyframeController", &NI_KEYFRAME_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiKeyframeController.h b/obj/NiKeyframeController.h
index a9aca36f24300170dd3f17e7bd8ef1c123828aea..4775d4b71e95de204bd470412622bb9a5169d9af 100644
--- a/obj/NiKeyframeController.h
+++ b/obj/NiKeyframeController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiKeyframeData;
 
 #include "../gen/obj_defines.h"
@@ -26,7 +29,7 @@ public:
 	~NiKeyframeController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -41,6 +44,8 @@ public:
 
 protected:
 	NI_KEYFRAME_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiKeyframeData.cpp b/obj/NiKeyframeData.cpp
index c7c889c95642deb49528999846e3349a1bd45429..0f83d0198fa7fc2656dc58347580f1978680a62e 100644
--- a/obj/NiKeyframeData.cpp
+++ b/obj/NiKeyframeData.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../gen/KeyGroup.h"
 #include "../gen/KeyGroup.h"
 #include "../gen/KeyGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiKeyframeData::TYPE("NiKeyframeData", &NI_KEYFRAME_DATA_PARENT::TypeConst() );
diff --git a/obj/NiKeyframeData.h b/obj/NiKeyframeData.h
index d668059ecc0814cdf2e8acea564f9392be3deb36..e50731b61d268ba4f5aabd45068ce413850d3a38 100644
--- a/obj/NiKeyframeData.h
+++ b/obj/NiKeyframeData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "AKeyedData.h"
 // Include structures
 #include "../gen/KeyGroup.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -185,6 +186,8 @@ public:
 
 protected:
 	NI_KEYFRAME_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiLODNode.cpp b/obj/NiLODNode.cpp
index 789ebff889468fcf73b87286bed5dab1eff9451d..6578240fa306557870deeb7557e69af0e9d119f1 100644
--- a/obj/NiLODNode.cpp
+++ b/obj/NiLODNode.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiLODNode.h"
 #include "../gen/LODRange.h"
 #include "NiRangeLODData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiLODNode::TYPE("NiLODNode", &NI_L_O_D_NODE_PARENT::TypeConst() );
diff --git a/obj/NiLODNode.h b/obj/NiLODNode.h
index 4a88dbbf11f3a8faf1f1fc0cb101b7f57d9c3573..1a7fc1c692775c7a5464f3989a7d517f93d7b237 100644
--- a/obj/NiLODNode.h
+++ b/obj/NiLODNode.h
@@ -5,11 +5,13 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NILODNODE_H_
 
 #include "NiNode.h"
+
 // Include structures
 #include "../gen/LODRange.h"
+#include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiRangeLODData;
 
 #include "../gen/obj_defines.h"
@@ -29,7 +31,7 @@ public:
 	~NiLODNode();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -38,8 +40,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_L_O_D_NODE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiLight.cpp b/obj/NiLight.cpp
index 8eee81509f0e477121c42554ad6f89a2b8f11186..db96b2b85e3ca191f767f9397315b50d027c306a 100644
--- a/obj/NiLight.cpp
+++ b/obj/NiLight.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiLight.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiLight::TYPE("NiLight", &NI_LIGHT_PARENT::TypeConst() );
diff --git a/obj/NiLight.h b/obj/NiLight.h
index 653aa8d3e26385624ecceea66fb1692c66eadfd8..1efd6fbc25d3a818ab5e45f17232739a8500429b 100644
--- a/obj/NiLight.h
+++ b/obj/NiLight.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NILIGHT_H_
 
 #include "NiDynamicEffect.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiLight();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_LIGHT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiLightColorController.cpp b/obj/NiLightColorController.cpp
index 45f30bda1468a2091e32e4df580c1ab070e03d6a..74cbea24b2a1787782051f8f1546290da4d1edf5 100644
--- a/obj/NiLightColorController.cpp
+++ b/obj/NiLightColorController.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiLightColorController.h"
 #include "NiPosData.h"
 #include "NiPoint3Interpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiLightColorController::TYPE("NiLightColorController", &NI_LIGHT_COLOR_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiLightColorController.h b/obj/NiLightColorController.h
index 4d9e864cb33bfc9ac127f63e2a08a9a423b8a1c7..d02fbc90827349068b78b61f93c46b8962f7b58b 100644
--- a/obj/NiLightColorController.h
+++ b/obj/NiLightColorController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPosData;
 class NiPoint3Interpolator;
 
@@ -26,7 +29,7 @@ public:
 	~NiLightColorController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -45,6 +48,8 @@ public:
 
 protected:
 	NI_LIGHT_COLOR_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiLightDimmerController.cpp b/obj/NiLightDimmerController.cpp
index 44628628495cc4469235bcfb4d9f3601c5ff4bdc..771efcf7f67a824763f04d1178bb72b26f3460a6 100644
--- a/obj/NiLightDimmerController.cpp
+++ b/obj/NiLightDimmerController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiLightDimmerController.h"
 #include "NiInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiLightDimmerController::TYPE("NiLightDimmerController", &NI_LIGHT_DIMMER_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiLightDimmerController.h b/obj/NiLightDimmerController.h
index deb0bd37aa9265decb7d062a6566b246e8359b59..79aac07201b01bdaf493f0447abe2320b1bff9fc 100644
--- a/obj/NiLightDimmerController.h
+++ b/obj/NiLightDimmerController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiInterpolator;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiLightDimmerController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_LIGHT_DIMMER_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiLookAtController.cpp b/obj/NiLookAtController.cpp
index ce5e18d9dbd93ed4831f293845c5aba90be536ca..e00191a107b6111e6ea11ef5e5942d6b2499c713 100644
--- a/obj/NiLookAtController.cpp
+++ b/obj/NiLookAtController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiLookAtController.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiLookAtController::TYPE("NiLookAtController", &NI_LOOK_AT_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiLookAtController.h b/obj/NiLookAtController.h
index 049ccf9fb31dff89454abf928954a371831a20ab..3dd0a551e3178de1b1f854f04e80cc6a96dfd885 100644
--- a/obj/NiLookAtController.h
+++ b/obj/NiLookAtController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiNode;
 
 #include "../gen/obj_defines.h"
@@ -26,7 +29,7 @@ public:
 	~NiLookAtController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_LOOK_AT_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiLookAtInterpolator.cpp b/obj/NiLookAtInterpolator.cpp
index 377a6ce5182032478af644231a69f219cf1cc1f1..74295dd21b25769c8d34f3424917ceb0b010aa6e 100644
--- a/obj/NiLookAtInterpolator.cpp
+++ b/obj/NiLookAtInterpolator.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiNode.h"
 #include "NiPoint3Interpolator.h"
 #include "NiFloatInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiLookAtInterpolator::TYPE("NiLookAtInterpolator", &NI_LOOK_AT_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiLookAtInterpolator.h b/obj/NiLookAtInterpolator.h
index dcd3ca5c9209a1e57bbad9f18717630b195082ba..fbaa69da6baa53be9dc1289cc058d85f07d2f8a1 100644
--- a/obj/NiLookAtInterpolator.h
+++ b/obj/NiLookAtInterpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiNode;
 class NiPoint3Interpolator;
 class NiFloatInterpolator;
@@ -27,7 +30,7 @@ public:
 	~NiLookAtInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,8 +39,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_LOOK_AT_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiMaterialColorController.cpp b/obj/NiMaterialColorController.cpp
index adfc10131747796efbf13ef25f53bf36496cf48d..e82f3b41c7a979594b2dedd1093f239db7fdd16e 100644
--- a/obj/NiMaterialColorController.cpp
+++ b/obj/NiMaterialColorController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiMaterialColorController.h"
 #include "NiPosData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiMaterialColorController::TYPE("NiMaterialColorController", &NI_MATERIAL_COLOR_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiMaterialColorController.h b/obj/NiMaterialColorController.h
index 3b7ab657b365da3d3677afb61c5ef49002f4924f..e00b713fa834d49e3de5a7df2cbb966bc901c300 100644
--- a/obj/NiMaterialColorController.h
+++ b/obj/NiMaterialColorController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSingleInterpolatorController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPosData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiMaterialColorController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_MATERIAL_COLOR_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiMaterialProperty.cpp b/obj/NiMaterialProperty.cpp
index 623e9b30b53b1170f6fa27ff77ec3a9bd3462edd..c01ecb56978c6deaca3fbff20840ac11e9ccb758 100644
--- a/obj/NiMaterialProperty.cpp
+++ b/obj/NiMaterialProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiMaterialProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiMaterialProperty::TYPE("NiMaterialProperty", &NI_MATERIAL_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiMaterialProperty.h b/obj/NiMaterialProperty.h
index 1b4b7af183f353f88144339fbda212097e407ace..c838cbb9b0fb3991edf6f9fac1c7d049833606b6 100644
--- a/obj/NiMaterialProperty.h
+++ b/obj/NiMaterialProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIMATERIALPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiMaterialProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -55,6 +57,8 @@ public:
 
 protected:
 	NI_MATERIAL_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiMeshPSysData.cpp b/obj/NiMeshPSysData.cpp
index cd0989f26dd974f30c404bbc0cbd0adcb8c4a698..002d9c9a0c624c33d0a898c224eb06e7b22305a4 100644
--- a/obj/NiMeshPSysData.cpp
+++ b/obj/NiMeshPSysData.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiMeshPSysData.h"
 #include "NiPSysModifier.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiMeshPSysData::TYPE("NiMeshPSysData", &NI_MESH_P_SYS_DATA_PARENT::TypeConst() );
diff --git a/obj/NiMeshPSysData.h b/obj/NiMeshPSysData.h
index 551da2bf72824adf98989a22bf0f56e3d4feecbd..4fd87756c328d57f429e865a854d8ed2ae02d941 100644
--- a/obj/NiMeshPSysData.h
+++ b/obj/NiMeshPSysData.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "APSysData.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPSysModifier;
 class NiNode;
 
@@ -26,7 +29,7 @@ public:
 	~NiMeshPSysData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_MESH_P_SYS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiMeshParticleSystem.cpp b/obj/NiMeshParticleSystem.cpp
index 00f0f9e76a464538545be03596f4375538ce8a69..115e67d507a481a335c4b6d6b953bbee6ac3e949 100644
--- a/obj/NiMeshParticleSystem.cpp
+++ b/obj/NiMeshParticleSystem.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiMeshParticleSystem.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiMeshParticleSystem::TYPE("NiMeshParticleSystem", &NI_MESH_PARTICLE_SYSTEM_PARENT::TypeConst() );
diff --git a/obj/NiMeshParticleSystem.h b/obj/NiMeshParticleSystem.h
index b0137becf6d2da2ab084a86344c921beb56bd538..2d45765cf7c3909f1f27bff3a8cb531e2a45e213 100644
--- a/obj/NiMeshParticleSystem.h
+++ b/obj/NiMeshParticleSystem.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIMESHPARTICLESYSTEM_H_
 
 #include "NiParticleSystem.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiMeshParticleSystem();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_MESH_PARTICLE_SYSTEM_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiMorphData.cpp b/obj/NiMorphData.cpp
index df1d75a70895ccbfcb6368337f291972e554227b..e675e7223d97675e0e295ab115fea08c81dff8c3 100644
--- a/obj/NiMorphData.cpp
+++ b/obj/NiMorphData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiMorphData.h"
 #include "../gen/Morph.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiMorphData::TYPE("NiMorphData", &NI_MORPH_DATA_PARENT::TypeConst() );
diff --git a/obj/NiMorphData.h b/obj/NiMorphData.h
index 0bde0a6aabfc2f768c2cc5771759833eca922dce..b013db158962caf68b6b6a703d53a902c96b5c6d 100644
--- a/obj/NiMorphData.h
+++ b/obj/NiMorphData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiObject.h"
 // Include structures
 #include "../gen/Morph.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -100,6 +101,8 @@ public:
 
 protected:
 	NI_MORPH_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiMultiTargetTransformController.cpp b/obj/NiMultiTargetTransformController.cpp
index c0137b438d983f869e5bf1329b37302b7219d2d5..81aa0f08986a3ee765bb149760c5de4d0f48a5ab 100644
--- a/obj/NiMultiTargetTransformController.cpp
+++ b/obj/NiMultiTargetTransformController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiMultiTargetTransformController.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiMultiTargetTransformController::TYPE("NiMultiTargetTransformController", &NI_MULTI_TARGET_TRANSFORM_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiMultiTargetTransformController.h b/obj/NiMultiTargetTransformController.h
index 9333733f8da196e0544d4fd19be311a3baba9f8a..413f7e4659d8f61eefd185c0d3f6ffa842140fb6 100644
--- a/obj/NiMultiTargetTransformController.h
+++ b/obj/NiMultiTargetTransformController.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIMULTITARGETTRANSFORMCONTROLLER_H_
 
 #include "NiTimeController.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiNode;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~NiMultiTargetTransformController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_MULTI_TARGET_TRANSFORM_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiNode.cpp b/obj/NiNode.cpp
index 211b765a2ff71425e001d271c9e216302760b80c..52bf1ca4d5ca4aa3adcbac89241523ef6247a956 100644
--- a/obj/NiNode.cpp
+++ b/obj/NiNode.cpp
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiSkinInstance.h"
 #include "NiSkinData.h"
 #include "NiTriBasedGeom.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiNode::TYPE("NiNode", &NI_NODE_PARENT::TypeConst() );
@@ -56,7 +57,7 @@ const Type & NiNode::GetType() const {
 	return TYPE;
 };
 
-void NiNode::AddChild( Ref<NiAVObject> & obj ) {
+void NiNode::AddChild( Ref<NiAVObject> obj ) {
 	if ( obj->GetParent() != NULL ) {
 		throw runtime_error( "You have attempted to add a child to a NiNode which already is the child of another NiNode." );
 	}
@@ -92,6 +93,35 @@ vector< Ref<NiAVObject> > NiNode::GetChildren() const {
 	return children;
 }
 
+
+void NiNode::AddEffect( Ref<NiDynamicEffect> obj ) {
+   obj->SetParent( this );
+   effects.push_back( obj );
+}
+
+void NiNode::RemoveEffect( Ref<NiDynamicEffect> obj ) {
+   //Search Effect list for the one to remove
+   for ( vector< NiDynamicEffectRef >::iterator it = effects.begin(); it != effects.end(); ) {
+      if ( *it == obj ) {
+         (*it)->SetParent(NULL);
+         it = effects.erase( it );
+      } else {
+         ++it;
+      }
+   }
+}
+
+void NiNode::ClearEffects() {
+   for ( vector< NiDynamicEffectRef >::iterator it = effects.begin(); it != effects.end(); ++it) {
+      if (*it) (*it)->SetParent(NULL);
+   }
+   effects.clear();
+}
+
+vector< Ref<NiDynamicEffect> > NiNode::GetEffects() const {
+   return effects;
+}
+
 bool NiNode::IsSkeletonRoot() const {
 	return ( skins.size() > 0 );
 }
diff --git a/obj/NiNode.h b/obj/NiNode.h
index f599717be72df734d8f0b0bda5e33d09042de44d..99f9624b7f496b920c3ccd25a97cd69dc1477969 100644
--- a/obj/NiNode.h
+++ b/obj/NiNode.h
@@ -6,6 +6,10 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAVObject.h"
 
+// Include structures
+#include "../Ref.h"
+namespace NifLib {
+
 // Forward define of referenced blocks
 class NiAVObject;
 class NiDynamicEffect;
@@ -37,10 +41,21 @@ public:
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
 
-	void AddChild( Ref<NiAVObject> & obj );
+	void AddChild( Ref<NiAVObject> obj );
 	void RemoveChild( Ref<NiAVObject> obj );
 	void ClearChildren();
 	vector< Ref<NiAVObject> > GetChildren() const;
+#ifdef USE_NIFLIB_TEMPLATE_HELPERS
+   template <typename ChildEquivalence>
+   inline void SortChildren(ChildEquivalence pred) {
+      std::stable_sort(children.begin(), children.end(), pred);
+   }
+#endif
+
+   void AddEffect( Ref<NiDynamicEffect> effect );
+   void RemoveEffect( Ref<NiDynamicEffect> effect );
+   void ClearEffects();
+   vector< Ref<NiDynamicEffect> > GetEffects() const;
 
 	/*! Checks if this node has any skins attached. */
 	bool IsSkeletonRoot() const;
@@ -74,6 +89,8 @@ private:
 protected:
 	list<NiSkinInstance*> skins;
 	NI_NODE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiObject.cpp b/obj/NiObject.cpp
index 48659806812937f57c846d2af642cc699629e70f..69d39436684b101ca3efb57f59044a4a17d8836e 100644
--- a/obj/NiObject.cpp
+++ b/obj/NiObject.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiObject::TYPE("NiObject", NULL );
diff --git a/obj/NiObject.h b/obj/NiObject.h
index cc5dd7271e68069ec42ac3e9690a31162417c09a..6413557c0f50c88ff307540c92e39484d3a3d5d2 100644
--- a/obj/NiObject.h
+++ b/obj/NiObject.h
@@ -16,6 +16,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../Ref.h"
 #include "../Type.h"
 #include "../gen/obj_defines.h"
+namespace NifLib {
 
 using namespace std;
 
@@ -143,6 +144,7 @@ private:
 	mutable unsigned int _ref_count;
 	list<NiObject*> _cross_refs;
 	static unsigned int objectsInMemory;
+	STANDARD_INTERNAL_METHODS
 };
 
 
@@ -173,8 +175,23 @@ template <class T> Ref<const T> DynamicCast( const NiObject * object ) {
 		return NULL;
 	}
 }
-
 #ifdef USE_NIFLIB_TEMPLATE_HELPERS
+template <typename T, typename U> Ref<T> StaticCast( Ref<U>& object ) {
+   return object;
+}
+
+template <typename T, typename U> Ref<T> DynamicCast( Ref<U>& object ) {
+   return object;
+}
+
+template <typename T, typename U> Ref<T> StaticCast( const Ref<U>& object ) {
+   return Ref<T>(object);
+}
+
+template <typename T, typename U> Ref<T> DynamicCast( const Ref<U>& object ) {
+   return Ref<T>(object);
+}
+
 /*!
  * Dynamically cast from a collection of objects to another collection
  * \param objs A collection of object references to be dynamically casted to the specified type.
@@ -205,5 +222,5 @@ inline list<Ref<U> > DynamicCast( list<Ref<T> > const & objs ) {
    return retval;
 }
 #endif
-
+}
 #endif
diff --git a/obj/NiObjectNET.cpp b/obj/NiObjectNET.cpp
index 8be3453a3090c2ed5bbb034dd7796301990df818..15e2555c32ec523acd9057b5d7ac2a7cdc34dbdd 100644
--- a/obj/NiObjectNET.cpp
+++ b/obj/NiObjectNET.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiObjectNET.h"
 #include "NiExtraData.h"
 #include "NiTimeController.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiObjectNET::TYPE("NiObjectNET", &NI_OBJECT_N_E_T_PARENT::TypeConst() );
diff --git a/obj/NiObjectNET.h b/obj/NiObjectNET.h
index 09206c0f43709627bf0f62dabd9f19bf4d6b2f56..dfafc40e3ea4488bf0e72aeaf238deeacc555e15 100644
--- a/obj/NiObjectNET.h
+++ b/obj/NiObjectNET.h
@@ -4,12 +4,16 @@ All rights reserved.  Please see niflib.h for licence. */
 #ifndef _NIOBJECTNET_H_
 #define _NIOBJECTNET_H_
 
-// Forward defines
+#include "NiObject.h"
+
+#include NI_OBJECT_N_E_T_INCLUDE
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiExtraData;
 class NiTimeController;
 
 #include "../gen/obj_defines.h"
-#include NI_OBJECT_N_E_T_INCLUDE
 
 class NiObjectNET;
 class NiExtraData;
@@ -58,5 +62,8 @@ public:
 	//TODO: pointer to first NiTimeController type.  Need functions to add/remove.
 private:
 	NI_OBJECT_N_E_T_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
+
+}
 #endif
diff --git a/obj/NiPSysAgeDeathModifier.cpp b/obj/NiPSysAgeDeathModifier.cpp
index 4351c1693fee7b247010acdbd90087a7f3e1a0c2..c2b9b55865e938477beaf3a8536885f8373665e2 100644
--- a/obj/NiPSysAgeDeathModifier.cpp
+++ b/obj/NiPSysAgeDeathModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysAgeDeathModifier.h"
 #include "NiPSysSpawnModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysAgeDeathModifier::TYPE("NiPSysAgeDeathModifier", &NI_P_SYS_AGE_DEATH_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysAgeDeathModifier.h b/obj/NiPSysAgeDeathModifier.h
index 64308e83bc5e73a23e71bf17c8cdba59a5206769..f3c8943703c3010730624c823026f5ff72d3bfdc 100644
--- a/obj/NiPSysAgeDeathModifier.h
+++ b/obj/NiPSysAgeDeathModifier.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysModifier.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPSysSpawnModifier;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiPSysAgeDeathModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_AGE_DEATH_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysBombModifier.cpp b/obj/NiPSysBombModifier.cpp
index f44de713e3685db8f4c613785f5c11bf209f498c..e7c9a185a041583ad731bba08018fd2eec2ee8e0 100644
--- a/obj/NiPSysBombModifier.cpp
+++ b/obj/NiPSysBombModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysBombModifier.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysBombModifier::TYPE("NiPSysBombModifier", &NI_P_SYS_BOMB_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysBombModifier.h b/obj/NiPSysBombModifier.h
index 5842f571173a3f7f772be339e8d5c16891cfa078..621c53bfaea83230963fa5f465cb8494982fea88 100644
--- a/obj/NiPSysBombModifier.h
+++ b/obj/NiPSysBombModifier.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSBOMBMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiNode;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~NiPSysBombModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_BOMB_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysBoundUpdateModifier.cpp b/obj/NiPSysBoundUpdateModifier.cpp
index d46becc58bad110921fdb10e9440e52346339898..ec05cc31f4e89f4982acc285c165d8d47d85dffb 100644
--- a/obj/NiPSysBoundUpdateModifier.cpp
+++ b/obj/NiPSysBoundUpdateModifier.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysBoundUpdateModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysBoundUpdateModifier::TYPE("NiPSysBoundUpdateModifier", &NI_P_SYS_BOUND_UPDATE_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysBoundUpdateModifier.h b/obj/NiPSysBoundUpdateModifier.h
index 2ba34993c8f5d60cda7057e9ba34f2c6995a7f62..d0562ff2f83da3b681efe6d8a47442ec6e762ab7 100644
--- a/obj/NiPSysBoundUpdateModifier.h
+++ b/obj/NiPSysBoundUpdateModifier.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSBOUNDUPDATEMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysBoundUpdateModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_BOUND_UPDATE_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysBoxEmitter.cpp b/obj/NiPSysBoxEmitter.cpp
index c55085c444046ef111432dc8f524e7252c684f0c..bca9e8d92292c63a116b974bb74b9b5500f00dd5 100644
--- a/obj/NiPSysBoxEmitter.cpp
+++ b/obj/NiPSysBoxEmitter.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysBoxEmitter.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysBoxEmitter::TYPE("NiPSysBoxEmitter", &NI_P_SYS_BOX_EMITTER_PARENT::TypeConst() );
diff --git a/obj/NiPSysBoxEmitter.h b/obj/NiPSysBoxEmitter.h
index 20a8a9e92e9868a77948fecc1a164bb014cf7f62..48a351425c1601f05c5e7e57007f29b060b4ff16 100644
--- a/obj/NiPSysBoxEmitter.h
+++ b/obj/NiPSysBoxEmitter.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSBOXEMITTER_H_
 
 #include "NiPSysVolumeEmitter.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysBoxEmitter();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_BOX_EMITTER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysColliderManager.cpp b/obj/NiPSysColliderManager.cpp
index a387963267ca1508e941c74e395682c58e36e674..d5f4d2b5144b475ab03e20c72dbe5c2029f31806 100644
--- a/obj/NiPSysColliderManager.cpp
+++ b/obj/NiPSysColliderManager.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysColliderManager.h"
 #include "NiPSysPlanarCollider.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysColliderManager::TYPE("NiPSysColliderManager", &NI_P_SYS_COLLIDER_MANAGER_PARENT::TypeConst() );
diff --git a/obj/NiPSysColliderManager.h b/obj/NiPSysColliderManager.h
index b0e42291f6ea489dc62352106b6b366fe3a98f26..eb47897e1c9f0dacf2d2119b286bddb72043bc2e 100644
--- a/obj/NiPSysColliderManager.h
+++ b/obj/NiPSysColliderManager.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysModifier.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPSysPlanarCollider;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiPSysColliderManager();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_COLLIDER_MANAGER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysColorModifier.cpp b/obj/NiPSysColorModifier.cpp
index 92f80f33e849ac80e7b4cb2947a98f4189447f87..7b23d476fb3e1bf0ae58b49a9a5834c4ee36819f 100644
--- a/obj/NiPSysColorModifier.cpp
+++ b/obj/NiPSysColorModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysColorModifier.h"
 #include "NiColorData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysColorModifier::TYPE("NiPSysColorModifier", &NI_P_SYS_COLOR_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysColorModifier.h b/obj/NiPSysColorModifier.h
index 3c1aff6d0572e67afd9c5e63d8ad1bbc5c37a8c5..f619645f09314c728a20b4bf19b0d8d94d7455c9 100644
--- a/obj/NiPSysColorModifier.h
+++ b/obj/NiPSysColorModifier.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysModifier.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiColorData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiPSysColorModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_COLOR_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysCylinderEmitter.cpp b/obj/NiPSysCylinderEmitter.cpp
index 2008cb8fdbb50302047f961027fbd4dc462de25e..9e20b5182f2d55b67a809271e37d77f0416a9358 100644
--- a/obj/NiPSysCylinderEmitter.cpp
+++ b/obj/NiPSysCylinderEmitter.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysCylinderEmitter.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysCylinderEmitter::TYPE("NiPSysCylinderEmitter", &NI_P_SYS_CYLINDER_EMITTER_PARENT::TypeConst() );
diff --git a/obj/NiPSysCylinderEmitter.h b/obj/NiPSysCylinderEmitter.h
index b59b1e7bfcd27ffaef2f00465e374f1054146565..03bbc5d9495be7923e2554a002f13eda5ce622a1 100644
--- a/obj/NiPSysCylinderEmitter.h
+++ b/obj/NiPSysCylinderEmitter.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSCYLINDEREMITTER_H_
 
 #include "NiPSysVolumeEmitter.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysCylinderEmitter();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_CYLINDER_EMITTER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysData.cpp b/obj/NiPSysData.cpp
index 2052a34f5d80e110c8a2d16708528159348d132f..326e074cabde3c53ed59f872b061109710379b44 100644
--- a/obj/NiPSysData.cpp
+++ b/obj/NiPSysData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysData::TYPE("NiPSysData", &NI_P_SYS_DATA_PARENT::TypeConst() );
diff --git a/obj/NiPSysData.h b/obj/NiPSysData.h
index 71e9509d6ea8accaaab5ba615cf3d7532f99128e..e6baeaa1e6667c00e9bc006fc7f8f66fa58e6ad3 100644
--- a/obj/NiPSysData.h
+++ b/obj/NiPSysData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSDATA_H_
 
 #include "APSysData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysDragModifier.cpp b/obj/NiPSysDragModifier.cpp
index 8a9ca149166f6c2fbe6a9932b6f775b0dcce7f22..d129a689c48d4c7bb248d9143ecb97c09fef78e8 100644
--- a/obj/NiPSysDragModifier.cpp
+++ b/obj/NiPSysDragModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysDragModifier.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysDragModifier::TYPE("NiPSysDragModifier", &NI_P_SYS_DRAG_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysDragModifier.h b/obj/NiPSysDragModifier.h
index e1915e4bebf3bf62ca6f858447964a1216b1909a..bf879af26a7075d26031de89fd4a0635c9c3e165 100644
--- a/obj/NiPSysDragModifier.h
+++ b/obj/NiPSysDragModifier.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSDRAGMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiObject;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~NiPSysDragModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_DRAG_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitter.cpp b/obj/NiPSysEmitter.cpp
index b8818fa160dae09bccce509d5174dc2880bd3536..48eb2f38451d1d9db26f280ad4c3ca89bb81b124 100644
--- a/obj/NiPSysEmitter.cpp
+++ b/obj/NiPSysEmitter.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitter.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitter::TYPE("NiPSysEmitter", &NI_P_SYS_EMITTER_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitter.h b/obj/NiPSysEmitter.h
index 1a92104162217d828c3058d631987f881ac83cb7..704f364259251ecdef81a0bf154dd7f7ec58b4e0 100644
--- a/obj/NiPSysEmitter.h
+++ b/obj/NiPSysEmitter.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSEMITTER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysEmitter();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitterCtlr.cpp b/obj/NiPSysEmitterCtlr.cpp
index ba46280f94df886553c6e13f70b14b7e3e617c0b..a635746f2499f0e95a434843c2f4d6857578fa6a 100644
--- a/obj/NiPSysEmitterCtlr.cpp
+++ b/obj/NiPSysEmitterCtlr.cpp
@@ -2,8 +2,9 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitterCtlr.h"
-#include "NiInterpolator.h"
 #include "NiPSysEmitterCtlrData.h"
+#include "NiInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitterCtlr::TYPE("NiPSysEmitterCtlr", &NI_P_SYS_EMITTER_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitterCtlr.h b/obj/NiPSysEmitterCtlr.h
index d7943942c80a860d060ed348d1e27e6d5e241795..138d71a36a0ea7da9939c31ef5656a3eb96fabf2 100644
--- a/obj/NiPSysEmitterCtlr.h
+++ b/obj/NiPSysEmitterCtlr.h
@@ -6,14 +6,17 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "APSysCtlr.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
+class NiPSysEmitterCtlrData;
 class NiInterpolator;
 
 #include "../gen/obj_defines.h"
 
 class NiPSysEmitterCtlr;
-class NiPSysEmitterCtlrData;
 typedef Ref<NiPSysEmitterCtlr> NiPSysEmitterCtlrRef;
 
 /*!
@@ -26,7 +29,7 @@ public:
 	~NiPSysEmitterCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitterCtlrData.cpp b/obj/NiPSysEmitterCtlrData.cpp
index 159a0a049a8c7c2c5a71a7bfb20d83dfebd02a15..97c9d948433c0202421dfa21f640710bddf7a7a5 100644
--- a/obj/NiPSysEmitterCtlrData.cpp
+++ b/obj/NiPSysEmitterCtlrData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitterCtlrData.h"
 #include "../gen/KeyGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitterCtlrData::TYPE("NiPSysEmitterCtlrData", &NI_P_SYS_EMITTER_CTLR_DATA_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitterCtlrData.h b/obj/NiPSysEmitterCtlrData.h
index f74a3aace4c2248cc6bcb2cb3e8cf23eebbeae07..5497e2e3e16ffdc6eaeeeadf6969861330473610 100644
--- a/obj/NiPSysEmitterCtlrData.h
+++ b/obj/NiPSysEmitterCtlrData.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSEMITTERCTLRDATA_H_
 
 #include "NiObject.h"
+
 // Include structures
 #include "../gen/KeyGroup.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +26,7 @@ public:
 	~NiPSysEmitterCtlrData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -32,8 +35,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_CTLR_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitterDeclinationCtlr.cpp b/obj/NiPSysEmitterDeclinationCtlr.cpp
index 7f66ed79320c6a752930558669308b53808ccf51..022fc68096bb94c92fcfcd40787e0c8fb082b984 100644
--- a/obj/NiPSysEmitterDeclinationCtlr.cpp
+++ b/obj/NiPSysEmitterDeclinationCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitterDeclinationCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitterDeclinationCtlr::TYPE("NiPSysEmitterDeclinationCtlr", &NI_P_SYS_EMITTER_DECLINATION_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitterDeclinationCtlr.h b/obj/NiPSysEmitterDeclinationCtlr.h
index 5bae5ecdd1552a12b6bc34d5dfba80ba90f38075..d69a41bd41b8e4ac2abce48c4e5371ad234cc84d 100644
--- a/obj/NiPSysEmitterDeclinationCtlr.h
+++ b/obj/NiPSysEmitterDeclinationCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSEMITTERDECLINATIONCTLR_H_
 
 #include "APSysCtlr.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysEmitterDeclinationCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_DECLINATION_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitterDeclinationVarCtlr.cpp b/obj/NiPSysEmitterDeclinationVarCtlr.cpp
index 43e64a7af2812457853200ce145a49f8c2391e86..5fb5b46db9943fc974c3d4faa30f7e204a9d52bb 100644
--- a/obj/NiPSysEmitterDeclinationVarCtlr.cpp
+++ b/obj/NiPSysEmitterDeclinationVarCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitterDeclinationVarCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitterDeclinationVarCtlr::TYPE("NiPSysEmitterDeclinationVarCtlr", &NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitterDeclinationVarCtlr.h b/obj/NiPSysEmitterDeclinationVarCtlr.h
index 4493327cdf408b138dccbce0a753c6272da13a6e..0eb067334a713f03af6083bd563a4e331271cb28 100644
--- a/obj/NiPSysEmitterDeclinationVarCtlr.h
+++ b/obj/NiPSysEmitterDeclinationVarCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSEMITTERDECLINATIONVARCTLR_H_
 
 #include "APSysCtlr.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysEmitterDeclinationVarCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_DECLINATION_VAR_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitterInitialRadiusCtlr.cpp b/obj/NiPSysEmitterInitialRadiusCtlr.cpp
index 487aa1829cb312d9b00cfeff6026b3a4a8a43111..30b2bfd3e4a552e332cf0476ecde5b735ac7c712 100644
--- a/obj/NiPSysEmitterInitialRadiusCtlr.cpp
+++ b/obj/NiPSysEmitterInitialRadiusCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitterInitialRadiusCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitterInitialRadiusCtlr::TYPE("NiPSysEmitterInitialRadiusCtlr", &NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitterInitialRadiusCtlr.h b/obj/NiPSysEmitterInitialRadiusCtlr.h
index febe1d9ab64f93d3ac179d5e676764d74dd3ada5..4d367de94db215dc76ada2adbd1db1bfa0f2b121 100644
--- a/obj/NiPSysEmitterInitialRadiusCtlr.h
+++ b/obj/NiPSysEmitterInitialRadiusCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSEMITTERINITIALRADIUSCTLR_H_
 
 #include "APSysCtlr.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysEmitterInitialRadiusCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_INITIAL_RADIUS_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitterLifeSpanCtlr.cpp b/obj/NiPSysEmitterLifeSpanCtlr.cpp
index 8e4e6f3294ad58efe3aa220e33a1f111cb68bf5f..ba9ad3ad4534c7f29dd506ce0e92375a3ce87dab 100644
--- a/obj/NiPSysEmitterLifeSpanCtlr.cpp
+++ b/obj/NiPSysEmitterLifeSpanCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitterLifeSpanCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitterLifeSpanCtlr::TYPE("NiPSysEmitterLifeSpanCtlr", &NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitterLifeSpanCtlr.h b/obj/NiPSysEmitterLifeSpanCtlr.h
index 439a98e7915726cbaf3b3b844e12a290ed63bca9..c690cf431d3a842af18eb703cf85e0f5e3e195a0 100644
--- a/obj/NiPSysEmitterLifeSpanCtlr.h
+++ b/obj/NiPSysEmitterLifeSpanCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSEMITTERLIFESPANCTLR_H_
 
 #include "APSysCtlr.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysEmitterLifeSpanCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_LIFE_SPAN_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysEmitterSpeedCtlr.cpp b/obj/NiPSysEmitterSpeedCtlr.cpp
index 635aa9c0d037bd072056d445471df73e1b6899a2..6267bf5f0bce5ca21816cf587895239d9241150d 100644
--- a/obj/NiPSysEmitterSpeedCtlr.cpp
+++ b/obj/NiPSysEmitterSpeedCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitterSpeedCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysEmitterSpeedCtlr::TYPE("NiPSysEmitterSpeedCtlr", &NI_P_SYS_EMITTER_SPEED_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysEmitterSpeedCtlr.h b/obj/NiPSysEmitterSpeedCtlr.h
index 267519129ff01c854655e49e7f52fe069cc2d8ca..8a255fe0fffa8d88990e88dc1392d8e0f4bd93e7 100644
--- a/obj/NiPSysEmitterSpeedCtlr.h
+++ b/obj/NiPSysEmitterSpeedCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSEMITTERSPEEDCTLR_H_
 
 #include "APSysCtlr.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysEmitterSpeedCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_EMITTER_SPEED_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysGravityModifier.cpp b/obj/NiPSysGravityModifier.cpp
index cc938ca5a3d51fcd0316d8646b5498eb6dfe585d..c79de006c67c6d758172a4aa85888ae0dfc98f8c 100644
--- a/obj/NiPSysGravityModifier.cpp
+++ b/obj/NiPSysGravityModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysGravityModifier.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysGravityModifier::TYPE("NiPSysGravityModifier", &NI_P_SYS_GRAVITY_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysGravityModifier.h b/obj/NiPSysGravityModifier.h
index c13daf3c161a2564bcac0f3e35178f72e61f7b0a..dbdccfebe548f8c869d552383cd2ad652158f745 100644
--- a/obj/NiPSysGravityModifier.h
+++ b/obj/NiPSysGravityModifier.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSGRAVITYMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiNode;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~NiPSysGravityModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_GRAVITY_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysGravityStrengthCtlr.cpp b/obj/NiPSysGravityStrengthCtlr.cpp
index 18b65b00372d4b85aff998f3a51a9ceabf388443..ffa1ee625e5f9aa04e4c43d18d8c20c3ab3144cc 100644
--- a/obj/NiPSysGravityStrengthCtlr.cpp
+++ b/obj/NiPSysGravityStrengthCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysGravityStrengthCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysGravityStrengthCtlr::TYPE("NiPSysGravityStrengthCtlr", &NI_P_SYS_GRAVITY_STRENGTH_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysGravityStrengthCtlr.h b/obj/NiPSysGravityStrengthCtlr.h
index d4127ffcd8d4bb50144a70d94b7da6c66e872c0d..41f7bc071e10ca94528a44639d736217986f9386 100644
--- a/obj/NiPSysGravityStrengthCtlr.h
+++ b/obj/NiPSysGravityStrengthCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSGRAVITYSTRENGTHCTLR_H_
 
 #include "APSysCtlr.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysGravityStrengthCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_GRAVITY_STRENGTH_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysGrowFadeModifier.cpp b/obj/NiPSysGrowFadeModifier.cpp
index 3c5d1e2f1628decec554322344f5671ae014927b..946a83001c1f36c59b4e834fd9d4d497ec83ac26 100644
--- a/obj/NiPSysGrowFadeModifier.cpp
+++ b/obj/NiPSysGrowFadeModifier.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysGrowFadeModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysGrowFadeModifier::TYPE("NiPSysGrowFadeModifier", &NI_P_SYS_GROW_FADE_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysGrowFadeModifier.h b/obj/NiPSysGrowFadeModifier.h
index 67980c8c16995a7ff3817e1a01542a4f61afb624..ab0ea60869bd473db4149792e4f7e801c26017f0 100644
--- a/obj/NiPSysGrowFadeModifier.h
+++ b/obj/NiPSysGrowFadeModifier.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSGROWFADEMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysGrowFadeModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_GROW_FADE_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysMeshEmitter.cpp b/obj/NiPSysMeshEmitter.cpp
index ba6bb78c21a4078e40fd58d4992e505e8a03c5b8..c374356eb60203ec545ff1f31a7532b758fa3d9c 100644
--- a/obj/NiPSysMeshEmitter.cpp
+++ b/obj/NiPSysMeshEmitter.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysMeshEmitter.h"
 #include "NiTriBasedGeom.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysMeshEmitter::TYPE("NiPSysMeshEmitter", &NI_P_SYS_MESH_EMITTER_PARENT::TypeConst() );
diff --git a/obj/NiPSysMeshEmitter.h b/obj/NiPSysMeshEmitter.h
index df438b9ae874a661486fe9b95ec0909048e104a8..ab2417e00ae89a5b98d93136804cf6e554d0a087 100644
--- a/obj/NiPSysMeshEmitter.h
+++ b/obj/NiPSysMeshEmitter.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysEmitter.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiTriBasedGeom;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiPSysMeshEmitter();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_MESH_EMITTER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysMeshUpdateModifier.cpp b/obj/NiPSysMeshUpdateModifier.cpp
index 77066072f19ebdab6ad228663f9614fd038a6842..cba516aee1170eefefbffcf1e2aeb3bdd451e57f 100644
--- a/obj/NiPSysMeshUpdateModifier.cpp
+++ b/obj/NiPSysMeshUpdateModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysMeshUpdateModifier.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysMeshUpdateModifier::TYPE("NiPSysMeshUpdateModifier", &NI_P_SYS_MESH_UPDATE_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysMeshUpdateModifier.h b/obj/NiPSysMeshUpdateModifier.h
index c4bc7a9a3c65a5503bc732df6f42459a3672d467..745035ef4aad2ac1e264bd842c55c64d8975a51f 100644
--- a/obj/NiPSysMeshUpdateModifier.h
+++ b/obj/NiPSysMeshUpdateModifier.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysModifier.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiNode;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiPSysMeshUpdateModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_MESH_UPDATE_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysModifier.cpp b/obj/NiPSysModifier.cpp
index 45c4d9544900db62124044df5e6b34d47c455000..6c904efd244e414bd6e47e33ef34c10f11876326 100644
--- a/obj/NiPSysModifier.cpp
+++ b/obj/NiPSysModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysModifier.h"
 #include "NiParticleSystem.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysModifier::TYPE("NiPSysModifier", &NI_P_SYS_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysModifier.h b/obj/NiPSysModifier.h
index c1ac55585821e0ea0dbd5fb9d8d4bca6fe3ed0fb..e79c59c0f9209290d19c5b2555783f16626dc421 100644
--- a/obj/NiPSysModifier.h
+++ b/obj/NiPSysModifier.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSMODIFIER_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiParticleSystem;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~NiPSysModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysModifierActiveCtlr.cpp b/obj/NiPSysModifierActiveCtlr.cpp
index b9eb65b2d1635b0b5b1e2cf6c78d5d7f72331a19..eb95b71bfa562ee4a074e6df794fb2e653ee3aea 100644
--- a/obj/NiPSysModifierActiveCtlr.cpp
+++ b/obj/NiPSysModifierActiveCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysModifierActiveCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysModifierActiveCtlr::TYPE("NiPSysModifierActiveCtlr", &NI_P_SYS_MODIFIER_ACTIVE_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysModifierActiveCtlr.h b/obj/NiPSysModifierActiveCtlr.h
index 533be8788412dd086963711ce061be153720549b..fd81d68676e907ed4fbe7c19c9c2041f69c833dd 100644
--- a/obj/NiPSysModifierActiveCtlr.h
+++ b/obj/NiPSysModifierActiveCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSMODIFIERACTIVECTLR_H_
 
 #include "APSysCtlr.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysModifierActiveCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_MODIFIER_ACTIVE_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysPlanarCollider.cpp b/obj/NiPSysPlanarCollider.cpp
index df408a016a59c3474a1d817729ff24b9d32896ab..f252d0651727a2dc62a704014205e1f36fd2800d 100644
--- a/obj/NiPSysPlanarCollider.cpp
+++ b/obj/NiPSysPlanarCollider.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiPSysSpawnModifier.h"
 #include "NiObject.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysPlanarCollider::TYPE("NiPSysPlanarCollider", &NI_P_SYS_PLANAR_COLLIDER_PARENT::TypeConst() );
diff --git a/obj/NiPSysPlanarCollider.h b/obj/NiPSysPlanarCollider.h
index 24e9c7019acdc2318c14835a98140178a19382ad..717ea3474140b06595478e52234a13f508d4db58 100644
--- a/obj/NiPSysPlanarCollider.h
+++ b/obj/NiPSysPlanarCollider.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPSysSpawnModifier;
 class NiObject;
 class NiNode;
@@ -27,7 +30,7 @@ public:
 	~NiPSysPlanarCollider();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,8 +39,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_PLANAR_COLLIDER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysPositionModifier.cpp b/obj/NiPSysPositionModifier.cpp
index 376b5084a2fb1df9c04f61124856d35696ab612d..a1d5fc3123ef46c4967fe11a76b4031ba6917fa0 100644
--- a/obj/NiPSysPositionModifier.cpp
+++ b/obj/NiPSysPositionModifier.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysPositionModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysPositionModifier::TYPE("NiPSysPositionModifier", &NI_P_SYS_POSITION_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysPositionModifier.h b/obj/NiPSysPositionModifier.h
index 6b91842d1a623abc6b3b0d932e2d77996b9426ab..863f4b0464325c41c7269cc4963232675b464023 100644
--- a/obj/NiPSysPositionModifier.h
+++ b/obj/NiPSysPositionModifier.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSPOSITIONMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysPositionModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_POSITION_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysResetOnLoopCtlr.cpp b/obj/NiPSysResetOnLoopCtlr.cpp
index 8f084457df4cc9df9444cbcb35d1b15d263aa46f..586fd82ae426bd99ecc993fa6f9d933912e620c4 100644
--- a/obj/NiPSysResetOnLoopCtlr.cpp
+++ b/obj/NiPSysResetOnLoopCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysResetOnLoopCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysResetOnLoopCtlr::TYPE("NiPSysResetOnLoopCtlr", &NI_P_SYS_RESET_ON_LOOP_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysResetOnLoopCtlr.h b/obj/NiPSysResetOnLoopCtlr.h
index 4ab047ceef27bc89f3c5cf2ffe35613bfed80ea5..7538fe0d19489f05ee8f7f3d979c682ff8683dbb 100644
--- a/obj/NiPSysResetOnLoopCtlr.h
+++ b/obj/NiPSysResetOnLoopCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSRESETONLOOPCTLR_H_
 
 #include "NiTimeController.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysResetOnLoopCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_RESET_ON_LOOP_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysRotationModifier.cpp b/obj/NiPSysRotationModifier.cpp
index b1de6ac3b918547ffe6788fc42501bcd3a2e3ef9..9848b2cc1de45c2dfb8729951824ffa3dd9458dd 100644
--- a/obj/NiPSysRotationModifier.cpp
+++ b/obj/NiPSysRotationModifier.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysRotationModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysRotationModifier::TYPE("NiPSysRotationModifier", &NI_P_SYS_ROTATION_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysRotationModifier.h b/obj/NiPSysRotationModifier.h
index 5e1c1c4f70a7d41c40dc1cea0439fb0a5a91e3ea..2cfc3ce4390623f28aed8e554ea698cfae8ed25d 100644
--- a/obj/NiPSysRotationModifier.h
+++ b/obj/NiPSysRotationModifier.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSROTATIONMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysRotationModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_ROTATION_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysSpawnModifier.cpp b/obj/NiPSysSpawnModifier.cpp
index b1eaa069d20f22e567b664fd00eabfd498d2a894..55ded02d5b18acbe0c9a5992f931174796cff27f 100644
--- a/obj/NiPSysSpawnModifier.cpp
+++ b/obj/NiPSysSpawnModifier.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysSpawnModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysSpawnModifier::TYPE("NiPSysSpawnModifier", &NI_P_SYS_SPAWN_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiPSysSpawnModifier.h b/obj/NiPSysSpawnModifier.h
index fd2fd229a7d503f224fea1b36d4f81ec7dffdcdc..13e0c1a021ebae41770194408fa892b739d8c350 100644
--- a/obj/NiPSysSpawnModifier.h
+++ b/obj/NiPSysSpawnModifier.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSSPAWNMODIFIER_H_
 
 #include "NiPSysModifier.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysSpawnModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_SPAWN_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysSphereEmitter.cpp b/obj/NiPSysSphereEmitter.cpp
index 345bdb64222a5799c2312039327f9553c6b17a8d..64f7843b2715cd2bdca9bbcd06cb443084184316 100644
--- a/obj/NiPSysSphereEmitter.cpp
+++ b/obj/NiPSysSphereEmitter.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysSphereEmitter.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysSphereEmitter::TYPE("NiPSysSphereEmitter", &NI_P_SYS_SPHERE_EMITTER_PARENT::TypeConst() );
diff --git a/obj/NiPSysSphereEmitter.h b/obj/NiPSysSphereEmitter.h
index 89a7ad9b698a3624e96c2dccf0bc88b6522bfe4d..a3515f80d2a3dce7f890ef9ff07788abb612e1c5 100644
--- a/obj/NiPSysSphereEmitter.h
+++ b/obj/NiPSysSphereEmitter.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSSPHEREEMITTER_H_
 
 #include "NiPSysVolumeEmitter.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPSysSphereEmitter();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_SPHERE_EMITTER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysUpdateCtlr.cpp b/obj/NiPSysUpdateCtlr.cpp
index 5687692dc4c7c116a73d61ee4c11edad72690deb..bdc84fc08b197a41d50449bbed2780008f3c7473 100644
--- a/obj/NiPSysUpdateCtlr.cpp
+++ b/obj/NiPSysUpdateCtlr.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysUpdateCtlr.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysUpdateCtlr::TYPE("NiPSysUpdateCtlr", &NI_P_SYS_UPDATE_CTLR_PARENT::TypeConst() );
diff --git a/obj/NiPSysUpdateCtlr.h b/obj/NiPSysUpdateCtlr.h
index 1e208b7bb2b09df2f5a8085c0066989c52d055e6..34a3e23f27f3420ce458cb0f2b7bd3446e0bac30 100644
--- a/obj/NiPSysUpdateCtlr.h
+++ b/obj/NiPSysUpdateCtlr.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSUPDATECTLR_H_
 
 #include "NiTimeController.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPSysUpdateCtlr();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_UPDATE_CTLR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPSysVolumeEmitter.cpp b/obj/NiPSysVolumeEmitter.cpp
index 243e299dce2aeb70c6ff200b707992dd948bf107..d3b3e5ad161dd37de3537df618a210a3b7cf3f1a 100644
--- a/obj/NiPSysVolumeEmitter.cpp
+++ b/obj/NiPSysVolumeEmitter.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPSysVolumeEmitter.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPSysVolumeEmitter::TYPE("NiPSysVolumeEmitter", &NI_P_SYS_VOLUME_EMITTER_PARENT::TypeConst() );
diff --git a/obj/NiPSysVolumeEmitter.h b/obj/NiPSysVolumeEmitter.h
index aeeac7bc0e5b678233511903e55190e95018a16d..4382777fb93ecfd7be6c73ddcb338f34289147e6 100644
--- a/obj/NiPSysVolumeEmitter.h
+++ b/obj/NiPSysVolumeEmitter.h
@@ -5,9 +5,9 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPSYSVOLUMEEMITTER_H_
 
 #include "NiPSysEmitter.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiNode;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +25,7 @@ public:
 	~NiPSysVolumeEmitter();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_P_SYS_VOLUME_EMITTER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPalette.cpp b/obj/NiPalette.cpp
index 20135a5d8dd1a7e9b10ff79384822687f27742a4..4079598b09229809f2b291e84ba7cc3694116f44 100644
--- a/obj/NiPalette.cpp
+++ b/obj/NiPalette.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPalette.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPalette::TYPE("NiPalette", &NI_PALETTE_PARENT::TypeConst() );
diff --git a/obj/NiPalette.h b/obj/NiPalette.h
index 4a050ada53f17342219ef2dd6c4a152539c39a35..50324c4e867d381f73d366dfe517f2fe1da145d8 100644
--- a/obj/NiPalette.h
+++ b/obj/NiPalette.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPALETTE_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -44,6 +45,8 @@ public:
 	void SetPalette( const vector<Color4> & new_pal );
 protected:
 	NI_PALETTE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleBomb.cpp b/obj/NiParticleBomb.cpp
index 0b7a5a50c1d283f5c7c21138fc864c65251d2980..73820e8cf64b815eb2365a07f219958d22be6a14 100644
--- a/obj/NiParticleBomb.cpp
+++ b/obj/NiParticleBomb.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleBomb.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleBomb::TYPE("NiParticleBomb", &NI_PARTICLE_BOMB_PARENT::TypeConst() );
diff --git a/obj/NiParticleBomb.h b/obj/NiParticleBomb.h
index 85be84157933b8d24507c597d2dc38a469a856ab..9074a99a3053eb32dc7049af8ddd8d16aa51337b 100644
--- a/obj/NiParticleBomb.h
+++ b/obj/NiParticleBomb.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPARTICLEBOMB_H_
 
 #include "AParticleModifier.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiParticleBomb();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_BOMB_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleColorModifier.cpp b/obj/NiParticleColorModifier.cpp
index acf778bfb9fd036e5a8c7e8aad113943a2e305fe..110d17cecb6d3d55b83bbbff91cbce3ec203d37b 100644
--- a/obj/NiParticleColorModifier.cpp
+++ b/obj/NiParticleColorModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleColorModifier.h"
 #include "NiColorData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleColorModifier::TYPE("NiParticleColorModifier", &NI_PARTICLE_COLOR_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiParticleColorModifier.h b/obj/NiParticleColorModifier.h
index 1cf45cdf9df457aa863be29905da21ff152353c8..3e23e9baaf2ae5eca3b0e38e253e0df8da912b82 100644
--- a/obj/NiParticleColorModifier.h
+++ b/obj/NiParticleColorModifier.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "AParticleModifier.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiColorData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiParticleColorModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_COLOR_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleGrowFade.cpp b/obj/NiParticleGrowFade.cpp
index f3cae888d4d0ef230d119e6ed3a2c1d604032d35..b4fca3e5d88435e5ae121ccdecaa5b51577b6140 100644
--- a/obj/NiParticleGrowFade.cpp
+++ b/obj/NiParticleGrowFade.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleGrowFade.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleGrowFade::TYPE("NiParticleGrowFade", &NI_PARTICLE_GROW_FADE_PARENT::TypeConst() );
diff --git a/obj/NiParticleGrowFade.h b/obj/NiParticleGrowFade.h
index 7e29afe0d3ed75918839e9de8739e252ce225e1f..4de6afe98d5a11c5935cb8f3e7661c33e16447ba 100644
--- a/obj/NiParticleGrowFade.h
+++ b/obj/NiParticleGrowFade.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPARTICLEGROWFADE_H_
 
 #include "AParticleModifier.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -24,7 +26,7 @@ public:
 	~NiParticleGrowFade();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -33,8 +35,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_GROW_FADE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleMeshModifier.cpp b/obj/NiParticleMeshModifier.cpp
index 702b9544adc1169a0959d871b532a2fc4eee7f9c..75cc8d0850da3f0a2129ab8120474b499027115a 100644
--- a/obj/NiParticleMeshModifier.cpp
+++ b/obj/NiParticleMeshModifier.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleMeshModifier.h"
 #include "NiAVObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleMeshModifier::TYPE("NiParticleMeshModifier", &NI_PARTICLE_MESH_MODIFIER_PARENT::TypeConst() );
diff --git a/obj/NiParticleMeshModifier.h b/obj/NiParticleMeshModifier.h
index becc21107f9478ad8af27ef496ca5108cb12de89..3ca99fd64a67853ed68a69570a89787386bb1300 100644
--- a/obj/NiParticleMeshModifier.h
+++ b/obj/NiParticleMeshModifier.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "AParticleModifier.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiAVObject;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiParticleMeshModifier();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_MESH_MODIFIER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleMeshes.cpp b/obj/NiParticleMeshes.cpp
index a23a56068590d0980083a24c94cc7de01df77355..de488ab0e27d58a4b1366dbd9e9b6ceba71c20d2 100644
--- a/obj/NiParticleMeshes.cpp
+++ b/obj/NiParticleMeshes.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleMeshes.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleMeshes::TYPE("NiParticleMeshes", &NI_PARTICLE_MESHES_PARENT::TypeConst() );
diff --git a/obj/NiParticleMeshes.h b/obj/NiParticleMeshes.h
index 97c3d3a061609d4f3840f11319f9b5fab54c7c85..14b3b7b83ea26ac654c12f73205799e0f7cfdd28 100644
--- a/obj/NiParticleMeshes.h
+++ b/obj/NiParticleMeshes.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPARTICLEMESHES_H_
 
 #include "NiParticles.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiParticleMeshes();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_MESHES_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleMeshesData.cpp b/obj/NiParticleMeshesData.cpp
index dd96a2722fe94f88c6a7358c87ea04cfa52b5b95..96678aa24de035b913cac3d65ab0782613353743 100644
--- a/obj/NiParticleMeshesData.cpp
+++ b/obj/NiParticleMeshesData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleMeshesData.h"
 #include "NiAVObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleMeshesData::TYPE("NiParticleMeshesData", &NI_PARTICLE_MESHES_DATA_PARENT::TypeConst() );
diff --git a/obj/NiParticleMeshesData.h b/obj/NiParticleMeshesData.h
index 6779eae858b179733fdea3a14f939fa7032554c2..fb9b515443ce0cff523d1d567bb3de116283d4b9 100644
--- a/obj/NiParticleMeshesData.h
+++ b/obj/NiParticleMeshesData.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticlesData.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiAVObject;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiParticleMeshesData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_MESHES_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleRotation.cpp b/obj/NiParticleRotation.cpp
index 48e5c1ce83642e5946b03ebf81f518c470a410d5..034a2ceef5e98fcada0dc43d4b998d7a47cb5b82 100644
--- a/obj/NiParticleRotation.cpp
+++ b/obj/NiParticleRotation.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleRotation.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleRotation::TYPE("NiParticleRotation", &NI_PARTICLE_ROTATION_PARENT::TypeConst() );
diff --git a/obj/NiParticleRotation.h b/obj/NiParticleRotation.h
index 88137263b950d4801dc8c18a34e6a7a8f0fe7e9f..e280c311be3b0971340124f19da7721073390309 100644
--- a/obj/NiParticleRotation.h
+++ b/obj/NiParticleRotation.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPARTICLEROTATION_H_
 
 #include "AParticleModifier.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiParticleRotation();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_ROTATION_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleSystem.cpp b/obj/NiParticleSystem.cpp
index 26b337782cf3bce9d9d6bff1eb67b5976be73a84..cdd10a9d9042bbf3171b08a7f146b48dccdae8d0 100644
--- a/obj/NiParticleSystem.cpp
+++ b/obj/NiParticleSystem.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticleSystem.h"
 #include "NiPSysModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleSystem::TYPE("NiParticleSystem", &NI_PARTICLE_SYSTEM_PARENT::TypeConst() );
diff --git a/obj/NiParticleSystem.h b/obj/NiParticleSystem.h
index 1ffa579a1d71eff5bdc023099fdd3192fcc42ac5..2576cf01e27eb03e3314fd4748889bf732cc4dfb 100644
--- a/obj/NiParticleSystem.h
+++ b/obj/NiParticleSystem.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticles.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPSysModifier;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiParticleSystem();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLE_SYSTEM_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticleSystemController.cpp b/obj/NiParticleSystemController.cpp
index d5353a3dbb76ee5a61bbfee2d2103a4ed40e711c..79740b6c33d2c7ee8571324d19aba0baccaf3102 100644
--- a/obj/NiParticleSystemController.cpp
+++ b/obj/NiParticleSystemController.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../gen/Particle.h"
 #include "NiObject.h"
 #include "AParticleModifier.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticleSystemController::TYPE("NiParticleSystemController", &NI_PARTICLE_SYSTEM_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiParticleSystemController.h b/obj/NiParticleSystemController.h
index c84f136ee2ac362b3f86581bd0df870a778808b4..e4818a9f5d810b1e70459e45be773520fc0c2a4f 100644
--- a/obj/NiParticleSystemController.h
+++ b/obj/NiParticleSystemController.h
@@ -5,11 +5,13 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPARTICLESYSTEMCONTROLLER_H_
 
 #include "NiTimeController.h"
+
 // Include structures
+#include "../Ref.h"
 #include "../gen/Particle.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiObject;
 class AParticleModifier;
 
@@ -29,7 +31,7 @@ public:
 	~NiParticleSystemController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -41,6 +43,8 @@ public:
 	//TODO:  This controller is not a priority and it has a lot of unknown data.
 protected:
 	NI_PARTICLE_SYSTEM_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticles.cpp b/obj/NiParticles.cpp
index 7216118a28975c63f319bd7e1a7d955125ab63f2..8144df6b050086160f49dadeb4c07e5081138ea5 100644
--- a/obj/NiParticles.cpp
+++ b/obj/NiParticles.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticles.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticles::TYPE("NiParticles", &NI_PARTICLES_PARENT::TypeConst() );
diff --git a/obj/NiParticles.h b/obj/NiParticles.h
index 5cc43e0e5584796618cbbdaffe4ae54fb7b8cf7f..35c25b92da54887bb8d78da8019693ad2c264553 100644
--- a/obj/NiParticles.h
+++ b/obj/NiParticles.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPARTICLES_H_
 
 #include "NiTriBasedGeom.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiParticles();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLES_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiParticlesData.cpp b/obj/NiParticlesData.cpp
index 1dabfccd3e41cc1758eec120a0a49a80ed6efd9b..96984f072ca51965e3bf6a49f454c29223ba2287 100644
--- a/obj/NiParticlesData.cpp
+++ b/obj/NiParticlesData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiParticlesData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiParticlesData::TYPE("NiParticlesData", &NI_PARTICLES_DATA_PARENT::TypeConst() );
diff --git a/obj/NiParticlesData.h b/obj/NiParticlesData.h
index b674054c177257a943085cb1d759d5887f33495e..79eca8cc8e9e3f160fc43ebebfb584f471cf9a18 100644
--- a/obj/NiParticlesData.h
+++ b/obj/NiParticlesData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPARTICLESDATA_H_
 
 #include "NiAutoNormalParticlesData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiParticlesData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PARTICLES_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPathController.cpp b/obj/NiPathController.cpp
index 5c6dcc00e7218d2768814400500d0559ac208fb3..42a449fd908cd964855f14464e0289eee783db3f 100644
--- a/obj/NiPathController.cpp
+++ b/obj/NiPathController.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiPathController.h"
 #include "NiPosData.h"
 #include "NiFloatData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPathController::TYPE("NiPathController", &NI_PATH_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiPathController.h b/obj/NiPathController.h
index e15c76832222b9802f76fafe75bb132315a2bd50..ca11d23ca3b7763113d418f7a959c2abfa1b8910 100644
--- a/obj/NiPathController.h
+++ b/obj/NiPathController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPosData;
 class NiFloatData;
 
@@ -26,7 +29,7 @@ public:
 	~NiPathController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -44,6 +47,8 @@ public:
 	void SetPosData( const Ref<NiPosData> & n );
 protected:
 	NI_PATH_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPathInterpolator.cpp b/obj/NiPathInterpolator.cpp
index 335ea0d3d4aa95a3e17625c4594c6c26b5da3b7d..62032713067f702a0ff1dacff8e9371d4fe59aa3 100644
--- a/obj/NiPathInterpolator.cpp
+++ b/obj/NiPathInterpolator.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiPathInterpolator.h"
 #include "NiPosData.h"
 #include "NiFloatData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPathInterpolator::TYPE("NiPathInterpolator", &NI_PATH_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiPathInterpolator.h b/obj/NiPathInterpolator.h
index 846d6d5c3c7fba7da507cedc91b17c51e72f1ed2..4faa80f1a0d9a03937610d61f8191f613d4f8acd 100644
--- a/obj/NiPathInterpolator.h
+++ b/obj/NiPathInterpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiBlendInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPosData;
 class NiFloatData;
 
@@ -26,7 +29,7 @@ public:
 	~NiPathInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PATH_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPixelData.cpp b/obj/NiPixelData.cpp
index d933d58d3e9585111f8116d8c0c4204b4d2e6902..8bf1a3c601fb37cff522f42af19a5287e8632ddd 100644
--- a/obj/NiPixelData.cpp
+++ b/obj/NiPixelData.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../gen/MipMap.h"
 #include "../gen/ByteArray.h"
 #include "NiPalette.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPixelData::TYPE("NiPixelData", &NI_PIXEL_DATA_PARENT::TypeConst() );
diff --git a/obj/NiPixelData.h b/obj/NiPixelData.h
index 22f3540bdf2ebebf0020ca1d1a9781a15b773e8a..0d8b2aab90b9863907e408d66db579418fec5c9c 100644
--- a/obj/NiPixelData.h
+++ b/obj/NiPixelData.h
@@ -6,11 +6,12 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 // Include structures
+#include "../Ref.h"
 #include "../gen/MipMap.h"
 #include "../gen/ByteArray.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiPalette;
 
 #include "../gen/obj_defines.h"
@@ -79,6 +80,8 @@ public:
 
 protected:
 	NI_PIXEL_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPlanarCollider.cpp b/obj/NiPlanarCollider.cpp
index a343a70f31749a027dca63d2c74edd0093418894..f5bbc79635827f636b4f9476fd266c254539e69d 100644
--- a/obj/NiPlanarCollider.cpp
+++ b/obj/NiPlanarCollider.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPlanarCollider.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPlanarCollider::TYPE("NiPlanarCollider", &NI_PLANAR_COLLIDER_PARENT::TypeConst() );
diff --git a/obj/NiPlanarCollider.h b/obj/NiPlanarCollider.h
index be4ff5c2d856de88c3afad5b2c2e419b46f4489f..358aa2e4e3b76edd940dc8e09f3c1e8ac10e6a6a 100644
--- a/obj/NiPlanarCollider.h
+++ b/obj/NiPlanarCollider.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPLANARCOLLIDER_H_
 
 #include "AParticleModifier.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiPlanarCollider();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PLANAR_COLLIDER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPoint3Interpolator.cpp b/obj/NiPoint3Interpolator.cpp
index 83ba9d4440baf4c22ced3f188fecedf6acb17bc2..d6cd84463c924ddf170ebf21b3371dc3de8e6187 100644
--- a/obj/NiPoint3Interpolator.cpp
+++ b/obj/NiPoint3Interpolator.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPoint3Interpolator.h"
 #include "NiPosData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPoint3Interpolator::TYPE("NiPoint3Interpolator", &NI_POINT3_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiPoint3Interpolator.h b/obj/NiPoint3Interpolator.h
index 3ec2a599d525d7a346fdec2f332319c95566450b..49cc6e8b1d08bd33e642ca2efb8db53baebe6ad5 100644
--- a/obj/NiPoint3Interpolator.h
+++ b/obj/NiPoint3Interpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiPosData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiPoint3Interpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_POINT3_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPointLight.cpp b/obj/NiPointLight.cpp
index 6d0eda2700e0b69aa4ca5f25e0a8a5d43b59df4b..77390f8358746de83ae60d05f268c8e2b6ad64b8 100644
--- a/obj/NiPointLight.cpp
+++ b/obj/NiPointLight.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPointLight.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPointLight::TYPE("NiPointLight", &NI_POINT_LIGHT_PARENT::TypeConst() );
diff --git a/obj/NiPointLight.h b/obj/NiPointLight.h
index 8b400fed64a484d74beeaace5bf59816aa94e387..7941418dee579af66c9b9c78e620591ffadcccc4 100644
--- a/obj/NiPointLight.h
+++ b/obj/NiPointLight.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPOINTLIGHT_H_
 
 #include "NiLight.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiPointLight();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_POINT_LIGHT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiPosData.cpp b/obj/NiPosData.cpp
index 5296c82746eacd06ff0ebe2671c6dc7bb6a451ba..c542532d244cc011fe9e158d1389411034ca66a0 100644
--- a/obj/NiPosData.cpp
+++ b/obj/NiPosData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiPosData.h"
 #include "../gen/KeyGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiPosData::TYPE("NiPosData", &NI_POS_DATA_PARENT::TypeConst() );
diff --git a/obj/NiPosData.h b/obj/NiPosData.h
index 0eb75db88be75c244d0371052354c1e2802bb9af..800aa7138fc29e7b35610c2ec32f96019393be90 100644
--- a/obj/NiPosData.h
+++ b/obj/NiPosData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "AKeyedData.h"
 // Include structures
 #include "../gen/KeyGroup.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -59,6 +60,8 @@ public:
 
 protected:
 	NI_POS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiProperty.cpp b/obj/NiProperty.cpp
index 355432255b9db047db40fa69ecbf9e06fa309d75..3aeceb2cb45c83a8a116ca4dc47c20890a69bed2 100644
--- a/obj/NiProperty.cpp
+++ b/obj/NiProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiProperty::TYPE("NiProperty", &NI_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiProperty.h b/obj/NiProperty.h
index 456ef1a61dbf63f81f92c23f50b66c30b66f1ad8..c69a6dd32754445d7af30c7515cfcd302b55de46 100644
--- a/obj/NiProperty.h
+++ b/obj/NiProperty.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIPROPERTY_H_
 
 #include "NiObjectNET.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiRangeLODData.cpp b/obj/NiRangeLODData.cpp
index b99880964c7ee27e10b445544f072a1960a73366..6d9f9f193a1283bb0724e102374feddef692b478 100644
--- a/obj/NiRangeLODData.cpp
+++ b/obj/NiRangeLODData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiRangeLODData.h"
 #include "../gen/LODRange.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiRangeLODData::TYPE("NiRangeLODData", &NI_RANGE_L_O_D_DATA_PARENT::TypeConst() );
diff --git a/obj/NiRangeLODData.h b/obj/NiRangeLODData.h
index 358541d847910fe77e73ddd13fd0a85536ad3f08..968018801b0a7899bed599c8c3211c83f312f0a0 100644
--- a/obj/NiRangeLODData.h
+++ b/obj/NiRangeLODData.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIRANGELODDATA_H_
 
 #include "NiObject.h"
+
 // Include structures
 #include "../gen/LODRange.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +26,7 @@ public:
 	~NiRangeLODData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -32,8 +35,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_RANGE_L_O_D_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiRotatingParticles.cpp b/obj/NiRotatingParticles.cpp
index 03b8f9e06afb0ee612d4736139d4484aa54b335f..21675d2f78237674e73aed02b8d973d24858de57 100644
--- a/obj/NiRotatingParticles.cpp
+++ b/obj/NiRotatingParticles.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiRotatingParticles.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiRotatingParticles::TYPE("NiRotatingParticles", &NI_ROTATING_PARTICLES_PARENT::TypeConst() );
diff --git a/obj/NiRotatingParticles.h b/obj/NiRotatingParticles.h
index 4840b607f6a05c5aa24c2738de54fc8ec38c6bda..efaca6224e44789242148c5f8153a3ad0e3d4db8 100644
--- a/obj/NiRotatingParticles.h
+++ b/obj/NiRotatingParticles.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIROTATINGPARTICLES_H_
 
 #include "NiParticles.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiRotatingParticles();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_ROTATING_PARTICLES_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiRotatingParticlesData.cpp b/obj/NiRotatingParticlesData.cpp
index df0abf47fd4b30dd8ee885b7966ceb8ff4a3eac7..8cfe9d38758a8b570615482dc6b1c7e44cb2e6f2 100644
--- a/obj/NiRotatingParticlesData.cpp
+++ b/obj/NiRotatingParticlesData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiRotatingParticlesData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiRotatingParticlesData::TYPE("NiRotatingParticlesData", &NI_ROTATING_PARTICLES_DATA_PARENT::TypeConst() );
diff --git a/obj/NiRotatingParticlesData.h b/obj/NiRotatingParticlesData.h
index 71c4e7da120a0233caa2936361849ce5565673a9..95cec2c92c30508aad47ed6033ddcbce77eae3c9 100644
--- a/obj/NiRotatingParticlesData.h
+++ b/obj/NiRotatingParticlesData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIROTATINGPARTICLESDATA_H_
 
 #include "NiParticlesData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiRotatingParticlesData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_ROTATING_PARTICLES_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiScreenLODData.cpp b/obj/NiScreenLODData.cpp
index a1169bec1121d09bff018b4420da355d7ba13fd6..68a4a452921ca26fb43aaa2310055ab85882f6f7 100644
--- a/obj/NiScreenLODData.cpp
+++ b/obj/NiScreenLODData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiScreenLODData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiScreenLODData::TYPE("NiScreenLODData", &NI_SCREEN_L_O_D_DATA_PARENT::TypeConst() );
diff --git a/obj/NiScreenLODData.h b/obj/NiScreenLODData.h
index f246e2e5a62401da2f8a3f8d59b434d0f3da5f36..2a3153785661e83886de577e2667c7a1cc0a19c3 100644
--- a/obj/NiScreenLODData.h
+++ b/obj/NiScreenLODData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISCREENLODDATA_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiScreenLODData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_SCREEN_L_O_D_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSequenceStreamHelper.cpp b/obj/NiSequenceStreamHelper.cpp
index 81aea9bc964131e5e29385caf0437a9033c71fc4..1173625eb6d7beee3cd448ea403f7a6606af8186 100644
--- a/obj/NiSequenceStreamHelper.cpp
+++ b/obj/NiSequenceStreamHelper.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSequenceStreamHelper.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSequenceStreamHelper::TYPE("NiSequenceStreamHelper", &NI_SEQUENCE_STREAM_HELPER_PARENT::TypeConst() );
diff --git a/obj/NiSequenceStreamHelper.h b/obj/NiSequenceStreamHelper.h
index c46a1f62c5171e3026e15147808b8895cc3b7d03..bb3a1806584705062ea8ae1f2c0f157c40705146 100644
--- a/obj/NiSequenceStreamHelper.h
+++ b/obj/NiSequenceStreamHelper.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISEQUENCESTREAMHELPER_H_
 
 #include "NiObjectNET.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiSequenceStreamHelper();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_SEQUENCE_STREAM_HELPER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiShadeProperty.cpp b/obj/NiShadeProperty.cpp
index bd9f2497994edad341a82b1a55df486ddc09c96b..31daede6c43c871c1a43dffd3e7f8b9c21f2f07c 100644
--- a/obj/NiShadeProperty.cpp
+++ b/obj/NiShadeProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiShadeProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiShadeProperty::TYPE("NiShadeProperty", &NI_SHADE_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiShadeProperty.h b/obj/NiShadeProperty.h
index 0411c1e20ca3dbbeb365f284cd9dacba416cc2b5..8c88cc341b8e36793fbb9b513aa718e76c257670 100644
--- a/obj/NiShadeProperty.h
+++ b/obj/NiShadeProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISHADEPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +24,7 @@ public:
 	~NiShadeProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -37,6 +39,8 @@ public:
 
 protected:
 	NI_SHADE_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSingleInterpolatorController.cpp b/obj/NiSingleInterpolatorController.cpp
index a9853ce12ccc7a7f1ece7850470357e7a9f8998c..978acc11a9452600b86bd02e5b3ec0ff1244b904 100644
--- a/obj/NiSingleInterpolatorController.cpp
+++ b/obj/NiSingleInterpolatorController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSingleInterpolatorController.h"
 #include "NiInterpolator.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSingleInterpolatorController::TYPE("NiSingleInterpolatorController", &NI_SINGLE_INTERPOLATOR_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiSingleInterpolatorController.h b/obj/NiSingleInterpolatorController.h
index 1dd07a80d88fc781cb66bfae6a94a34b148f7b89..8b58f302fff460d7216f9ec66dbda9d3f4a2aa6f 100644
--- a/obj/NiSingleInterpolatorController.h
+++ b/obj/NiSingleInterpolatorController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiInterpolator;
 
 #include "../gen/obj_defines.h"
@@ -26,7 +29,7 @@ public:
 	~NiSingleInterpolatorController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -40,6 +43,8 @@ public:
 	void SetInterpolator( const Ref<NiInterpolator> & n );
 protected:
 	NI_SINGLE_INTERPOLATOR_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSkinData.cpp b/obj/NiSkinData.cpp
index 154330d5022e723d091234d25242dff16df9f004..c8d836cf208f373ab2a4c936a5bfb1cd1a7956e7 100644
--- a/obj/NiSkinData.cpp
+++ b/obj/NiSkinData.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../gen/SkinData.h"
 #include "../gen/SkinWeight.h"
 #include "NiSkinPartition.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSkinData::TYPE("NiSkinData", &NI_SKIN_DATA_PARENT::TypeConst() );
diff --git a/obj/NiSkinData.h b/obj/NiSkinData.h
index a09f44db12149c2527c6e37de8eda4a55659227a..617bdf456e9bca61055ae3a8c3f528d85bc6fc79 100644
--- a/obj/NiSkinData.h
+++ b/obj/NiSkinData.h
@@ -6,10 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 // Include structures
+#include "../Ref.h"
 #include "../gen/SkinData.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiSkinPartition;
 
 #include "../gen/obj_defines.h"
@@ -44,6 +45,8 @@ public:
 	vector<SkinData> GetBoneData() const;
 protected:
 	NI_SKIN_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSkinInstance.cpp b/obj/NiSkinInstance.cpp
index 6d304af6532e546ab5fc2a0b660aedd3a47f271e..d3b3ef12dda8cc5a4eface469b943945d4b3d3cb 100644
--- a/obj/NiSkinInstance.cpp
+++ b/obj/NiSkinInstance.cpp
@@ -6,6 +6,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiSkinData.h"
 #include "NiSkinPartition.h"
 #include "NiNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSkinInstance::TYPE("NiSkinInstance", &NI_SKIN_INSTANCE_PARENT::TypeConst() );
diff --git a/obj/NiSkinInstance.h b/obj/NiSkinInstance.h
index 0d3b163093eceaaf1cdf5409008aadce4e029145..505b46f141fc4429b072c1eadd4661b7a0689932 100644
--- a/obj/NiSkinInstance.h
+++ b/obj/NiSkinInstance.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiSkinData;
 class NiSkinPartition;
 class NiNode;
@@ -73,6 +76,8 @@ public:
 
 protected:
 	NI_SKIN_INSTANCE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSkinPartition.cpp b/obj/NiSkinPartition.cpp
index 508f9b06238af2975e9d7a44b7e598f1f418215b..1ea2a51bda68fc283bd9df1e9cc3c2ae9970c9ea 100644
--- a/obj/NiSkinPartition.cpp
+++ b/obj/NiSkinPartition.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSkinPartition.h"
 #include "../gen/SkinPartition.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSkinPartition::TYPE("NiSkinPartition", &NI_SKIN_PARTITION_PARENT::TypeConst() );
diff --git a/obj/NiSkinPartition.h b/obj/NiSkinPartition.h
index 6957f0c3b835eac7c840a48a53eef08c124bd455..34d2683024f17e6e426360f4af4628a3f4d0f10c 100644
--- a/obj/NiSkinPartition.h
+++ b/obj/NiSkinPartition.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISKINPARTITION_H_
 
 #include "NiObject.h"
+
 // Include structures
 #include "../gen/SkinPartition.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -25,7 +28,7 @@ public:
 	~NiSkinPartition();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_SKIN_PARTITION_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSourceTexture.cpp b/obj/NiSourceTexture.cpp
index 685b6e5972798102e3dc7e0e091ab78705709947..1dff2968cd608638e91c0f70421e895d55a3a5be 100644
--- a/obj/NiSourceTexture.cpp
+++ b/obj/NiSourceTexture.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiSourceTexture.h"
 #include "NiObject.h"
 #include "NiPixelData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSourceTexture::TYPE("NiSourceTexture", &NI_SOURCE_TEXTURE_PARENT::TypeConst() );
diff --git a/obj/NiSourceTexture.h b/obj/NiSourceTexture.h
index 63c68f8ea77cd1bb53c22c091ac17a278154febe..949abc9a1d5f668d2e005a3c0dea1a751060462c 100644
--- a/obj/NiSourceTexture.h
+++ b/obj/NiSourceTexture.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObjectNET.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiObject;
 class NiPixelData;
 
@@ -66,6 +69,8 @@ public:
 	//SetUnknownByte3( byte n );
 protected:
 	NI_SOURCE_TEXTURE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSpecularProperty.cpp b/obj/NiSpecularProperty.cpp
index 64ccfe8067ca61abd5751bf2674d04c0203e57ff..08c75fe28803047b7fd78aab4538586dc9c7ff04 100644
--- a/obj/NiSpecularProperty.cpp
+++ b/obj/NiSpecularProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSpecularProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSpecularProperty::TYPE("NiSpecularProperty", &NI_SPECULAR_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiSpecularProperty.h b/obj/NiSpecularProperty.h
index 488e0c021caf9c0e45d841ba0bb3e0353a2efe6c..6570344f19a42bcac25d12109353348ceabeee76 100644
--- a/obj/NiSpecularProperty.h
+++ b/obj/NiSpecularProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISPECULARPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiSpecularProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	NI_SPECULAR_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSphericalCollider.cpp b/obj/NiSphericalCollider.cpp
index 68f4253522f916304ca8c7b04540430679fbc468..c970da86e0e5392f33ca1c99f80a5ca66770ee81 100644
--- a/obj/NiSphericalCollider.cpp
+++ b/obj/NiSphericalCollider.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSphericalCollider.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSphericalCollider::TYPE("NiSphericalCollider", &NI_SPHERICAL_COLLIDER_PARENT::TypeConst() );
diff --git a/obj/NiSphericalCollider.h b/obj/NiSphericalCollider.h
index dac2c89a00b6c01488f0bbcec156311e11b03b05..4669ef48d0d97a953dbb79ecc2d19f094fdf2438 100644
--- a/obj/NiSphericalCollider.h
+++ b/obj/NiSphericalCollider.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISPHERICALCOLLIDER_H_
 
 #include "AParticleModifier.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiSphericalCollider();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_SPHERICAL_COLLIDER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiSpotLight.cpp b/obj/NiSpotLight.cpp
index 7c41a8494596ea320e14f98541767c5cd91ed4fd..3ecfadf2c16a61dfdf9afda13c6459d62b1583ed 100644
--- a/obj/NiSpotLight.cpp
+++ b/obj/NiSpotLight.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSpotLight.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiSpotLight::TYPE("NiSpotLight", &NI_SPOT_LIGHT_PARENT::TypeConst() );
diff --git a/obj/NiSpotLight.h b/obj/NiSpotLight.h
index 520b7eb3cb1f46453f071d2ac9b1af038360e1fe..ffaa12c79aef295a947f46743e73e99268d5bad2 100644
--- a/obj/NiSpotLight.h
+++ b/obj/NiSpotLight.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISPOTLIGHT_H_
 
 #include "NiPointLight.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiSpotLight();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_SPOT_LIGHT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiStencilProperty.cpp b/obj/NiStencilProperty.cpp
index 9eb1c73be64bf5b774f735e53581f31ee3da53e4..56f667b62670c4e95fc41fdedce4b526a57759f0 100644
--- a/obj/NiStencilProperty.cpp
+++ b/obj/NiStencilProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiStencilProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiStencilProperty::TYPE("NiStencilProperty", &NI_STENCIL_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiStencilProperty.h b/obj/NiStencilProperty.h
index d41ca0879ac33d5ca3a59410a5ccc4997aedfc07..ff5c92d7398cb8dccc49fe1446c64b213bfd35c8 100644
--- a/obj/NiStencilProperty.h
+++ b/obj/NiStencilProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISTENCILPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiStencilProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -61,6 +63,8 @@ public:
 
 protected:
 	NI_STENCIL_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiStringExtraData.cpp b/obj/NiStringExtraData.cpp
index f25175ecb8812ac898bd6b2e6cd957417221d3af..91b29c5715b91343daa1e2a9780263eae777149e 100644
--- a/obj/NiStringExtraData.cpp
+++ b/obj/NiStringExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiStringExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiStringExtraData::TYPE("NiStringExtraData", &NI_STRING_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiStringExtraData.h b/obj/NiStringExtraData.h
index 799496936ce86f21ebfc1de410cba9767fce2390..5e88d0c87eeb33352b810988374cf93e5f0351f7 100644
--- a/obj/NiStringExtraData.h
+++ b/obj/NiStringExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISTRINGEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +25,7 @@ public:
 	~NiStringExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -37,8 +39,9 @@ public:
 	void SetData( const string & n );
 
 protected:
-	uint BytesRemaining() const;
 	NI_STRING_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiStringPalette.cpp b/obj/NiStringPalette.cpp
index cb08b70a312d9253305365d7232f49000a58564f..3d0e42300682e6d249b332b980dce259814b67b3 100644
--- a/obj/NiStringPalette.cpp
+++ b/obj/NiStringPalette.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiStringPalette.h"
 #include "../gen/StringPalette.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiStringPalette::TYPE("NiStringPalette", &NI_STRING_PALETTE_PARENT::TypeConst() );
diff --git a/obj/NiStringPalette.h b/obj/NiStringPalette.h
index b3896d44624063373eeb4898994824c7d801e7a0..c84b999e647ceb36e19cf5c484a2e10b511fa65a 100644
--- a/obj/NiStringPalette.h
+++ b/obj/NiStringPalette.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISTRINGPALETTE_H_
 
 #include "NiObject.h"
+
 // Include structures
 #include "../gen/StringPalette.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -25,7 +28,7 @@ public:
 	~NiStringPalette();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_STRING_PALETTE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiStringsExtraData.cpp b/obj/NiStringsExtraData.cpp
index 428c98ce820c94e50820e52d817175b0430ac6be..6686da5679677ca8209557f019d414944e516b8d 100644
--- a/obj/NiStringsExtraData.cpp
+++ b/obj/NiStringsExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiStringsExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiStringsExtraData::TYPE("NiStringsExtraData", &NI_STRINGS_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiStringsExtraData.h b/obj/NiStringsExtraData.h
index 6d556ac182264a29f484c3faf889b98f2046ea2a..cab7795e4ff7dcd037221403761d370ac6b472ad 100644
--- a/obj/NiStringsExtraData.h
+++ b/obj/NiStringsExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NISTRINGSEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +24,7 @@ public:
 	~NiStringsExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -37,6 +39,8 @@ public:
 
 protected:
 	NI_STRINGS_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTextKeyExtraData.cpp b/obj/NiTextKeyExtraData.cpp
index 0a042eba9b7a126340a1a8f8220aa882c8ff09f0..71f743d12a6bf99d8244cecea457680434826bc3 100644
--- a/obj/NiTextKeyExtraData.cpp
+++ b/obj/NiTextKeyExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTextKeyExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTextKeyExtraData::TYPE("NiTextKeyExtraData", &NI_TEXT_KEY_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiTextKeyExtraData.h b/obj/NiTextKeyExtraData.h
index 7700fbf68bb7514009c0c028828ae55582102624..ddeab50d2bbffc660fc9f932b77be97ba776c8a5 100644
--- a/obj/NiTextKeyExtraData.h
+++ b/obj/NiTextKeyExtraData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NITEXTKEYEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -48,6 +49,8 @@ public:
 
 protected:
 	NI_TEXT_KEY_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTextureEffect.cpp b/obj/NiTextureEffect.cpp
index 9323174b742c405824bf059ab7ef04372dc44390..1da9ca111ab9fbd8808d588b6ff77fbe883d8a30 100644
--- a/obj/NiTextureEffect.cpp
+++ b/obj/NiTextureEffect.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTextureEffect.h"
 #include "NiSourceTexture.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTextureEffect::TYPE("NiTextureEffect", &NI_TEXTURE_EFFECT_PARENT::TypeConst() );
diff --git a/obj/NiTextureEffect.h b/obj/NiTextureEffect.h
index 97a2dd52fb8ab7001f7de30e01f568cbb6937be2..e6698f4fcb8bf79b8ecd2982344d52fefc478154 100644
--- a/obj/NiTextureEffect.h
+++ b/obj/NiTextureEffect.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiDynamicEffect.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiSourceTexture;
 
 #include "../gen/obj_defines.h"
@@ -28,7 +31,7 @@ public:
 	~NiTextureEffect();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -37,8 +40,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_TEXTURE_EFFECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTextureTransformController.cpp b/obj/NiTextureTransformController.cpp
index 7c99ff1b3571e23a04d1a4f67fa0ec640b0af9fc..9b0fc734de0b94bc30182d32a8e41cdd8039f7f3 100644
--- a/obj/NiTextureTransformController.cpp
+++ b/obj/NiTextureTransformController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTextureTransformController.h"
 #include "NiFloatData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTextureTransformController::TYPE("NiTextureTransformController", &NI_TEXTURE_TRANSFORM_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiTextureTransformController.h b/obj/NiTextureTransformController.h
index db12eabe2481cb6ac47f1cf248a0ec272c059b48..440bbd7640b2a9522e47ea2b6a97d9ca2d459354 100644
--- a/obj/NiTextureTransformController.h
+++ b/obj/NiTextureTransformController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSingleInterpolatorController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiFloatData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiTextureTransformController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_TEXTURE_TRANSFORM_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTexturingProperty.cpp b/obj/NiTexturingProperty.cpp
index 216b511c2f51b575d4d0d6b1e03b04d817d02c8a..857381d9f08c7e9fb0e86ab473adc7f4a8c6b928 100644
--- a/obj/NiTexturingProperty.cpp
+++ b/obj/NiTexturingProperty.cpp
@@ -21,6 +21,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../gen/ShaderTexDesc.h"
 #include "../gen/TexDesc.h"
 #include "NiSourceTexture.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTexturingProperty::TYPE("NiTexturingProperty", &NI_TEXTURING_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiTexturingProperty.h b/obj/NiTexturingProperty.h
index 0d0f95d9eb15596bb72b6312f89cc3882ef248fa..0b270e8c2c7739ec60ab0c22ae782ab736da3126 100644
--- a/obj/NiTexturingProperty.h
+++ b/obj/NiTexturingProperty.h
@@ -8,6 +8,7 @@ All rights reserved.  Please see niflib.h for licence. */
 // Include structures
 #include "../gen/TexDesc.h"
 #include "../gen/ShaderTexDesc.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -145,6 +146,8 @@ public:
 
 protected:
 	NI_TEXTURING_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTimeController.cpp b/obj/NiTimeController.cpp
index 6e7380008e85e0cfc928530b27a41a0fc7513c6f..d3594a552ea7d8e127febc42bf56f523612fdbc2 100644
--- a/obj/NiTimeController.cpp
+++ b/obj/NiTimeController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 #include "NiObjectNET.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTimeController::TYPE("NiTimeController", &NI_TIME_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiTimeController.h b/obj/NiTimeController.h
index 21955bd9c394c0bc6493c06b3f4eb5924c7377fe..77aa610167b9d8770976cda5ab9714610aa8ea25 100644
--- a/obj/NiTimeController.h
+++ b/obj/NiTimeController.h
@@ -6,8 +6,9 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
 class NiObject;
 
 #include "../gen/obj_defines.h"
@@ -78,6 +79,8 @@ public:
 	void SetStopTime( float n );
 protected:
 	NI_TIME_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTransformController.cpp b/obj/NiTransformController.cpp
index 15986bbbabaf3f536ae261492f53cae4bea6446c..064fa05b544dcafd35d2d8aac8a1c8570861af2d 100644
--- a/obj/NiTransformController.cpp
+++ b/obj/NiTransformController.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTransformController.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTransformController::TYPE("NiTransformController", &NI_TRANSFORM_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiTransformController.h b/obj/NiTransformController.h
index 6e18aaabd77ebfa44d3cfbe8911f0f52731fc48f..8bdf73c2042f80c9420426893db23c46b261ebeb 100644
--- a/obj/NiTransformController.h
+++ b/obj/NiTransformController.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NITRANSFORMCONTROLLER_H_
 
 #include "NiSingleInterpolatorController.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~NiTransformController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_TRANSFORM_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTransformData.cpp b/obj/NiTransformData.cpp
index 0e6eb6272fb6f75e4d558e1ad0add75565d0d4bb..1c90141cffbc8d7efad1a5f16e4162e0fc4ecd14 100644
--- a/obj/NiTransformData.cpp
+++ b/obj/NiTransformData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTransformData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTransformData::TYPE("NiTransformData", &NI_TRANSFORM_DATA_PARENT::TypeConst() );
diff --git a/obj/NiTransformData.h b/obj/NiTransformData.h
index 304f14d7a4eced4da196277332c1529a9cb37865..8675dd078faa31e5879f8b1a13c83ca1cb56600d 100644
--- a/obj/NiTransformData.h
+++ b/obj/NiTransformData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NITRANSFORMDATA_H_
 
 #include "NiKeyframeData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiTransformData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_TRANSFORM_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTransformInterpolator.cpp b/obj/NiTransformInterpolator.cpp
index 52ed2d20bd982c034e2e1651ba023915a6cbd8d0..494d3ba1a867aae3919dc32a6eadff951e5f713e 100644
--- a/obj/NiTransformInterpolator.cpp
+++ b/obj/NiTransformInterpolator.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTransformInterpolator.h"
 #include "NiTransformData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTransformInterpolator::TYPE("NiTransformInterpolator", &NI_TRANSFORM_INTERPOLATOR_PARENT::TypeConst() );
diff --git a/obj/NiTransformInterpolator.h b/obj/NiTransformInterpolator.h
index 0839b0fcc1ebc7947fbf89b655a90b37dc714de8..e1a54d1dd412cbeb4fd307608d5c8adaae09db25 100644
--- a/obj/NiTransformInterpolator.h
+++ b/obj/NiTransformInterpolator.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiInterpolator.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiTransformData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiTransformInterpolator();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_TRANSFORM_INTERPOLATOR_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTriBasedGeom.cpp b/obj/NiTriBasedGeom.cpp
index bfd31f3444c632918c197fc1774c62074bdf4c26..2df124d32ec9fe5df99e571e5a13e25e6d1b99d0 100644
--- a/obj/NiTriBasedGeom.cpp
+++ b/obj/NiTriBasedGeom.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiTriBasedGeomData.h"
 #include "NiSkinInstance.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTriBasedGeom::TYPE("NiTriBasedGeom", &NI_TRI_BASED_GEOM_PARENT::TypeConst() );
diff --git a/obj/NiTriBasedGeom.h b/obj/NiTriBasedGeom.h
index 564d315e36b4dbd69c1232ec315a43fa68a877c0..f3be77db25123193e9dd69c8218cb23c053d9d73 100644
--- a/obj/NiTriBasedGeom.h
+++ b/obj/NiTriBasedGeom.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiAVObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiTriBasedGeomData;
 class NiSkinInstance;
 class NiObject;
@@ -53,6 +56,8 @@ public:
 	
 protected:
 	NI_TRI_BASED_GEOM_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTriBasedGeomData.cpp b/obj/NiTriBasedGeomData.cpp
index 783e330b5e3aba884e64cc4c98fb87411d257c25..563e5a06b503cade49f244ca6bc90c47a964dce2 100644
--- a/obj/NiTriBasedGeomData.cpp
+++ b/obj/NiTriBasedGeomData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTriBasedGeomData.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTriBasedGeomData::TYPE("NiTriBasedGeomData", &NI_TRI_BASED_GEOM_DATA_PARENT::TypeConst() );
diff --git a/obj/NiTriBasedGeomData.h b/obj/NiTriBasedGeomData.h
index 24d1c6aabf9406238e76558cb69f337357859e13..159101773d0c2e8d48841e61d00a1dc75b66cd58 100644
--- a/obj/NiTriBasedGeomData.h
+++ b/obj/NiTriBasedGeomData.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiObject;
 
 #include "../gen/obj_defines.h"
@@ -128,6 +131,8 @@ public:
 
 protected:
 	NI_TRI_BASED_GEOM_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTriShape.cpp b/obj/NiTriShape.cpp
index 5a057ec8e345be413872bca5f932d77e4b2f9e91..88f941cca0dd04ce4387e0424a00f11f70f04202 100644
--- a/obj/NiTriShape.cpp
+++ b/obj/NiTriShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTriShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTriShape::TYPE("NiTriShape", &NI_TRI_SHAPE_PARENT::TypeConst() );
diff --git a/obj/NiTriShape.h b/obj/NiTriShape.h
index 55d7c80f91a7468962d281e413ee9197b0543bad..1b9b6654783e9e0702b197056c4237b3ffc82895 100644
--- a/obj/NiTriShape.h
+++ b/obj/NiTriShape.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NITRISHAPE_H_
 
 #include "NiTriBasedGeom.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~NiTriShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_TRI_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTriShapeData.cpp b/obj/NiTriShapeData.cpp
index bee7701451246c46e7b69ce06e650dd9b74a57cf..3fc8df77589e4af299dadc3c5a49b9e30bcd56d0 100644
--- a/obj/NiTriShapeData.cpp
+++ b/obj/NiTriShapeData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTriShapeData.h"
 #include "../gen/MatchGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTriShapeData::TYPE("NiTriShapeData", &NI_TRI_SHAPE_DATA_PARENT::TypeConst() );
diff --git a/obj/NiTriShapeData.h b/obj/NiTriShapeData.h
index 3969012f51f1132859a7a061c26e15a07cac31b8..b07221cffb29cd169180bcf5e28d4e8e41cd1041 100644
--- a/obj/NiTriShapeData.h
+++ b/obj/NiTriShapeData.h
@@ -7,6 +7,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "NiTriBasedGeomData.h"
 // Include structures
 #include "../gen/MatchGroup.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -32,8 +33,6 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
-protected:
-	NI_TRI_SHAPE_DATA_MEMBERS
 public:
 
 	//--Match Detection--//
@@ -73,6 +72,10 @@ public:
 	 * \sa ITriShapeData::GetTriangles
 	 */
 	void SetTriangles( const vector<Triangle> & in );
+protected:
+	NI_TRI_SHAPE_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTriStrips.cpp b/obj/NiTriStrips.cpp
index d635b889b860c58540d325d08b93be9efcb0d11d..eb8b16d28d5f61dadd68893e46df8a22b349178b 100644
--- a/obj/NiTriStrips.cpp
+++ b/obj/NiTriStrips.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTriStrips.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTriStrips::TYPE("NiTriStrips", &NI_TRI_STRIPS_PARENT::TypeConst() );
diff --git a/obj/NiTriStrips.h b/obj/NiTriStrips.h
index da69a8ac103dc2b837be0aadf2e336b0f8d9d00d..5491e4dc4ee5c7881efd366d8b83b78feba03bab 100644
--- a/obj/NiTriStrips.h
+++ b/obj/NiTriStrips.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NITRISTRIPS_H_
 
 #include "NiTriBasedGeom.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~NiTriStrips();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_TRI_STRIPS_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiTriStripsData.cpp b/obj/NiTriStripsData.cpp
index 374ac7b984b17acba9c3df4d737e35851d7ddd96..39bdc12c9b7a9b270c23a41b7454d6ee6cdb1a74 100644
--- a/obj/NiTriStripsData.cpp
+++ b/obj/NiTriStripsData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTriStripsData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiTriStripsData::TYPE("NiTriStripsData", &NI_TRI_STRIPS_DATA_PARENT::TypeConst() );
diff --git a/obj/NiTriStripsData.h b/obj/NiTriStripsData.h
index 4344eb6e2c4099639b05c818dd0794eadac199b0..eb200c83b816b9ea2de9addfcb4d837cc99b88ad 100644
--- a/obj/NiTriStripsData.h
+++ b/obj/NiTriStripsData.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NITRISTRIPSDATA_H_
 
 #include "NiTriBasedGeomData.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -74,6 +75,8 @@ private:
 
 protected:
 	NI_TRI_STRIPS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiUVController.cpp b/obj/NiUVController.cpp
index 4b03643cf103037d27aa2320540355fa40330884..789610d0637ced16ddea6c695341a81459cee41d 100644
--- a/obj/NiUVController.cpp
+++ b/obj/NiUVController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiUVController.h"
 #include "NiUVData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiUVController::TYPE("NiUVController", &NI_U_V_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiUVController.h b/obj/NiUVController.h
index 329f74f965f2634a15b819f7eebb33fc330145d4..e067abc1be1e6dfd32a36bc2e6c3d7df3d42e978 100644
--- a/obj/NiUVController.h
+++ b/obj/NiUVController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiTimeController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiUVData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiUVController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -41,6 +44,8 @@ public:
 
 protected:
 	NI_U_V_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiUVData.cpp b/obj/NiUVData.cpp
index 5477b2c9e01e572c6ce284f96f6eb3f7c4aef6de..63d1d4bf16c8b1561f318c6215a300abf126590b 100644
--- a/obj/NiUVData.cpp
+++ b/obj/NiUVData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiUVData.h"
 #include "../gen/KeyGroup.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiUVData::TYPE("NiUVData", &NI_U_V_DATA_PARENT::TypeConst() );
diff --git a/obj/NiUVData.h b/obj/NiUVData.h
index a1f0a7ded46623d321370600ea861c78b9add76c..71edba3e0df946128bfc6821d621ead619ba2635 100644
--- a/obj/NiUVData.h
+++ b/obj/NiUVData.h
@@ -5,8 +5,10 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIUVDATA_H_
 
 #include "NiObject.h"
+
 // Include structures
 #include "../gen/KeyGroup.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +25,7 @@ public:
 	~NiUVData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -32,8 +34,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_U_V_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiVectorExtraData.cpp b/obj/NiVectorExtraData.cpp
index 134301b9c4e7dbe407ba42064064c75f642ad4ba..f66da2925523693af0614d773efeae0968267d17 100644
--- a/obj/NiVectorExtraData.cpp
+++ b/obj/NiVectorExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiVectorExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiVectorExtraData::TYPE("NiVectorExtraData", &NI_VECTOR_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiVectorExtraData.h b/obj/NiVectorExtraData.h
index 8f3b007e9d41ae43e8f1ea3d2dceecd8442471de..63143d66524c0f09204302691d23796a393d7172 100644
--- a/obj/NiVectorExtraData.h
+++ b/obj/NiVectorExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIVECTOREXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiVectorExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -37,6 +39,8 @@ public:
 	//TODO:  There is an unknown member in this class
 protected:
 	NI_VECTOR_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiVertWeightsExtraData.cpp b/obj/NiVertWeightsExtraData.cpp
index 98558aab47d59e6e49cc43f5e2e7009a92b57a56..d729fb2a5fd6fcc54a4930e6a2636c76369357bc 100644
--- a/obj/NiVertWeightsExtraData.cpp
+++ b/obj/NiVertWeightsExtraData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiVertWeightsExtraData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiVertWeightsExtraData::TYPE("NiVertWeightsExtraData", &NI_VERT_WEIGHTS_EXTRA_DATA_PARENT::TypeConst() );
diff --git a/obj/NiVertWeightsExtraData.h b/obj/NiVertWeightsExtraData.h
index 5f2375cf7e194e44724251220300524195b3977c..03b9976c4c4c6a859f83285af50e8b63d43f1b58 100644
--- a/obj/NiVertWeightsExtraData.h
+++ b/obj/NiVertWeightsExtraData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIVERTWEIGHTSEXTRADATA_H_
 
 #include "NiExtraData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +24,7 @@ public:
 	~NiVertWeightsExtraData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -37,6 +39,8 @@ public:
 
 protected:
 	NI_VERT_WEIGHTS_EXTRA_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiVertexColorProperty.cpp b/obj/NiVertexColorProperty.cpp
index 15d6af715c14e4cb737a46ff79dc656c5a278b05..92150e6292ce20be96ea08c2e912725de5c26560 100644
--- a/obj/NiVertexColorProperty.cpp
+++ b/obj/NiVertexColorProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiVertexColorProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiVertexColorProperty::TYPE("NiVertexColorProperty", &NI_VERTEX_COLOR_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiVertexColorProperty.h b/obj/NiVertexColorProperty.h
index 157d73756e1ab56a69b30d4a94dde0d75297be8f..cf92dac722a2595d222884d3aba1affdba19e53e 100644
--- a/obj/NiVertexColorProperty.h
+++ b/obj/NiVertexColorProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIVERTEXCOLORPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -24,7 +26,7 @@ public:
 	~NiVertexColorProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -45,6 +47,8 @@ public:
 
 protected:
 	NI_VERTEX_COLOR_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiVisController.cpp b/obj/NiVisController.cpp
index b437588dfbd1fe8484aed559930b46ed5eda12c3..f8021234403a1bbf5814cf558883648960265d76 100644
--- a/obj/NiVisController.cpp
+++ b/obj/NiVisController.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiVisController.h"
 #include "NiVisData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiVisController::TYPE("NiVisController", &NI_VIS_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/NiVisController.h b/obj/NiVisController.h
index 49cbfc4bd1f69807d71375baa3b378723eab3530..4ada2a09a8c757bc51ad4d29fde28e6807c538d5 100644
--- a/obj/NiVisController.h
+++ b/obj/NiVisController.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiSingleInterpolatorController.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiVisData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~NiVisController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_VIS_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiVisData.cpp b/obj/NiVisData.cpp
index 29afff8d2efbb3bb62368336f0f536bb1ca8572a..4ead3db73c53ed072f3ea24ff06d8dc4e808e08e 100644
--- a/obj/NiVisData.cpp
+++ b/obj/NiVisData.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiVisData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiVisData::TYPE("NiVisData", &NI_VIS_DATA_PARENT::TypeConst() );
diff --git a/obj/NiVisData.h b/obj/NiVisData.h
index ab10614591f161503837c82a7cd9edd6ba6c2f7f..65503d5f4fdf1f9662bb0c3fa0d4c87e7a3ee7ea 100644
--- a/obj/NiVisData.h
+++ b/obj/NiVisData.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIVISDATA_H_
 
 #include "AKeyedData.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiVisData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	NI_VIS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiWireframeProperty.cpp b/obj/NiWireframeProperty.cpp
index a05d9ced6a98828c19521f6eb21479d7e4778440..4ba168bcb381e29c64930330c9f55b46f1667f1e 100644
--- a/obj/NiWireframeProperty.cpp
+++ b/obj/NiWireframeProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiWireframeProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiWireframeProperty::TYPE("NiWireframeProperty", &NI_WIREFRAME_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiWireframeProperty.h b/obj/NiWireframeProperty.h
index c036cae7dd998d524846dd54ee1037a5115da40a..8ccc94a117921f38c128888e2b5a7c3d01cc96fe 100644
--- a/obj/NiWireframeProperty.h
+++ b/obj/NiWireframeProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIWIREFRAMEPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~NiWireframeProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,6 +38,8 @@ public:
 
 protected:
 	NI_WIREFRAME_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/NiZBufferProperty.cpp b/obj/NiZBufferProperty.cpp
index a6a454bb6f3f69b728255469eb1ccc7f33aff6fc..bf0f25d22e533fda564f73ec478c24d6c64b85e7 100644
--- a/obj/NiZBufferProperty.cpp
+++ b/obj/NiZBufferProperty.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "NiZBufferProperty.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type NiZBufferProperty::TYPE("NiZBufferProperty", &NI_Z_BUFFER_PROPERTY_PARENT::TypeConst() );
diff --git a/obj/NiZBufferProperty.h b/obj/NiZBufferProperty.h
index 8fb22e3f08bef4d5da839bdfeb6ffc7b1f43eb28..61fa23fb3c2fbda9c6adc3fcdb9b1095b1b154a5 100644
--- a/obj/NiZBufferProperty.h
+++ b/obj/NiZBufferProperty.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _NIZBUFFERPROPERTY_H_
 
 #include "NiProperty.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +24,7 @@ public:
 	~NiZBufferProperty();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -40,6 +42,8 @@ public:
 
 protected:
 	NI_Z_BUFFER_PROPERTY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/RootCollisionNode.cpp b/obj/RootCollisionNode.cpp
index 9e24f616cc6d6dec8b0c22b186ae43182a2c52ed..8251858d78d4446b8d11ea506745ac0d04654636 100644
--- a/obj/RootCollisionNode.cpp
+++ b/obj/RootCollisionNode.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "RootCollisionNode.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type RootCollisionNode::TYPE("RootCollisionNode", &ROOT_COLLISION_NODE_PARENT::TypeConst() );
diff --git a/obj/RootCollisionNode.h b/obj/RootCollisionNode.h
index 4f76acdb1a9337082e740b4b3b9f7b3539f1276f..5a7830e2542378d8fc6bd4310011861288172622 100644
--- a/obj/RootCollisionNode.h
+++ b/obj/RootCollisionNode.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _ROOTCOLLISIONNODE_H_
 
 #include "NiNode.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~RootCollisionNode();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	ROOT_COLLISION_NODE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkBlendCollisionObject.cpp b/obj/bhkBlendCollisionObject.cpp
index e11870b1e7a5ec51e9a2d5a4d12363eae7ff17ef..d8c9fd7e60797f5ab977e1a7ec4c0b7e09894b06 100644
--- a/obj/bhkBlendCollisionObject.cpp
+++ b/obj/bhkBlendCollisionObject.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkBlendCollisionObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkBlendCollisionObject::TYPE("bhkBlendCollisionObject", &BHK_BLEND_COLLISION_OBJECT_PARENT::TypeConst() );
diff --git a/obj/bhkBlendCollisionObject.h b/obj/bhkBlendCollisionObject.h
index 47f2e9a24d6a539555b012d6077d4f4c29a9fad7..cc20d7e729b0770d21ed8cae6a39219ea11132d0 100644
--- a/obj/bhkBlendCollisionObject.h
+++ b/obj/bhkBlendCollisionObject.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKBLENDCOLLISIONOBJECT_H_
 
 #include "NiCollisionObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkBlendCollisionObject();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_BLEND_COLLISION_OBJECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkBlendController.cpp b/obj/bhkBlendController.cpp
index d7c0be16f4ddd0a6d47b2992b2e299d4fedea7db..a2e7a3363629796e2fbd608e29fde36d6c64164c 100644
--- a/obj/bhkBlendController.cpp
+++ b/obj/bhkBlendController.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkBlendController.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkBlendController::TYPE("bhkBlendController", &BHK_BLEND_CONTROLLER_PARENT::TypeConst() );
diff --git a/obj/bhkBlendController.h b/obj/bhkBlendController.h
index 92ce914644f4f6da4421528684d6364e6ddc3020..c5de9d9e6504d712ffb92e8546a4409534fd610a 100644
--- a/obj/bhkBlendController.h
+++ b/obj/bhkBlendController.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKBLENDCONTROLLER_H_
 
 #include "NiTimeController.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~bhkBlendController();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -32,9 +33,10 @@ public:
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
 
-	//TODO:  This is not a priority but needs to be implemented eventually
 protected:
 	BHK_BLEND_CONTROLLER_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkBoxShape.cpp b/obj/bhkBoxShape.cpp
index f0fee9f2d4caa87231b81c8c956b8e7bbcb417fd..02a3600db283b706a35cd1bdaeb654cca02c7f72 100644
--- a/obj/bhkBoxShape.cpp
+++ b/obj/bhkBoxShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkBoxShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkBoxShape::TYPE("bhkBoxShape", &BHK_BOX_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkBoxShape.h b/obj/bhkBoxShape.h
index 65e054d18de59e5de243de2234392cf3fba75e1a..f3e30cfc2b0945379a9982730c9aee8e2745dab8 100644
--- a/obj/bhkBoxShape.h
+++ b/obj/bhkBoxShape.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKBOXSHAPE_H_
 
 #include "bhkConvexShape.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~bhkBoxShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_BOX_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkCapsuleShape.cpp b/obj/bhkCapsuleShape.cpp
index b1e2adcd5351ff518c809d84d9278dbc468d1fa0..ab1fe776c960ad47507cc967e07d55cb4e24de6e 100644
--- a/obj/bhkCapsuleShape.cpp
+++ b/obj/bhkCapsuleShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkCapsuleShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkCapsuleShape::TYPE("bhkCapsuleShape", &BHK_CAPSULE_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkCapsuleShape.h b/obj/bhkCapsuleShape.h
index 4488fed40ca9961bc40b541e64befd7690da9bdc..293c410acc7ac06e3ccc55a48ab45f1f89c0722f 100644
--- a/obj/bhkCapsuleShape.h
+++ b/obj/bhkCapsuleShape.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKCAPSULESHAPE_H_
 
 #include "bhkConvexShape.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~bhkCapsuleShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_CAPSULE_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkCollisionObject.cpp b/obj/bhkCollisionObject.cpp
index b58ca89b08e37f9969179605c3d87c9f624eb4f2..257e53bd3b4052238ff7af8f5152578a9a3a058b 100644
--- a/obj/bhkCollisionObject.cpp
+++ b/obj/bhkCollisionObject.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkCollisionObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkCollisionObject::TYPE("bhkCollisionObject", &BHK_COLLISION_OBJECT_PARENT::TypeConst() );
diff --git a/obj/bhkCollisionObject.h b/obj/bhkCollisionObject.h
index 01a18ac73f2aa6527e7eec6d77a10f1ba3e1cdf0..1fc349b7198f0fe64f7771192938659da66b6cd6 100644
--- a/obj/bhkCollisionObject.h
+++ b/obj/bhkCollisionObject.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKCOLLISIONOBJECT_H_
 
 #include "NiCollisionObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkCollisionObject();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_COLLISION_OBJECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkConvexShape.cpp b/obj/bhkConvexShape.cpp
index afc83cb2803e28b6dad0134a867788094f2051ec..49c9398ce0414e9468d2266673c33d1754ae2677 100644
--- a/obj/bhkConvexShape.cpp
+++ b/obj/bhkConvexShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkConvexShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkConvexShape::TYPE("bhkConvexShape", &BHK_CONVEX_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkConvexShape.h b/obj/bhkConvexShape.h
index f0f5f0a58cf7859b76f7903c92d293078d25cda9..eed56e669ae0d266cc8fffb1e28721477a05d2c2 100644
--- a/obj/bhkConvexShape.h
+++ b/obj/bhkConvexShape.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKCONVEXSHAPE_H_
 
 #include "bhkSphereRepShape.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkConvexShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_CONVEX_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkConvexTransformShape.cpp b/obj/bhkConvexTransformShape.cpp
index 4ef28d461f4981bb4235d93d22038a35bd59eb94..8c5a32a5a50a5fe3d9754bcf31602610b2572f04 100644
--- a/obj/bhkConvexTransformShape.cpp
+++ b/obj/bhkConvexTransformShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkConvexTransformShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkConvexTransformShape::TYPE("bhkConvexTransformShape", &BHK_CONVEX_TRANSFORM_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkConvexTransformShape.h b/obj/bhkConvexTransformShape.h
index 156b921e83500b9e76d28991882e128441f3dac8..ca96d565b9c889ad449e28990b39e7bf959d4381 100644
--- a/obj/bhkConvexTransformShape.h
+++ b/obj/bhkConvexTransformShape.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKCONVEXTRANSFORMSHAPE_H_
 
 #include "bhkTransformShape.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkConvexTransformShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_CONVEX_TRANSFORM_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkConvexVerticesShape.cpp b/obj/bhkConvexVerticesShape.cpp
index cae05f9989cb7b7f2768b0bbe379f05a93c57bed..380923cef07684dc8f3b77fb3e9982240bc831c1 100644
--- a/obj/bhkConvexVerticesShape.cpp
+++ b/obj/bhkConvexVerticesShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkConvexVerticesShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkConvexVerticesShape::TYPE("bhkConvexVerticesShape", &BHK_CONVEX_VERTICES_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkConvexVerticesShape.h b/obj/bhkConvexVerticesShape.h
index f8fce7b505068a08fa91b212d2ba0b9f264481ab..710fc63801f938d51648f86dde29f4a6fa7d86ea 100644
--- a/obj/bhkConvexVerticesShape.h
+++ b/obj/bhkConvexVerticesShape.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKCONVEXVERTICESSHAPE_H_
 
 #include "bhkSphereRepShape.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkConvexVerticesShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_CONVEX_VERTICES_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkEntity.cpp b/obj/bhkEntity.cpp
index f5dbf24cb0a2daa083b3b566a52dde7bfad58868..acc9a21c82b2491da810c7190438d6fa373ed58a 100644
--- a/obj/bhkEntity.cpp
+++ b/obj/bhkEntity.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkEntity.h"
 #include "bhkShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkEntity::TYPE("bhkEntity", &BHK_ENTITY_PARENT::TypeConst() );
diff --git a/obj/bhkEntity.h b/obj/bhkEntity.h
index 4abaca251864916fd832195667163284251f3f90..6ded32d49bd37840259d602bb053c98acd95078e 100644
--- a/obj/bhkEntity.h
+++ b/obj/bhkEntity.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkWorldObject.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class bhkShape;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~bhkEntity();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_ENTITY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkHingeConstraint.cpp b/obj/bhkHingeConstraint.cpp
index 4f1c00df85b308e659352263c2fea2b0d0718bac..726f1b926479425372e516ade5ea19bb85b71b62 100644
--- a/obj/bhkHingeConstraint.cpp
+++ b/obj/bhkHingeConstraint.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkHingeConstraint.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkHingeConstraint::TYPE("bhkHingeConstraint", &BHK_HINGE_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/bhkHingeConstraint.h b/obj/bhkHingeConstraint.h
index 5d79801ebe945f987d134cf50bc9f325b827c59f..f59c33fe8a7dca74e75a230782f2248e3e24eea5 100644
--- a/obj/bhkHingeConstraint.h
+++ b/obj/bhkHingeConstraint.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKHINGECONSTRAINT_H_
 
 #include "AbhkConstraint.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkHingeConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_HINGE_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkLimitedHingeConstraint.cpp b/obj/bhkLimitedHingeConstraint.cpp
index c38225e2a72b2660d24aa8926e5ffe02686d7679..1a67af5768a452ed733177bdb4ff6b16cc20c6e6 100644
--- a/obj/bhkLimitedHingeConstraint.cpp
+++ b/obj/bhkLimitedHingeConstraint.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkLimitedHingeConstraint.h"
 #include "../gen/LimitedHingeDescriptor.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkLimitedHingeConstraint::TYPE("bhkLimitedHingeConstraint", &BHK_LIMITED_HINGE_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/bhkLimitedHingeConstraint.h b/obj/bhkLimitedHingeConstraint.h
index 4ee05f8692266885d24ea86dac9fc3ad0a413f06..6b5b4c40d5c8567d809fcf3dbaa7471f4f58d7e5 100644
--- a/obj/bhkLimitedHingeConstraint.h
+++ b/obj/bhkLimitedHingeConstraint.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKLIMITEDHINGECONSTRAINT_H_
 
 #include "AbhkConstraint.h"
+
 // Include structures
 #include "../gen/LimitedHingeDescriptor.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +26,7 @@ public:
 	~bhkLimitedHingeConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -32,8 +35,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_LIMITED_HINGE_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkListShape.cpp b/obj/bhkListShape.cpp
index 1f1ff810703288a0d4862953575f753d8ac6b5f3..d60195bd280381e34a4923f2df3e70d948262f75 100644
--- a/obj/bhkListShape.cpp
+++ b/obj/bhkListShape.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkListShape.h"
 #include "bhkShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkListShape::TYPE("bhkListShape", &BHK_LIST_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkListShape.h b/obj/bhkListShape.h
index ccdbc70812edff66adbcbc8c5c418786edeebfb8..e4545939d653d71ea4304d00283a8f6317754be9 100644
--- a/obj/bhkListShape.h
+++ b/obj/bhkListShape.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "AbhkShapeCollection.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class bhkShape;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~bhkListShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_LIST_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkMalleableConstraint.cpp b/obj/bhkMalleableConstraint.cpp
index 501aeae5c3aa097b8c16d0ab3cc01c5ba9136135..713742fb8291d16beeb527d4e57b9a5a7614c482 100644
--- a/obj/bhkMalleableConstraint.cpp
+++ b/obj/bhkMalleableConstraint.cpp
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "../gen/RagDollDescriptor.h"
 #include "../gen/LimitedHingeDescriptor.h"
 #include "NiObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkMalleableConstraint::TYPE("bhkMalleableConstraint", &BHK_MALLEABLE_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/bhkMalleableConstraint.h b/obj/bhkMalleableConstraint.h
index b4f6a96f202f628590af0d46d52e92b7c2327eaf..a1572d7ff52c8f6a47311b53619bac36c730ba78 100644
--- a/obj/bhkMalleableConstraint.h
+++ b/obj/bhkMalleableConstraint.h
@@ -5,12 +5,14 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKMALLEABLECONSTRAINT_H_
 
 #include "AbhkConstraint.h"
+
 // Include structures
+#include "../Ref.h"
 #include "../gen/RagDollDescriptor.h"
 #include "../gen/LimitedHingeDescriptor.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class NiObject;
 
 #include "../gen/obj_defines.h"
@@ -28,7 +30,7 @@ public:
 	~bhkMalleableConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -37,8 +39,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_MALLEABLE_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkMoppBvTreeShape.cpp b/obj/bhkMoppBvTreeShape.cpp
index e8882eb411f18cb0b07d813148247511964c322a..94159ae957ea62819256690055a095935745454b 100644
--- a/obj/bhkMoppBvTreeShape.cpp
+++ b/obj/bhkMoppBvTreeShape.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkMoppBvTreeShape.h"
 #include "bhkShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkMoppBvTreeShape::TYPE("bhkMoppBvTreeShape", &BHK_MOPP_BV_TREE_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkMoppBvTreeShape.h b/obj/bhkMoppBvTreeShape.h
index e9cf3e008dfb6fa18309f2955d2369134971899c..b3628b7b070f7b6dd830ca2fecea88d05637a4d1 100644
--- a/obj/bhkMoppBvTreeShape.h
+++ b/obj/bhkMoppBvTreeShape.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkShape.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class bhkShape;
 
 #include "../gen/obj_defines.h"
@@ -26,7 +29,7 @@ public:
 	~bhkMoppBvTreeShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -35,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_MOPP_BV_TREE_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkMultiSphereShape.cpp b/obj/bhkMultiSphereShape.cpp
index 5bedbc397fc88bcd0d9179b374e3341bbc5632eb..c947718c8b8a6428d01147683560b15e58414302 100644
--- a/obj/bhkMultiSphereShape.cpp
+++ b/obj/bhkMultiSphereShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkMultiSphereShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkMultiSphereShape::TYPE("bhkMultiSphereShape", &BHK_MULTI_SPHERE_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkMultiSphereShape.h b/obj/bhkMultiSphereShape.h
index f1db7edc4bd565e67734a08e28e8ea9edec07bb4..1d6305242c0b8130c1ca468c7bcf1af9dd7b77fa 100644
--- a/obj/bhkMultiSphereShape.h
+++ b/obj/bhkMultiSphereShape.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKMULTISPHERESHAPE_H_
 
 #include "bhkSphereRepShape.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkMultiSphereShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_MULTI_SPHERE_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkNiTriStripsShape.cpp b/obj/bhkNiTriStripsShape.cpp
index e7dd97e2334937284fa8c385d78ac4ec1b5e9af6..48c8f9ce5c037321ffc68717e7385af8a53e317e 100644
--- a/obj/bhkNiTriStripsShape.cpp
+++ b/obj/bhkNiTriStripsShape.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkNiTriStripsShape.h"
 #include "NiTriStripsData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkNiTriStripsShape::TYPE("bhkNiTriStripsShape", &BHK_NI_TRI_STRIPS_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkNiTriStripsShape.h b/obj/bhkNiTriStripsShape.h
index df7219527d56ae5d65c1f98cc36ee579726116ae..10354c4ea41a46c2303a8a535340c422cfc5acaf 100644
--- a/obj/bhkNiTriStripsShape.h
+++ b/obj/bhkNiTriStripsShape.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkSphereRepShape.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class NiTriStripsData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~bhkNiTriStripsShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_NI_TRI_STRIPS_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkPackedNiTriStripsShape.cpp b/obj/bhkPackedNiTriStripsShape.cpp
index 38a6fa5e283e995ca7446b78b74d2d8f170ba549..386557bf0770e09037d0378b36c5fbd2de2a1b2b 100644
--- a/obj/bhkPackedNiTriStripsShape.cpp
+++ b/obj/bhkPackedNiTriStripsShape.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkPackedNiTriStripsShape.h"
 #include "hkPackedNiTriStripsData.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkPackedNiTriStripsShape::TYPE("bhkPackedNiTriStripsShape", &BHK_PACKED_NI_TRI_STRIPS_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkPackedNiTriStripsShape.h b/obj/bhkPackedNiTriStripsShape.h
index 5332d8ad43377a286dadb44368046f3eaa34e0bf..cbfa610d798c514a37d8d9ff806b6827ca0d2a9b 100644
--- a/obj/bhkPackedNiTriStripsShape.h
+++ b/obj/bhkPackedNiTriStripsShape.h
@@ -6,8 +6,11 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "AbhkShapeCollection.h"
 
-// Forward define of referenced blocks
+// Include structures
 #include "../Ref.h"
+namespace NifLib {
+
+// Forward define of referenced blocks
 class hkPackedNiTriStripsData;
 
 #include "../gen/obj_defines.h"
@@ -25,7 +28,7 @@ public:
 	~bhkPackedNiTriStripsShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -34,8 +37,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_PACKED_NI_TRI_STRIPS_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkPrismaticConstraint.cpp b/obj/bhkPrismaticConstraint.cpp
index 016e615215649dc06cfcc5d8fae7331605433610..77322344717a864f1812ad08bdc11f3d8b277179 100644
--- a/obj/bhkPrismaticConstraint.cpp
+++ b/obj/bhkPrismaticConstraint.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkPrismaticConstraint.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkPrismaticConstraint::TYPE("bhkPrismaticConstraint", &BHK_PRISMATIC_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/bhkPrismaticConstraint.h b/obj/bhkPrismaticConstraint.h
index fdbc900873187593cb25e5fdc0ff2d20ebb6395d..7428523784996ceb8c7643281a5908714841ddef 100644
--- a/obj/bhkPrismaticConstraint.h
+++ b/obj/bhkPrismaticConstraint.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKPRISMATICCONSTRAINT_H_
 
 #include "AbhkConstraint.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkPrismaticConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_PRISMATIC_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkRagdollConstraint.cpp b/obj/bhkRagdollConstraint.cpp
index 15b0cfcab238e2309e9faac392efb8027fec724b..63fe589f772d4e7a41eb1dde011b7513194b7390 100644
--- a/obj/bhkRagdollConstraint.cpp
+++ b/obj/bhkRagdollConstraint.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkRagdollConstraint.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkRagdollConstraint::TYPE("bhkRagdollConstraint", &BHK_RAGDOLL_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/bhkRagdollConstraint.h b/obj/bhkRagdollConstraint.h
index bf5fbb889fd5c8256c2364027846281350c8f482..1fc7014753886ace006beaffcbbe12b7207337d7 100644
--- a/obj/bhkRagdollConstraint.h
+++ b/obj/bhkRagdollConstraint.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKRAGDOLLCONSTRAINT_H_
 
 #include "AbhkRagdollConstraint.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkRagdollConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_RAGDOLL_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkRefObject.cpp b/obj/bhkRefObject.cpp
index 93f1728558887ef6be56574b71d0734cb041cbd6..186e983e73fac686ff521fe7109697f01975580c 100644
--- a/obj/bhkRefObject.cpp
+++ b/obj/bhkRefObject.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkRefObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkRefObject::TYPE("bhkRefObject", &BHK_REF_OBJECT_PARENT::TypeConst() );
diff --git a/obj/bhkRefObject.h b/obj/bhkRefObject.h
index 599580119d0ca15aa92bb0f057d82586c1e9d56f..fe16257e57bb66660fbdfa76b523158eb192cb93 100644
--- a/obj/bhkRefObject.h
+++ b/obj/bhkRefObject.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKREFOBJECT_H_
 
 #include "NiObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkRefObject();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_REF_OBJECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkRigidBody.cpp b/obj/bhkRigidBody.cpp
index e5f8ad0105d49a903bd26ef1b36e2db799d4e410..64571721aa43d35b6c569603a43270066f893887 100644
--- a/obj/bhkRigidBody.cpp
+++ b/obj/bhkRigidBody.cpp
@@ -4,6 +4,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #include "bhkRigidBody.h"
 #include "../gen/QuaternionXYZW.h"
 #include "AbhkConstraint.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkRigidBody::TYPE("bhkRigidBody", &BHK_RIGID_BODY_PARENT::TypeConst() );
diff --git a/obj/bhkRigidBody.h b/obj/bhkRigidBody.h
index c9d8b91d2f6331e0db02152d7d914d898a0dbbe8..86d5234a0486fad0fec49a5d8d348d2e1d1583a5 100644
--- a/obj/bhkRigidBody.h
+++ b/obj/bhkRigidBody.h
@@ -5,11 +5,13 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKRIGIDBODY_H_
 
 #include "bhkEntity.h"
+
 // Include structures
 #include "../gen/QuaternionXYZW.h"
+#include "../Ref.h"
+namespace NifLib {
 
 // Forward define of referenced blocks
-#include "../Ref.h"
 class AbhkConstraint;
 
 #include "../gen/obj_defines.h"
@@ -27,7 +29,7 @@ public:
 	~bhkRigidBody();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -36,8 +38,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_RIGID_BODY_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkRigidBodyT.cpp b/obj/bhkRigidBodyT.cpp
index 9bd1a45856bd0052686bc96e9ed04a723bbe17c0..569a805e9419070bb8ff7c5c04c91a1249fec3a3 100644
--- a/obj/bhkRigidBodyT.cpp
+++ b/obj/bhkRigidBodyT.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkRigidBodyT.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkRigidBodyT::TYPE("bhkRigidBodyT", &BHK_RIGID_BODY_T_PARENT::TypeConst() );
diff --git a/obj/bhkRigidBodyT.h b/obj/bhkRigidBodyT.h
index c6bae197d4975aa2d5abc34d4affe9cb2fd80f0d..6be1972221673237f276755cd84192da8ae89dc1 100644
--- a/obj/bhkRigidBodyT.h
+++ b/obj/bhkRigidBodyT.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKRIGIDBODYT_H_
 
 #include "bhkRigidBody.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkRigidBodyT();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_RIGID_BODY_T_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkSPCollisionObject.cpp b/obj/bhkSPCollisionObject.cpp
index 68e8cbecfda535cd499ce421ea62b099de47bea4..22f35ee1398f1b49eb1c40b6ea0a94edda6b8dba 100644
--- a/obj/bhkSPCollisionObject.cpp
+++ b/obj/bhkSPCollisionObject.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkSPCollisionObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkSPCollisionObject::TYPE("bhkSPCollisionObject", &BHK_S_P_COLLISION_OBJECT_PARENT::TypeConst() );
diff --git a/obj/bhkSPCollisionObject.h b/obj/bhkSPCollisionObject.h
index ac6c3215adf47e6e2926db321263f2f5b896eb18..07cb5fc693f0d07aa7f94623bf726b49f0934b43 100644
--- a/obj/bhkSPCollisionObject.h
+++ b/obj/bhkSPCollisionObject.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKSPCOLLISIONOBJECT_H_
 
 #include "NiCollisionObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkSPCollisionObject();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_S_P_COLLISION_OBJECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkSerializable.cpp b/obj/bhkSerializable.cpp
index 3c9845980e875828ccdf5b4c1969743201cb943b..4e69457d3b2070213b92080dec0cbd9b105ff32b 100644
--- a/obj/bhkSerializable.cpp
+++ b/obj/bhkSerializable.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkSerializable.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkSerializable::TYPE("bhkSerializable", &BHK_SERIALIZABLE_PARENT::TypeConst() );
diff --git a/obj/bhkSerializable.h b/obj/bhkSerializable.h
index 1a14803ea2b003f58c5ffbe15562105719451e95..b0812149a0863b70202dcf8ed36dc12b9e6effa3 100644
--- a/obj/bhkSerializable.h
+++ b/obj/bhkSerializable.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKSERIALIZABLE_H_
 
 #include "bhkRefObject.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +23,7 @@ public:
 	~bhkSerializable();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_SERIALIZABLE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkShape.cpp b/obj/bhkShape.cpp
index e38f172f9bd051510d9823560be70918ad1447e0..e85f2234441a905602c7e9148293c877abe9a48d 100644
--- a/obj/bhkShape.cpp
+++ b/obj/bhkShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkShape::TYPE("bhkShape", &BHK_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkShape.h b/obj/bhkShape.h
index a2149c68d61e29021e8a624a1c670f62845bd832..a9842fa812aa1dc50c11c72afbf284e82f31641f 100644
--- a/obj/bhkShape.h
+++ b/obj/bhkShape.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKSHAPE_H_
 
 #include "bhkSerializable.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkSimpleShapePhantom.cpp b/obj/bhkSimpleShapePhantom.cpp
index 00035c4e2a12d3875f98b427e98a8e6be053dbea..139c297eb19ccb9042f70b24306b9bd6bbc8d67c 100644
--- a/obj/bhkSimpleShapePhantom.cpp
+++ b/obj/bhkSimpleShapePhantom.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkSimpleShapePhantom.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkSimpleShapePhantom::TYPE("bhkSimpleShapePhantom", &BHK_SIMPLE_SHAPE_PHANTOM_PARENT::TypeConst() );
diff --git a/obj/bhkSimpleShapePhantom.h b/obj/bhkSimpleShapePhantom.h
index 86f8cd453198057ba5344994063a751020c9d735..7e2360d84fe8945c4cabc02a18bfdb3784ae82a4 100644
--- a/obj/bhkSimpleShapePhantom.h
+++ b/obj/bhkSimpleShapePhantom.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKSIMPLESHAPEPHANTOM_H_
 
 #include "bhkEntity.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkSimpleShapePhantom();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_SIMPLE_SHAPE_PHANTOM_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkSphereRepShape.cpp b/obj/bhkSphereRepShape.cpp
index 7efa8a14c37a8f6195fee492e718d176725511d5..0a6dc79ef01d4387475f6223ee5136531e483bf2 100644
--- a/obj/bhkSphereRepShape.cpp
+++ b/obj/bhkSphereRepShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkSphereRepShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkSphereRepShape::TYPE("bhkSphereRepShape", &BHK_SPHERE_REP_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkSphereRepShape.h b/obj/bhkSphereRepShape.h
index 964d4506fb94a7dc76fe2071bb63179c33803012..1f3a4422f24473a62da29a1fce9a2c1f84e591f4 100644
--- a/obj/bhkSphereRepShape.h
+++ b/obj/bhkSphereRepShape.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKSPHEREREPSHAPE_H_
 
 #include "bhkShape.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -22,7 +24,7 @@ public:
 	~bhkSphereRepShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -31,8 +33,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_SPHERE_REP_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkSphereShape.cpp b/obj/bhkSphereShape.cpp
index cdb7c1219bfafed62cb30994d02cece4333d4a8c..2499b7f423565da0e508f74696f31ab361f7a1c5 100644
--- a/obj/bhkSphereShape.cpp
+++ b/obj/bhkSphereShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkSphereShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkSphereShape::TYPE("bhkSphereShape", &BHK_SPHERE_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkSphereShape.h b/obj/bhkSphereShape.h
index 5e082860f92ddbd51b9e803bf2cfd31e92510422..e10429db16e1ef84c3aa4b92226f04db0cabf7df 100644
--- a/obj/bhkSphereShape.h
+++ b/obj/bhkSphereShape.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKSPHERESHAPE_H_
 
 #include "bhkConvexShape.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~bhkSphereShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_SPHERE_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkStiffSpringConstraint.cpp b/obj/bhkStiffSpringConstraint.cpp
index 2d96ad990339d3f611e3e54e32230665111a5d33..992a86e472b1e7df836a19f914c41aa409e3e489 100644
--- a/obj/bhkStiffSpringConstraint.cpp
+++ b/obj/bhkStiffSpringConstraint.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkStiffSpringConstraint.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkStiffSpringConstraint::TYPE("bhkStiffSpringConstraint", &BHK_STIFF_SPRING_CONSTRAINT_PARENT::TypeConst() );
diff --git a/obj/bhkStiffSpringConstraint.h b/obj/bhkStiffSpringConstraint.h
index c86b6f859002601b42e8e39285fd341e85d5855e..46dd61cbccf79f181ea013729728cfb9bde3ea00 100644
--- a/obj/bhkStiffSpringConstraint.h
+++ b/obj/bhkStiffSpringConstraint.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKSTIFFSPRINGCONSTRAINT_H_
 
 #include "AbhkConstraint.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkStiffSpringConstraint();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_STIFF_SPRING_CONSTRAINT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkTransformShape.cpp b/obj/bhkTransformShape.cpp
index a8b5718277f68bc414a47f90ea79359088b5f73d..c037cba90f7550efa1d1ac31f3d9cb7fcac71e5c 100644
--- a/obj/bhkTransformShape.cpp
+++ b/obj/bhkTransformShape.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkTransformShape.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkTransformShape::TYPE("bhkTransformShape", &BHK_TRANSFORM_SHAPE_PARENT::TypeConst() );
diff --git a/obj/bhkTransformShape.h b/obj/bhkTransformShape.h
index 538be5ee2ddeede92a8fa3c7f456b8da52d1456a..c44f82a1a1f90d22de41939c6a3fd50292c56b73 100644
--- a/obj/bhkTransformShape.h
+++ b/obj/bhkTransformShape.h
@@ -5,6 +5,8 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKTRANSFORMSHAPE_H_
 
 #include "bhkEntity.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +23,7 @@ public:
 	~bhkTransformShape();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +32,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_TRANSFORM_SHAPE_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/bhkWorldObject.cpp b/obj/bhkWorldObject.cpp
index 99c7795ffd1bc752323613c2a742f69862dc6a82..312ac15d368d7738ff8b2e4f9286a41656677dd2 100644
--- a/obj/bhkWorldObject.cpp
+++ b/obj/bhkWorldObject.cpp
@@ -2,6 +2,7 @@
 All rights reserved.  Please see niflib.h for licence. */
 
 #include "bhkWorldObject.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type bhkWorldObject::TYPE("bhkWorldObject", &BHK_WORLD_OBJECT_PARENT::TypeConst() );
diff --git a/obj/bhkWorldObject.h b/obj/bhkWorldObject.h
index 3b56b2e33546b2b512cdf2d8012adfb5524e52fc..52c5e03e4384ffa9e9e638993b0c7165854b3cf6 100644
--- a/obj/bhkWorldObject.h
+++ b/obj/bhkWorldObject.h
@@ -5,6 +5,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _BHKWORLDOBJECT_H_
 
 #include "bhkShape.h"
+namespace NifLib {
 
 #include "../gen/obj_defines.h"
 
@@ -21,7 +22,7 @@ public:
 	~bhkWorldObject();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -30,8 +31,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	BHK_WORLD_OBJECT_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/obj/hkPackedNiTriStripsData.cpp b/obj/hkPackedNiTriStripsData.cpp
index f81d6e023f4b02d5da6f1e5c8d670b96b9b1cae5..514f2fed7bd799db5a08bcbb2b4840bcf0891ce5 100644
--- a/obj/hkPackedNiTriStripsData.cpp
+++ b/obj/hkPackedNiTriStripsData.cpp
@@ -3,6 +3,7 @@ All rights reserved.  Please see niflib.h for licence. */
 
 #include "hkPackedNiTriStripsData.h"
 #include "../gen/hkTriangle.h"
+using namespace NifLib;
 
 //Definition of TYPE constant
 const Type hkPackedNiTriStripsData::TYPE("hkPackedNiTriStripsData", &HK_PACKED_NI_TRI_STRIPS_DATA_PARENT::TypeConst() );
diff --git a/obj/hkPackedNiTriStripsData.h b/obj/hkPackedNiTriStripsData.h
index 53e05dc45af677d519513485e9ae68b808a33c32..adc91bd5ab4de7a6ff5dcd0827a006f690ae10a0 100644
--- a/obj/hkPackedNiTriStripsData.h
+++ b/obj/hkPackedNiTriStripsData.h
@@ -5,8 +5,11 @@ All rights reserved.  Please see niflib.h for licence. */
 #define _HKPACKEDNITRISTRIPSDATA_H_
 
 #include "AbhkShapeCollection.h"
+
 // Include structures
 #include "../gen/hkTriangle.h"
+namespace NifLib {
+
 
 #include "../gen/obj_defines.h"
 
@@ -23,7 +26,7 @@ public:
 	~hkPackedNiTriStripsData();
 	//Run-Time Type Information
 	static const Type & TypeConst() { return TYPE; }
-private:	
+private:
 	static const Type TYPE;
 public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version, unsigned int user_version );
@@ -32,8 +35,11 @@ public:
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
 	virtual list<NiObjectRef> GetRefs() const;
 	virtual const Type & GetType() const;
+
 protected:
 	HK_PACKED_NI_TRI_STRIPS_DATA_MEMBERS
+	STANDARD_INTERNAL_METHODS
 };
 
+}
 #endif
diff --git a/pch.h b/pch.h
index 4deff492cd5ec36b3512c9ef00a51ad693c91089..2cd284a16c7f6e4182a77228e8e5c66f831b6e07 100644
--- a/pch.h
+++ b/pch.h
@@ -2,12 +2,12 @@
 
 //Trying to pre-compile only generated headers
 
-//#include "dll_export.h"
-//#include "NIF_IO.h"
-//#include "nif_math.h"
-//#include "niflib.h"
-//#include "Ref.h"
-//#include "Type.h"
+#include "dll_export.h"
+#include "NIF_IO.h"
+#include "nif_math.h"
+#include "niflib.h"
+#include "Ref.h"
+#include "Type.h"
 
 #include "gen/AVObject.h"
 #include "gen/BoundingBox.h"
@@ -41,216 +41,216 @@
 #include "gen/TexDesc.h"
 #include "gen/TexSource.h"
 
-//#include "obj/AbhkConstraint.h"
-//#include "obj/AbhkRagdollConstraint.h"
-//#include "obj/AbhkShapeCollection.h"
-//#include "obj/ABoneLODController.h"
-//#include "obj/AKeyedData.h"
-//#include "obj/AParticleModifier.h"
-//#include "obj/APSysCtlr.h"
-//#include "obj/APSysData.h"
-//#include "obj/AvoidNode.h"
-//#include "obj/bhkBlendCollisionObject.h"
-//#include "obj/bhkBlendController.h"
-//#include "obj/bhkBoxShape.h"
-//#include "obj/bhkCapsuleShape.h"
-//#include "obj/bhkCollisionObject.h"
-//#include "obj/bhkConvexShape.h"
-//#include "obj/bhkConvexTransformShape.h"
-//#include "obj/bhkConvexVerticesShape.h"
-//#include "obj/bhkEntity.h"
-//#include "obj/bhkHingeConstraint.h"
-//#include "obj/bhkLimitedHingeConstraint.h"
-//#include "obj/bhkListShape.h"
-//#include "obj/bhkMalleableConstraint.h"
-//#include "obj/bhkMoppBvTreeShape.h"
-//#include "obj/bhkMultiSphereShape.h"
-//#include "obj/bhkNiTriStripsShape.h"
-//#include "obj/bhkPackedNiTriStripsShape.h"
-//#include "obj/bhkPrismaticConstraint.h"
-//#include "obj/bhkRagdollConstraint.h"
-//#include "obj/bhkRefObject.h"
-//#include "obj/bhkRigidBody.h"
-//#include "obj/bhkRigidBodyT.h"
-//#include "obj/bhkSerializable.h"
-//#include "obj/bhkShape.h"
-//#include "obj/bhkSimpleShapePhantom.h"
-//#include "obj/bhkSPCollisionObject.h"
-//#include "obj/bhkSphereRepShape.h"
-//#include "obj/bhkSphereShape.h"
-//#include "obj/bhkStiffSpringConstraint.h"
-//#include "obj/bhkTransformShape.h"
-//#include "obj/bhkWorldObject.h"
-//#include "obj/BSBound.h"
-//#include "obj/BSFurnitureMarker.h"
-//#include "obj/BSKeyframeController.h"
-//#include "obj/BSParentVelocityModifier.h"
-//#include "obj/BSPSysArrayEmitter.h"
-//#include "obj/BSXFlags.h"
-//#include "obj/FxButton.h"
-//#include "obj/FxRadioButton.h"
-//#include "obj/FxWidget.h"
-//#include "obj/hkPackedNiTriStripsData.h"
-//#include "obj/NiAlphaController.h"
-//#include "obj/NiAlphaProperty.h"
-//#include "obj/NiAmbientLight.h"
-//#include "obj/NiAutoNormalParticles.h"
-//#include "obj/NiAutoNormalParticlesData.h"
-//#include "obj/NiAVObject.h"
-//#include "obj/NiBillboardNode.h"
-//#include "obj/NiBinaryExtraData.h"
-//#include "obj/NiBlendBoolInterpolator.h"
-//#include "obj/NiBlendFloatInterpolator.h"
-//#include "obj/NiBlendInterpolator.h"
-//#include "obj/NiBlendPoint3Interpolator.h"
-//#include "obj/NiBlendTransformInterpolator.h"
-//#include "obj/NiBoneLODController.h"
-//#include "obj/NiBoolData.h"
-//#include "obj/NiBooleanExtraData.h"
-//#include "obj/NiBoolInterpolator.h"
-//#include "obj/NiBoolTimelineInterpolator.h"
-//#include "obj/NiBSAnimationNode.h"
-//#include "obj/NiBSBoneLODController.h"
-//#include "obj/NiBSPArrayController.h"
-//#include "obj/NiBSParticleNode.h"
-//#include "obj/NiBSplineBasisData.h"
-//#include "obj/NiBSplineCompFloatInterpolator.h"
-//#include "obj/NiBSplineCompPoint3Interpolator.h"
-//#include "obj/NiBSplineCompTransformInterpolator.h"
-//#include "obj/NiBSplineData.h"
-//#include "obj/NiBSplineInterpolator.h"
-//#include "obj/NiCamera.h"
-//#include "obj/NiCollisionData.h"
-//#include "obj/NiCollisionObject.h"
-//#include "obj/NiColorData.h"
-//#include "obj/NiColorExtraData.h"
-//#include "obj/NiControllerManager.h"
-//#include "obj/NiControllerSequence.h"
-//#include "obj/NiDefaultAVObjectPalette.h"
-//#include "obj/NiDirectionalLight.h"
-//#include "obj/NiDitherProperty.h"
-//#include "obj/NiDynamicEffect.h"
-//#include "obj/NiExtraData.h"
-//#include "obj/NiFlipController.h"
-//#include "obj/NiFloatData.h"
-//#include "obj/NiFloatExtraData.h"
-//#include "obj/NiFloatExtraDataController.h"
-//#include "obj/NiFloatInterpolator.h"
-//#include "obj/NiFloatsExtraData.h"
-//#include "obj/NiFogProperty.h"
-//#include "obj/NiGeomMorpherController.h"
-//#include "obj/NiGravity.h"
-//#include "obj/NiIntegerExtraData.h"
-//#include "obj/NiIntegersExtraData.h"
-//#include "obj/NiInterpolator.h"
-//#include "obj/NiKeyframeController.h"
-//#include "obj/NiKeyframeData.h"
-//#include "obj/NiLight.h"
-//#include "obj/NiLightColorController.h"
-//#include "obj/NiLightDimmerController.h"
-//#include "obj/NiLODNode.h"
-//#include "obj/NiLookAtController.h"
-//#include "obj/NiLookAtInterpolator.h"
-//#include "obj/NiMaterialColorController.h"
-//#include "obj/NiMaterialProperty.h"
-//#include "obj/NiMeshParticleSystem.h"
-//#include "obj/NiMeshPSysData.h"
-//#include "obj/NiMorphData.h"
-//#include "obj/NiMultiTargetTransformController.h"
-//#include "obj/NiNode.h"
-//#include "obj/NiObject.h"
-//#include "obj/NiObjectNET.h"
-//#include "obj/NiPalette.h"
-//#include "obj/NiParticleBomb.h"
-//#include "obj/NiParticleColorModifier.h"
-//#include "obj/NiParticleGrowFade.h"
-//#include "obj/NiParticleMeshes.h"
-//#include "obj/NiParticleMeshesData.h"
-//#include "obj/NiParticleMeshModifier.h"
-//#include "obj/NiParticleRotation.h"
-//#include "obj/NiParticles.h"
-//#include "obj/NiParticlesData.h"
-//#include "obj/NiParticleSystem.h"
-//#include "obj/NiParticleSystemController.h"
-//#include "obj/NiPathController.h"
-//#include "obj/NiPathInterpolator.h"
-//#include "obj/NiPixelData.h"
-//#include "obj/NiPlanarCollider.h"
-//#include "obj/NiPoint3Interpolator.h"
-//#include "obj/NiPointLight.h"
-//#include "obj/NiPosData.h"
-//#include "obj/NiProperty.h"
-//#include "obj/NiPSysAgeDeathModifier.h"
-//#include "obj/NiPSysBombModifier.h"
-//#include "obj/NiPSysBoundUpdateModifier.h"
-//#include "obj/NiPSysBoxEmitter.h"
-//#include "obj/NiPSysColliderManager.h"
-//#include "obj/NiPSysColorModifier.h"
-//#include "obj/NiPSysCylinderEmitter.h"
-//#include "obj/NiPSysData.h"
-//#include "obj/NiPSysDragModifier.h"
-//#include "obj/NiPSysEmitter.h"
-//#include "obj/NiPSysEmitterCtlr.h"
-//#include "obj/NiPSysEmitterCtlrData.h"
-//#include "obj/NiPSysEmitterDeclinationCtlr.h"
-//#include "obj/NiPSysEmitterDeclinationVarCtlr.h"
-//#include "obj/NiPSysEmitterInitialRadiusCtlr.h"
-//#include "obj/NiPSysEmitterLifeSpanCtlr.h"
-//#include "obj/NiPSysEmitterSpeedCtlr.h"
-//#include "obj/NiPSysGravityModifier.h"
-//#include "obj/NiPSysGravityStrengthCtlr.h"
-//#include "obj/NiPSysGrowFadeModifier.h"
-//#include "obj/NiPSysMeshEmitter.h"
-//#include "obj/NiPSysMeshUpdateModifier.h"
-//#include "obj/NiPSysModifier.h"
-//#include "obj/NiPSysModifierActiveCtlr.h"
-//#include "obj/NiPSysPlanarCollider.h"
-//#include "obj/NiPSysPositionModifier.h"
-//#include "obj/NiPSysResetOnLoopCtlr.h"
-//#include "obj/NiPSysRotationModifier.h"
-//#include "obj/NiPSysSpawnModifier.h"
-//#include "obj/NiPSysSphereEmitter.h"
-//#include "obj/NiPSysUpdateCtlr.h"
-//#include "obj/NiPSysVolumeEmitter.h"
-//#include "obj/NiRangeLODData.h"
-//#include "obj/NiRotatingParticles.h"
-//#include "obj/NiRotatingParticlesData.h"
-//#include "obj/NiScreenLODData.h"
-//#include "obj/NiSequenceStreamHelper.h"
-//#include "obj/NiShadeProperty.h"
-//#include "obj/NiSingleInterpolatorController.h"
-//#include "obj/NiSkinData.h"
-//#include "obj/NiSkinInstance.h"
-//#include "obj/NiSkinPartition.h"
-//#include "obj/NiSourceTexture.h"
-//#include "obj/NiSpecularProperty.h"
-//#include "obj/NiSphericalCollider.h"
-//#include "obj/NiSpotLight.h"
-//#include "obj/NiStencilProperty.h"
-//#include "obj/NiStringExtraData.h"
-//#include "obj/NiStringPalette.h"
-//#include "obj/NiStringsExtraData.h"
-//#include "obj/NiTextKeyExtraData.h"
-//#include "obj/NiTextureEffect.h"
-//#include "obj/NiTextureTransformController.h"
-//#include "obj/NiTexturingProperty.h"
-//#include "obj/NiTimeController.h"
-//#include "obj/NiTransformController.h"
-//#include "obj/NiTransformData.h"
-//#include "obj/NiTransformInterpolator.h"
-//#include "obj/NiTriBasedGeom.h"
-//#include "obj/NiTriBasedGeomData.h"
-//#include "obj/NiTriShape.h"
-//#include "obj/NiTriShapeData.h"
-//#include "obj/NiTriStrips.h"
-//#include "obj/NiTriStripsData.h"
-//#include "obj/NiUVController.h"
-//#include "obj/NiUVData.h"
-//#include "obj/NiVectorExtraData.h"
-//#include "obj/NiVertexColorProperty.h"
-//#include "obj/NiVertWeightsExtraData.h"
-//#include "obj/NiVisController.h"
-//#include "obj/NiVisData.h"
-//#include "obj/NiWireframeProperty.h"
-//#include "obj/NiZBufferProperty.h"
-//#include "obj/RootCollisionNode.h"
\ No newline at end of file
+#include "obj/AbhkConstraint.h"
+#include "obj/AbhkRagdollConstraint.h"
+#include "obj/AbhkShapeCollection.h"
+#include "obj/ABoneLODController.h"
+#include "obj/AKeyedData.h"
+#include "obj/AParticleModifier.h"
+#include "obj/APSysCtlr.h"
+#include "obj/APSysData.h"
+#include "obj/AvoidNode.h"
+#include "obj/bhkBlendCollisionObject.h"
+#include "obj/bhkBlendController.h"
+#include "obj/bhkBoxShape.h"
+#include "obj/bhkCapsuleShape.h"
+#include "obj/bhkCollisionObject.h"
+#include "obj/bhkConvexShape.h"
+#include "obj/bhkConvexTransformShape.h"
+#include "obj/bhkConvexVerticesShape.h"
+#include "obj/bhkEntity.h"
+#include "obj/bhkHingeConstraint.h"
+#include "obj/bhkLimitedHingeConstraint.h"
+#include "obj/bhkListShape.h"
+#include "obj/bhkMalleableConstraint.h"
+#include "obj/bhkMoppBvTreeShape.h"
+#include "obj/bhkMultiSphereShape.h"
+#include "obj/bhkNiTriStripsShape.h"
+#include "obj/bhkPackedNiTriStripsShape.h"
+#include "obj/bhkPrismaticConstraint.h"
+#include "obj/bhkRagdollConstraint.h"
+#include "obj/bhkRefObject.h"
+#include "obj/bhkRigidBody.h"
+#include "obj/bhkRigidBodyT.h"
+#include "obj/bhkSerializable.h"
+#include "obj/bhkShape.h"
+#include "obj/bhkSimpleShapePhantom.h"
+#include "obj/bhkSPCollisionObject.h"
+#include "obj/bhkSphereRepShape.h"
+#include "obj/bhkSphereShape.h"
+#include "obj/bhkStiffSpringConstraint.h"
+#include "obj/bhkTransformShape.h"
+#include "obj/bhkWorldObject.h"
+#include "obj/BSBound.h"
+#include "obj/BSFurnitureMarker.h"
+#include "obj/BSKeyframeController.h"
+#include "obj/BSParentVelocityModifier.h"
+#include "obj/BSPSysArrayEmitter.h"
+#include "obj/BSXFlags.h"
+#include "obj/FxButton.h"
+#include "obj/FxRadioButton.h"
+#include "obj/FxWidget.h"
+#include "obj/hkPackedNiTriStripsData.h"
+#include "obj/NiAlphaController.h"
+#include "obj/NiAlphaProperty.h"
+#include "obj/NiAmbientLight.h"
+#include "obj/NiAutoNormalParticles.h"
+#include "obj/NiAutoNormalParticlesData.h"
+#include "obj/NiAVObject.h"
+#include "obj/NiBillboardNode.h"
+#include "obj/NiBinaryExtraData.h"
+#include "obj/NiBlendBoolInterpolator.h"
+#include "obj/NiBlendFloatInterpolator.h"
+#include "obj/NiBlendInterpolator.h"
+#include "obj/NiBlendPoint3Interpolator.h"
+#include "obj/NiBlendTransformInterpolator.h"
+#include "obj/NiBoneLODController.h"
+#include "obj/NiBoolData.h"
+#include "obj/NiBooleanExtraData.h"
+#include "obj/NiBoolInterpolator.h"
+#include "obj/NiBoolTimelineInterpolator.h"
+#include "obj/NiBSAnimationNode.h"
+#include "obj/NiBSBoneLODController.h"
+#include "obj/NiBSPArrayController.h"
+#include "obj/NiBSParticleNode.h"
+#include "obj/NiBSplineBasisData.h"
+#include "obj/NiBSplineCompFloatInterpolator.h"
+#include "obj/NiBSplineCompPoint3Interpolator.h"
+#include "obj/NiBSplineCompTransformInterpolator.h"
+#include "obj/NiBSplineData.h"
+#include "obj/NiBSplineInterpolator.h"
+#include "obj/NiCamera.h"
+#include "obj/NiCollisionData.h"
+#include "obj/NiCollisionObject.h"
+#include "obj/NiColorData.h"
+#include "obj/NiColorExtraData.h"
+#include "obj/NiControllerManager.h"
+#include "obj/NiControllerSequence.h"
+#include "obj/NiDefaultAVObjectPalette.h"
+#include "obj/NiDirectionalLight.h"
+#include "obj/NiDitherProperty.h"
+#include "obj/NiDynamicEffect.h"
+#include "obj/NiExtraData.h"
+#include "obj/NiFlipController.h"
+#include "obj/NiFloatData.h"
+#include "obj/NiFloatExtraData.h"
+#include "obj/NiFloatExtraDataController.h"
+#include "obj/NiFloatInterpolator.h"
+#include "obj/NiFloatsExtraData.h"
+#include "obj/NiFogProperty.h"
+#include "obj/NiGeomMorpherController.h"
+#include "obj/NiGravity.h"
+#include "obj/NiIntegerExtraData.h"
+#include "obj/NiIntegersExtraData.h"
+#include "obj/NiInterpolator.h"
+#include "obj/NiKeyframeController.h"
+#include "obj/NiKeyframeData.h"
+#include "obj/NiLight.h"
+#include "obj/NiLightColorController.h"
+#include "obj/NiLightDimmerController.h"
+#include "obj/NiLODNode.h"
+#include "obj/NiLookAtController.h"
+#include "obj/NiLookAtInterpolator.h"
+#include "obj/NiMaterialColorController.h"
+#include "obj/NiMaterialProperty.h"
+#include "obj/NiMeshParticleSystem.h"
+#include "obj/NiMeshPSysData.h"
+#include "obj/NiMorphData.h"
+#include "obj/NiMultiTargetTransformController.h"
+#include "obj/NiNode.h"
+#include "obj/NiObject.h"
+#include "obj/NiObjectNET.h"
+#include "obj/NiPalette.h"
+#include "obj/NiParticleBomb.h"
+#include "obj/NiParticleColorModifier.h"
+#include "obj/NiParticleGrowFade.h"
+#include "obj/NiParticleMeshes.h"
+#include "obj/NiParticleMeshesData.h"
+#include "obj/NiParticleMeshModifier.h"
+#include "obj/NiParticleRotation.h"
+#include "obj/NiParticles.h"
+#include "obj/NiParticlesData.h"
+#include "obj/NiParticleSystem.h"
+#include "obj/NiParticleSystemController.h"
+#include "obj/NiPathController.h"
+#include "obj/NiPathInterpolator.h"
+#include "obj/NiPixelData.h"
+#include "obj/NiPlanarCollider.h"
+#include "obj/NiPoint3Interpolator.h"
+#include "obj/NiPointLight.h"
+#include "obj/NiPosData.h"
+#include "obj/NiProperty.h"
+#include "obj/NiPSysAgeDeathModifier.h"
+#include "obj/NiPSysBombModifier.h"
+#include "obj/NiPSysBoundUpdateModifier.h"
+#include "obj/NiPSysBoxEmitter.h"
+#include "obj/NiPSysColliderManager.h"
+#include "obj/NiPSysColorModifier.h"
+#include "obj/NiPSysCylinderEmitter.h"
+#include "obj/NiPSysData.h"
+#include "obj/NiPSysDragModifier.h"
+#include "obj/NiPSysEmitter.h"
+#include "obj/NiPSysEmitterCtlr.h"
+#include "obj/NiPSysEmitterCtlrData.h"
+#include "obj/NiPSysEmitterDeclinationCtlr.h"
+#include "obj/NiPSysEmitterDeclinationVarCtlr.h"
+#include "obj/NiPSysEmitterInitialRadiusCtlr.h"
+#include "obj/NiPSysEmitterLifeSpanCtlr.h"
+#include "obj/NiPSysEmitterSpeedCtlr.h"
+#include "obj/NiPSysGravityModifier.h"
+#include "obj/NiPSysGravityStrengthCtlr.h"
+#include "obj/NiPSysGrowFadeModifier.h"
+#include "obj/NiPSysMeshEmitter.h"
+#include "obj/NiPSysMeshUpdateModifier.h"
+#include "obj/NiPSysModifier.h"
+#include "obj/NiPSysModifierActiveCtlr.h"
+#include "obj/NiPSysPlanarCollider.h"
+#include "obj/NiPSysPositionModifier.h"
+#include "obj/NiPSysResetOnLoopCtlr.h"
+#include "obj/NiPSysRotationModifier.h"
+#include "obj/NiPSysSpawnModifier.h"
+#include "obj/NiPSysSphereEmitter.h"
+#include "obj/NiPSysUpdateCtlr.h"
+#include "obj/NiPSysVolumeEmitter.h"
+#include "obj/NiRangeLODData.h"
+#include "obj/NiRotatingParticles.h"
+#include "obj/NiRotatingParticlesData.h"
+#include "obj/NiScreenLODData.h"
+#include "obj/NiSequenceStreamHelper.h"
+#include "obj/NiShadeProperty.h"
+#include "obj/NiSingleInterpolatorController.h"
+#include "obj/NiSkinData.h"
+#include "obj/NiSkinInstance.h"
+#include "obj/NiSkinPartition.h"
+#include "obj/NiSourceTexture.h"
+#include "obj/NiSpecularProperty.h"
+#include "obj/NiSphericalCollider.h"
+#include "obj/NiSpotLight.h"
+#include "obj/NiStencilProperty.h"
+#include "obj/NiStringExtraData.h"
+#include "obj/NiStringPalette.h"
+#include "obj/NiStringsExtraData.h"
+#include "obj/NiTextKeyExtraData.h"
+#include "obj/NiTextureEffect.h"
+#include "obj/NiTextureTransformController.h"
+#include "obj/NiTexturingProperty.h"
+#include "obj/NiTimeController.h"
+#include "obj/NiTransformController.h"
+#include "obj/NiTransformData.h"
+#include "obj/NiTransformInterpolator.h"
+#include "obj/NiTriBasedGeom.h"
+#include "obj/NiTriBasedGeomData.h"
+#include "obj/NiTriShape.h"
+#include "obj/NiTriShapeData.h"
+#include "obj/NiTriStrips.h"
+#include "obj/NiTriStripsData.h"
+#include "obj/NiUVController.h"
+#include "obj/NiUVData.h"
+#include "obj/NiVectorExtraData.h"
+#include "obj/NiVertexColorProperty.h"
+#include "obj/NiVertWeightsExtraData.h"
+#include "obj/NiVisController.h"
+#include "obj/NiVisData.h"
+#include "obj/NiWireframeProperty.h"
+#include "obj/NiZBufferProperty.h"
+#include "obj/RootCollisionNode.h"
\ No newline at end of file