From 0a110d57497d7acf1c60adbe08e3abbdf2830407 Mon Sep 17 00:00:00 2001
From: Tazpn <tazpn@users.sourceforge.net>
Date: Sun, 18 Jun 2006 20:48:37 +0000
Subject: [PATCH] Major update to python generation scripts and others. 
 Currently just namepace and mutable size members with appropriate generated
 code.

---
 NIF_IO.cpp                                 |     5 +-
 NIF_IO.h                                   |   154 +-
 Ref.h                                      |   256 +-
 Type.cpp                                   |     3 +-
 Type.h                                     |     2 +
 gen/AVObject.cpp                           |     1 +
 gen/AVObject.h                             |     3 +
 gen/BoundingBox.cpp                        |     1 +
 gen/BoundingBox.h                          |     3 +
 gen/ByteArray.cpp                          |     1 +
 gen/ByteArray.h                            |     5 +-
 gen/ControllerLink.cpp                     |     1 +
 gen/ControllerLink.h                       |     2 +
 gen/Footer.cpp                             |     3 +
 gen/Footer.h                               |     6 +-
 gen/FurniturePosition.cpp                  |     1 +
 gen/FurniturePosition.h                    |     3 +
 gen/Header.cpp                             |    12 +-
 gen/Header.h                               |     9 +-
 gen/KeyGroup.h                             |     5 +-
 gen/LODRange.cpp                           |     1 +
 gen/LODRange.h                             |     3 +
 gen/LimitedHingeDescriptor.cpp             |     1 +
 gen/LimitedHingeDescriptor.h               |     3 +
 gen/MatchGroup.cpp                         |     1 +
 gen/MatchGroup.h                           |     5 +-
 gen/MipMap.cpp                             |     1 +
 gen/MipMap.h                               |     3 +
 gen/Morph.cpp                              |     1 +
 gen/Morph.h                                |     5 +-
 gen/NodeGroup.cpp                          |     1 +
 gen/NodeGroup.h                            |     4 +-
 gen/Particle.cpp                           |     1 +
 gen/Particle.h                             |     3 +
 gen/QuaternionXYZW.cpp                     |     1 +
 gen/QuaternionXYZW.h                       |     3 +
 gen/RagDollDescriptor.cpp                  |     1 +
 gen/RagDollDescriptor.h                    |     3 +
 gen/RotationKeyArray.h                     |     5 +-
 gen/ShaderTexDesc.cpp                      |     1 +
 gen/ShaderTexDesc.h                        |     3 +
 gen/ShortString.cpp                        |     1 +
 gen/ShortString.h                          |     5 +-
 gen/SkinData.cpp                           |     1 +
 gen/SkinData.h                             |     7 +-
 gen/SkinPartition.cpp                      |    14 +
 gen/SkinPartition.h                        |    19 +-
 gen/SkinShape.cpp                          |     1 +
 gen/SkinShape.h                            |     2 +
 gen/SkinShapeGroup.cpp                     |     1 +
 gen/SkinShapeGroup.h                       |     5 +-
 gen/SkinWeight.cpp                         |     1 +
 gen/SkinWeight.h                           |     3 +
 gen/StringPalette.cpp                      |     1 +
 gen/StringPalette.h                        |     3 +
 gen/TBC.cpp                                |     1 +
 gen/TBC.h                                  |     3 +
 gen/TexDesc.cpp                            |     1 +
 gen/TexDesc.h                              |     2 +
 gen/TexSource.cpp                          |     1 +
 gen/TexSource.h                            |     2 +
 gen/hkTriangle.cpp                         |     1 +
 gen/hkTriangle.h                           |     3 +
 gen/obj_defines.h                          | 10999 ++-----------------
 gen/obj_factories.cpp                      |     6 +
 nif_math.cpp                               |    32 +-
 nif_math.h                                 |     8 +
 niflib.cpp                                 |    52 +-
 niflib.h                                   |    16 +
 niflib.vcproj                              |   106 +-
 obj/ABoneLODController.cpp                 |     1 +
 obj/ABoneLODController.h                   |     7 +-
 obj/AKeyedData.cpp                         |     1 +
 obj/AKeyedData.h                           |     6 +-
 obj/APSysCtlr.cpp                          |     1 +
 obj/APSysCtlr.h                            |     7 +-
 obj/APSysData.cpp                          |     1 +
 obj/APSysData.h                            |     6 +-
 obj/AParticleModifier.cpp                  |     1 +
 obj/AParticleModifier.h                    |    10 +-
 obj/AbhkConstraint.cpp                     |     1 +
 obj/AbhkConstraint.h                       |     7 +-
 obj/AbhkRagdollConstraint.cpp              |     1 +
 obj/AbhkRagdollConstraint.h                |     7 +-
 obj/AbhkShapeCollection.cpp                |     1 +
 obj/AbhkShapeCollection.h                  |     6 +-
 obj/AvoidNode.cpp                          |     1 +
 obj/AvoidNode.h                            |     6 +-
 obj/BSBound.cpp                            |     1 +
 obj/BSBound.h                              |     6 +-
 obj/BSFurnitureMarker.cpp                  |     1 +
 obj/BSFurnitureMarker.h                    |     7 +-
 obj/BSKeyframeController.cpp               |     1 +
 obj/BSKeyframeController.h                 |    10 +-
 obj/BSPSysArrayEmitter.cpp                 |     1 +
 obj/BSPSysArrayEmitter.h                   |     6 +-
 obj/BSParentVelocityModifier.cpp           |     1 +
 obj/BSParentVelocityModifier.h             |     6 +-
 obj/BSXFlags.cpp                           |     1 +
 obj/BSXFlags.h                             |     6 +-
 obj/FxButton.cpp                           |     1 +
 obj/FxButton.h                             |     6 +-
 obj/FxRadioButton.cpp                      |     1 +
 obj/FxRadioButton.h                        |    10 +-
 obj/FxWidget.cpp                           |     1 +
 obj/FxWidget.h                             |     6 +-
 obj/NiAVObject.cpp                         |     1 +
 obj/NiAVObject.h                           |    12 +-
 obj/NiAlphaController.cpp                  |     1 +
 obj/NiAlphaController.h                    |    10 +-
 obj/NiAlphaProperty.cpp                    |    53 +
 obj/NiAlphaProperty.h                      |    48 +
 obj/NiAmbientLight.cpp                     |     1 +
 obj/NiAmbientLight.h                       |     6 +-
 obj/NiAutoNormalParticles.cpp              |     1 +
 obj/NiAutoNormalParticles.h                |     6 +-
 obj/NiAutoNormalParticlesData.cpp          |     1 +
 obj/NiAutoNormalParticlesData.h            |     7 +-
 obj/NiBSAnimationNode.cpp                  |     1 +
 obj/NiBSAnimationNode.h                    |     6 +-
 obj/NiBSBoneLODController.cpp              |     1 +
 obj/NiBSBoneLODController.h                |     6 +-
 obj/NiBSPArrayController.cpp               |     1 +
 obj/NiBSPArrayController.h                 |     6 +-
 obj/NiBSParticleNode.cpp                   |     1 +
 obj/NiBSParticleNode.h                     |     6 +-
 obj/NiBSplineBasisData.cpp                 |     1 +
 obj/NiBSplineBasisData.h                   |     6 +-
 obj/NiBSplineCompFloatInterpolator.cpp     |     1 +
 obj/NiBSplineCompFloatInterpolator.h       |     6 +-
 obj/NiBSplineCompPoint3Interpolator.cpp    |     1 +
 obj/NiBSplineCompPoint3Interpolator.h      |    10 +-
 obj/NiBSplineCompTransformInterpolator.cpp |     1 +
 obj/NiBSplineCompTransformInterpolator.h   |    10 +-
 obj/NiBSplineData.cpp                      |     1 +
 obj/NiBSplineData.h                        |     8 +-
 obj/NiBSplineInterpolator.cpp              |     1 +
 obj/NiBSplineInterpolator.h                |     7 +-
 obj/NiBillboardNode.cpp                    |     1 +
 obj/NiBillboardNode.h                      |     7 +-
 obj/NiBinaryExtraData.cpp                  |     1 +
 obj/NiBinaryExtraData.h                    |     3 +
 obj/NiBlendBoolInterpolator.cpp            |     1 +
 obj/NiBlendBoolInterpolator.h              |     7 +-
 obj/NiBlendFloatInterpolator.cpp           |     1 +
 obj/NiBlendFloatInterpolator.h             |     7 +-
 obj/NiBlendInterpolator.cpp                |     1 +
 obj/NiBlendInterpolator.h                  |     6 +-
 obj/NiBlendPoint3Interpolator.cpp          |     1 +
 obj/NiBlendPoint3Interpolator.h            |     7 +-
 obj/NiBlendTransformInterpolator.cpp       |     1 +
 obj/NiBlendTransformInterpolator.h         |     6 +-
 obj/NiBoneLODController.cpp                |     1 +
 obj/NiBoneLODController.h                  |     9 +-
 obj/NiBoolData.cpp                         |     1 +
 obj/NiBoolData.h                           |     3 +
 obj/NiBoolInterpolator.cpp                 |     1 +
 obj/NiBoolInterpolator.h                   |    10 +-
 obj/NiBoolTimelineInterpolator.cpp         |     1 +
 obj/NiBoolTimelineInterpolator.h           |    10 +-
 obj/NiBooleanExtraData.cpp                 |     1 +
 obj/NiBooleanExtraData.h                   |     6 +-
 obj/NiCamera.cpp                           |     1 +
 obj/NiCamera.h                             |    10 +-
 obj/NiCollisionData.cpp                    |     1 +
 obj/NiCollisionData.h                      |     7 +-
 obj/NiCollisionObject.cpp                  |     1 +
 obj/NiCollisionObject.h                    |    10 +-
 obj/NiColorData.cpp                        |     1 +
 obj/NiColorData.h                          |     3 +
 obj/NiColorExtraData.cpp                   |     1 +
 obj/NiColorExtraData.h                     |     6 +-
 obj/NiControllerManager.cpp                |     1 +
 obj/NiControllerManager.h                  |     9 +-
 obj/NiControllerSequence.cpp               |     3 +-
 obj/NiControllerSequence.h                 |     7 +-
 obj/NiDefaultAVObjectPalette.cpp           |     1 +
 obj/NiDefaultAVObjectPalette.h             |     8 +-
 obj/NiDirectionalLight.cpp                 |     1 +
 obj/NiDirectionalLight.h                   |     6 +-
 obj/NiDitherProperty.cpp                   |     1 +
 obj/NiDitherProperty.h                     |     6 +-
 obj/NiDynamicEffect.cpp                    |     1 +
 obj/NiDynamicEffect.h                      |    10 +-
 obj/NiExtraData.cpp                        |     1 +
 obj/NiExtraData.h                          |     6 +
 obj/NiFlipController.cpp                   |     1 +
 obj/NiFlipController.h                     |    10 +-
 obj/NiFloatData.cpp                        |     1 +
 obj/NiFloatData.h                          |     3 +
 obj/NiFloatExtraData.cpp                   |     1 +
 obj/NiFloatExtraData.h                     |     8 +-
 obj/NiFloatExtraDataController.cpp         |     1 +
 obj/NiFloatExtraDataController.h           |     9 +-
 obj/NiFloatInterpolator.cpp                |     1 +
 obj/NiFloatInterpolator.h                  |    10 +-
 obj/NiFloatsExtraData.cpp                  |     1 +
 obj/NiFloatsExtraData.h                    |     6 +-
 obj/NiFogProperty.cpp                      |     1 +
 obj/NiFogProperty.h                        |     6 +-
 obj/NiGeomMorpherController.cpp            |     1 +
 obj/NiGeomMorpherController.h              |     9 +-
 obj/NiGravity.cpp                          |     1 +
 obj/NiGravity.h                            |     5 +-
 obj/NiIntegerExtraData.cpp                 |     1 +
 obj/NiIntegerExtraData.h                   |     6 +-
 obj/NiIntegersExtraData.cpp                |     1 +
 obj/NiIntegersExtraData.h                  |    10 +-
 obj/NiInterpolator.cpp                     |     1 +
 obj/NiInterpolator.h                       |     6 +-
 obj/NiKeyframeController.cpp               |     1 +
 obj/NiKeyframeController.h                 |     9 +-
 obj/NiKeyframeData.cpp                     |     1 +
 obj/NiKeyframeData.h                       |     3 +
 obj/NiLODNode.cpp                          |     1 +
 obj/NiLODNode.h                            |     9 +-
 obj/NiLight.cpp                            |     1 +
 obj/NiLight.h                              |     7 +-
 obj/NiLightColorController.cpp             |     1 +
 obj/NiLightColorController.h               |     9 +-
 obj/NiLightDimmerController.cpp            |     1 +
 obj/NiLightDimmerController.h              |    10 +-
 obj/NiLookAtController.cpp                 |     1 +
 obj/NiLookAtController.h                   |    10 +-
 obj/NiLookAtInterpolator.cpp               |     1 +
 obj/NiLookAtInterpolator.h                 |    10 +-
 obj/NiMaterialColorController.cpp          |     1 +
 obj/NiMaterialColorController.h            |    10 +-
 obj/NiMaterialProperty.cpp                 |     1 +
 obj/NiMaterialProperty.h                   |     6 +-
 obj/NiMeshPSysData.cpp                     |     1 +
 obj/NiMeshPSysData.h                       |    10 +-
 obj/NiMeshParticleSystem.cpp               |     1 +
 obj/NiMeshParticleSystem.h                 |     6 +-
 obj/NiMorphData.cpp                        |     1 +
 obj/NiMorphData.h                          |     3 +
 obj/NiMultiTargetTransformController.cpp   |     1 +
 obj/NiMultiTargetTransformController.h     |     7 +-
 obj/NiNode.cpp                             |    32 +-
 obj/NiNode.h                               |    19 +-
 obj/NiObject.cpp                           |     1 +
 obj/NiObject.h                             |    21 +-
 obj/NiObjectNET.cpp                        |     1 +
 obj/NiObjectNET.h                          |    11 +-
 obj/NiPSysAgeDeathModifier.cpp             |     1 +
 obj/NiPSysAgeDeathModifier.h               |    10 +-
 obj/NiPSysBombModifier.cpp                 |     1 +
 obj/NiPSysBombModifier.h                   |     7 +-
 obj/NiPSysBoundUpdateModifier.cpp          |     1 +
 obj/NiPSysBoundUpdateModifier.h            |     7 +-
 obj/NiPSysBoxEmitter.cpp                   |     1 +
 obj/NiPSysBoxEmitter.h                     |     7 +-
 obj/NiPSysColliderManager.cpp              |     1 +
 obj/NiPSysColliderManager.h                |    10 +-
 obj/NiPSysColorModifier.cpp                |     1 +
 obj/NiPSysColorModifier.h                  |    10 +-
 obj/NiPSysCylinderEmitter.cpp              |     1 +
 obj/NiPSysCylinderEmitter.h                |     7 +-
 obj/NiPSysData.cpp                         |     1 +
 obj/NiPSysData.h                           |     6 +-
 obj/NiPSysDragModifier.cpp                 |     1 +
 obj/NiPSysDragModifier.h                   |     7 +-
 obj/NiPSysEmitter.cpp                      |     1 +
 obj/NiPSysEmitter.h                        |     7 +-
 obj/NiPSysEmitterCtlr.cpp                  |     3 +-
 obj/NiPSysEmitterCtlr.h                    |    12 +-
 obj/NiPSysEmitterCtlrData.cpp              |     1 +
 obj/NiPSysEmitterCtlrData.h                |     8 +-
 obj/NiPSysEmitterDeclinationCtlr.cpp       |     1 +
 obj/NiPSysEmitterDeclinationCtlr.h         |     6 +-
 obj/NiPSysEmitterDeclinationVarCtlr.cpp    |     1 +
 obj/NiPSysEmitterDeclinationVarCtlr.h      |     6 +-
 obj/NiPSysEmitterInitialRadiusCtlr.cpp     |     1 +
 obj/NiPSysEmitterInitialRadiusCtlr.h       |     6 +-
 obj/NiPSysEmitterLifeSpanCtlr.cpp          |     1 +
 obj/NiPSysEmitterLifeSpanCtlr.h            |     6 +-
 obj/NiPSysEmitterSpeedCtlr.cpp             |     1 +
 obj/NiPSysEmitterSpeedCtlr.h               |     6 +-
 obj/NiPSysGravityModifier.cpp              |     1 +
 obj/NiPSysGravityModifier.h                |     7 +-
 obj/NiPSysGravityStrengthCtlr.cpp          |     1 +
 obj/NiPSysGravityStrengthCtlr.h            |     6 +-
 obj/NiPSysGrowFadeModifier.cpp             |     1 +
 obj/NiPSysGrowFadeModifier.h               |     7 +-
 obj/NiPSysMeshEmitter.cpp                  |     1 +
 obj/NiPSysMeshEmitter.h                    |    10 +-
 obj/NiPSysMeshUpdateModifier.cpp           |     1 +
 obj/NiPSysMeshUpdateModifier.h             |    10 +-
 obj/NiPSysModifier.cpp                     |     1 +
 obj/NiPSysModifier.h                       |     7 +-
 obj/NiPSysModifierActiveCtlr.cpp           |     1 +
 obj/NiPSysModifierActiveCtlr.h             |     6 +-
 obj/NiPSysPlanarCollider.cpp               |     1 +
 obj/NiPSysPlanarCollider.h                 |    10 +-
 obj/NiPSysPositionModifier.cpp             |     1 +
 obj/NiPSysPositionModifier.h               |     6 +-
 obj/NiPSysResetOnLoopCtlr.cpp              |     1 +
 obj/NiPSysResetOnLoopCtlr.h                |     6 +-
 obj/NiPSysRotationModifier.cpp             |     1 +
 obj/NiPSysRotationModifier.h               |     7 +-
 obj/NiPSysSpawnModifier.cpp                |     1 +
 obj/NiPSysSpawnModifier.h                  |     7 +-
 obj/NiPSysSphereEmitter.cpp                |     1 +
 obj/NiPSysSphereEmitter.h                  |     7 +-
 obj/NiPSysUpdateCtlr.cpp                   |     1 +
 obj/NiPSysUpdateCtlr.h                     |     6 +-
 obj/NiPSysVolumeEmitter.cpp                |     1 +
 obj/NiPSysVolumeEmitter.h                  |     7 +-
 obj/NiPalette.cpp                          |     1 +
 obj/NiPalette.h                            |     3 +
 obj/NiParticleBomb.cpp                     |     1 +
 obj/NiParticleBomb.h                       |     6 +-
 obj/NiParticleColorModifier.cpp            |     1 +
 obj/NiParticleColorModifier.h              |    10 +-
 obj/NiParticleGrowFade.cpp                 |     1 +
 obj/NiParticleGrowFade.h                   |     7 +-
 obj/NiParticleMeshModifier.cpp             |     1 +
 obj/NiParticleMeshModifier.h               |    10 +-
 obj/NiParticleMeshes.cpp                   |     1 +
 obj/NiParticleMeshes.h                     |     6 +-
 obj/NiParticleMeshesData.cpp               |     1 +
 obj/NiParticleMeshesData.h                 |    10 +-
 obj/NiParticleRotation.cpp                 |     1 +
 obj/NiParticleRotation.h                   |     6 +-
 obj/NiParticleSystem.cpp                   |     1 +
 obj/NiParticleSystem.h                     |    10 +-
 obj/NiParticleSystemController.cpp         |     1 +
 obj/NiParticleSystemController.h           |     8 +-
 obj/NiParticles.cpp                        |     1 +
 obj/NiParticles.h                          |     6 +-
 obj/NiParticlesData.cpp                    |     1 +
 obj/NiParticlesData.h                      |     7 +-
 obj/NiPathController.cpp                   |     1 +
 obj/NiPathController.h                     |     9 +-
 obj/NiPathInterpolator.cpp                 |     1 +
 obj/NiPathInterpolator.h                   |    10 +-
 obj/NiPixelData.cpp                        |     1 +
 obj/NiPixelData.h                          |     5 +-
 obj/NiPlanarCollider.cpp                   |     1 +
 obj/NiPlanarCollider.h                     |     6 +-
 obj/NiPoint3Interpolator.cpp               |     1 +
 obj/NiPoint3Interpolator.h                 |    10 +-
 obj/NiPointLight.cpp                       |     1 +
 obj/NiPointLight.h                         |     7 +-
 obj/NiPosData.cpp                          |     1 +
 obj/NiPosData.h                            |     3 +
 obj/NiProperty.cpp                         |     1 +
 obj/NiProperty.h                           |     6 +-
 obj/NiRangeLODData.cpp                     |     1 +
 obj/NiRangeLODData.h                       |     8 +-
 obj/NiRotatingParticles.cpp                |     1 +
 obj/NiRotatingParticles.h                  |     6 +-
 obj/NiRotatingParticlesData.cpp            |     1 +
 obj/NiRotatingParticlesData.h              |     6 +-
 obj/NiScreenLODData.cpp                    |     1 +
 obj/NiScreenLODData.h                      |     6 +-
 obj/NiSequenceStreamHelper.cpp             |     1 +
 obj/NiSequenceStreamHelper.h               |     6 +-
 obj/NiShadeProperty.cpp                    |     1 +
 obj/NiShadeProperty.h                      |     6 +-
 obj/NiSingleInterpolatorController.cpp     |     1 +
 obj/NiSingleInterpolatorController.h       |     9 +-
 obj/NiSkinData.cpp                         |     1 +
 obj/NiSkinData.h                           |     5 +-
 obj/NiSkinInstance.cpp                     |     1 +
 obj/NiSkinInstance.h                       |     7 +-
 obj/NiSkinPartition.cpp                    |     1 +
 obj/NiSkinPartition.h                      |     8 +-
 obj/NiSourceTexture.cpp                    |     1 +
 obj/NiSourceTexture.h                      |     7 +-
 obj/NiSpecularProperty.cpp                 |     1 +
 obj/NiSpecularProperty.h                   |     6 +-
 obj/NiSphericalCollider.cpp                |     1 +
 obj/NiSphericalCollider.h                  |     6 +-
 obj/NiSpotLight.cpp                        |     1 +
 obj/NiSpotLight.h                          |     7 +-
 obj/NiStencilProperty.cpp                  |     1 +
 obj/NiStencilProperty.h                    |     6 +-
 obj/NiStringExtraData.cpp                  |     1 +
 obj/NiStringExtraData.h                    |     7 +-
 obj/NiStringPalette.cpp                    |     1 +
 obj/NiStringPalette.h                      |     8 +-
 obj/NiStringsExtraData.cpp                 |     1 +
 obj/NiStringsExtraData.h                   |     6 +-
 obj/NiTextKeyExtraData.cpp                 |     1 +
 obj/NiTextKeyExtraData.h                   |     3 +
 obj/NiTextureEffect.cpp                    |     1 +
 obj/NiTextureEffect.h                      |    10 +-
 obj/NiTextureTransformController.cpp       |     1 +
 obj/NiTextureTransformController.h         |    10 +-
 obj/NiTexturingProperty.cpp                |     1 +
 obj/NiTexturingProperty.h                  |     3 +
 obj/NiTimeController.cpp                   |     1 +
 obj/NiTimeController.h                     |     5 +-
 obj/NiTransformController.cpp              |     1 +
 obj/NiTransformController.h                |     6 +-
 obj/NiTransformData.cpp                    |     1 +
 obj/NiTransformData.h                      |     6 +-
 obj/NiTransformInterpolator.cpp            |     1 +
 obj/NiTransformInterpolator.h              |    10 +-
 obj/NiTriBasedGeom.cpp                     |     1 +
 obj/NiTriBasedGeom.h                       |     7 +-
 obj/NiTriBasedGeomData.cpp                 |     1 +
 obj/NiTriBasedGeomData.h                   |     7 +-
 obj/NiTriShape.cpp                         |     1 +
 obj/NiTriShape.h                           |     6 +-
 obj/NiTriShapeData.cpp                     |     1 +
 obj/NiTriShapeData.h                       |     7 +-
 obj/NiTriStrips.cpp                        |     1 +
 obj/NiTriStrips.h                          |     6 +-
 obj/NiTriStripsData.cpp                    |     1 +
 obj/NiTriStripsData.h                      |     3 +
 obj/NiUVController.cpp                     |     1 +
 obj/NiUVController.h                       |     9 +-
 obj/NiUVData.cpp                           |     1 +
 obj/NiUVData.h                             |     7 +-
 obj/NiVectorExtraData.cpp                  |     1 +
 obj/NiVectorExtraData.h                    |     6 +-
 obj/NiVertWeightsExtraData.cpp             |     1 +
 obj/NiVertWeightsExtraData.h               |     6 +-
 obj/NiVertexColorProperty.cpp              |     1 +
 obj/NiVertexColorProperty.h                |     6 +-
 obj/NiVisController.cpp                    |     1 +
 obj/NiVisController.h                      |    10 +-
 obj/NiVisData.cpp                          |     1 +
 obj/NiVisData.h                            |     7 +-
 obj/NiWireframeProperty.cpp                |     1 +
 obj/NiWireframeProperty.h                  |     6 +-
 obj/NiZBufferProperty.cpp                  |     1 +
 obj/NiZBufferProperty.h                    |     6 +-
 obj/RootCollisionNode.cpp                  |     1 +
 obj/RootCollisionNode.h                    |     6 +-
 obj/bhkBlendCollisionObject.cpp            |     1 +
 obj/bhkBlendCollisionObject.h              |     6 +-
 obj/bhkBlendController.cpp                 |     1 +
 obj/bhkBlendController.h                   |     6 +-
 obj/bhkBoxShape.cpp                        |     1 +
 obj/bhkBoxShape.h                          |     7 +-
 obj/bhkCapsuleShape.cpp                    |     1 +
 obj/bhkCapsuleShape.h                      |     7 +-
 obj/bhkCollisionObject.cpp                 |     1 +
 obj/bhkCollisionObject.h                   |     6 +-
 obj/bhkConvexShape.cpp                     |     1 +
 obj/bhkConvexShape.h                       |     6 +-
 obj/bhkConvexTransformShape.cpp            |     1 +
 obj/bhkConvexTransformShape.h              |     6 +-
 obj/bhkConvexVerticesShape.cpp             |     1 +
 obj/bhkConvexVerticesShape.h               |     6 +-
 obj/bhkEntity.cpp                          |     1 +
 obj/bhkEntity.h                            |    10 +-
 obj/bhkHingeConstraint.cpp                 |     1 +
 obj/bhkHingeConstraint.h                   |     6 +-
 obj/bhkLimitedHingeConstraint.cpp          |     1 +
 obj/bhkLimitedHingeConstraint.h            |     8 +-
 obj/bhkListShape.cpp                       |     1 +
 obj/bhkListShape.h                         |    10 +-
 obj/bhkMalleableConstraint.cpp             |     1 +
 obj/bhkMalleableConstraint.h               |     9 +-
 obj/bhkMoppBvTreeShape.cpp                 |     1 +
 obj/bhkMoppBvTreeShape.h                   |    10 +-
 obj/bhkMultiSphereShape.cpp                |     1 +
 obj/bhkMultiSphereShape.h                  |     6 +-
 obj/bhkNiTriStripsShape.cpp                |     1 +
 obj/bhkNiTriStripsShape.h                  |    10 +-
 obj/bhkPackedNiTriStripsShape.cpp          |     1 +
 obj/bhkPackedNiTriStripsShape.h            |    10 +-
 obj/bhkPrismaticConstraint.cpp             |     1 +
 obj/bhkPrismaticConstraint.h               |     6 +-
 obj/bhkRagdollConstraint.cpp               |     1 +
 obj/bhkRagdollConstraint.h                 |     6 +-
 obj/bhkRefObject.cpp                       |     1 +
 obj/bhkRefObject.h                         |     6 +-
 obj/bhkRigidBody.cpp                       |     1 +
 obj/bhkRigidBody.h                         |     9 +-
 obj/bhkRigidBodyT.cpp                      |     1 +
 obj/bhkRigidBodyT.h                        |     6 +-
 obj/bhkSPCollisionObject.cpp               |     1 +
 obj/bhkSPCollisionObject.h                 |     6 +-
 obj/bhkSerializable.cpp                    |     1 +
 obj/bhkSerializable.h                      |     6 +-
 obj/bhkShape.cpp                           |     1 +
 obj/bhkShape.h                             |     6 +-
 obj/bhkSimpleShapePhantom.cpp              |     1 +
 obj/bhkSimpleShapePhantom.h                |     6 +-
 obj/bhkSphereRepShape.cpp                  |     1 +
 obj/bhkSphereRepShape.h                    |     7 +-
 obj/bhkSphereShape.cpp                     |     1 +
 obj/bhkSphereShape.h                       |     7 +-
 obj/bhkStiffSpringConstraint.cpp           |     1 +
 obj/bhkStiffSpringConstraint.h             |     6 +-
 obj/bhkTransformShape.cpp                  |     1 +
 obj/bhkTransformShape.h                    |     7 +-
 obj/bhkWorldObject.cpp                     |     1 +
 obj/bhkWorldObject.h                       |     6 +-
 obj/hkPackedNiTriStripsData.cpp            |     1 +
 obj/hkPackedNiTriStripsData.h              |     8 +-
 pch.h                                      |   438 +-
 497 files changed, 3642 insertions(+), 10508 deletions(-)

diff --git a/NIF_IO.cpp b/NIF_IO.cpp
index 4b5d22d9..40883964 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 bb3ae1ee..1eab830c 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 b6090912..369f48dc 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 4545a6ea..2124249a 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 2902cc72..f4734382 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 c0fc28e0..06eae544 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 08231cdc..dffed035 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 b3608db7..96545cd1 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 697c7465..d50f3cdf 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 8b1dc522..abb07411 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 173ec692..79cb83de 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 9c2fa65d..805b1c90 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 ce949b5d..c34d015d 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 041e9c19..9082395c 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 0537e040..66c1d824 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 702464e3..356e5bc7 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 d70ea88d..10d9c6f8 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 2362ff7f..0ff4ed5a 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 478edf28..3811853d 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 e1f9cfa9..6d32ecde 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 2e6d9101..c3b3b695 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 caf580d7..678ccf7b 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 0f3bf91a..9c42628f 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 0e24fd01..1302f8aa 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 58b46937..d6d46bb9 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 88a156af..5564c30e 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 cd673a56..d028fa89 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 067cd6bc..3076bb8e 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 ef314ed6..ffd64610 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 2ab60532..7b024dcd 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 699d6d6b..13f75fa4 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 12354302..c001ca36 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 5ba5c457..74f4e799 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 e44c2e74..f17e0b9f 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 36b23acb..aa3c6f9f 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 55684223..85a25daa 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 caa89a77..67d10163 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 9e83ec5b..829bd3aa 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 c07c0269..7ca915ef 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 32c5a37a..213c583a 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 4b738818..ff9ac0a8 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 79d34596..d0370af2 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 66f95025..107b9e34 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 d9e9d17d..ae0368ad 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 8e4e78fc..fa6f542c 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 7ac08c81..b93d1833 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 a321ca4e..e51926bb 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 905d0e8f..663d9ba6 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 51fab527..4f00d9d9 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 893c7370..cbddd7ab 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 6cf48443..6108f0df 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 bb35f75d..2cd6a05a 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 2dfafae9..9dc0a2fe 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 4eeee30e..eb2005c6 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 9f3a9c6a..18b616f2 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 b11f4c33..79bbdf72 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 fa972d75..634e7a8d 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 66cf1cb3..d7cf5fc9 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 e3291f34..9ae45c6d 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 e3e35db7..b16cc28f 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 0dd4faa2..1476e8c7 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 e6c99c45..aea75ad1 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 b897b8ad..cf42c433 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 7572b1f3..af9f6192 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 91046aa4..f36112c6 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 877a9c82..592991d2 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 890ffced..162d8039 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 326d351b..db21ebc9 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 fc4665f1..aa861b2f 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 2701b1ee..2b8ec783 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 1690bb99..04f2b14b 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 dd730642..68bf24a1 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 82ca7416..e82e0b6e 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 50f086b5..c3c1cc4d 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 26107f3f..7f921993 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 7feefad3..1d6209ea 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 b888caca..6d5f5630 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 7fb36ccd..9fa50ae4 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 2caf0410..83809028 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 9ee82fa5..2284bafe 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 c8363e7a..cee306e0 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 04b4e043..d506d6e1 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 1c8c9180..74e93679 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 db8d7e6b..467939a1 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 aa3f670d..6a305597 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 3a99d057..d5b8e916 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 c93d9f30..fc6ae11c 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 0ab912e8..f1804a76 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 b4122762..bcaacabf 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 9c830c35..7756eb82 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 4a06a294..732aaded 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 d5d4efb2..8cd7ecaf 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 9bb786ce..3ba64ef8 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 3c44dba5..ea096a39 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 bc465e66..dabd8ffb 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 3011ec2b..ff5142da 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 fbfe0c6f..2008cd80 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 04d051fc..1e09728b 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 172b2771..d372e030 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 beee3235..6607b9ed 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 1b6f9fc9..d6bca43b 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 574aa4eb..b33f98a9 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 f8eb2436..abd48ef5 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 ceffd817..db515e8d 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 bb60ceab..8c6564f7 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 7727d795..6f9077e9 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 eb84e356..66df202d 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 6355f5b2..d0a1723a 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 1491cff0..e9f16f01 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 f413e035..e406314a 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 b40552fd..d86a605c 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 e7b0e2a3..9f650302 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 af3b20cf..7758d2c7 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 f39d3c14..a822b02a 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 97e3c74b..f3579b4c 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 89a79400..5e420d30 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 80b4bcf4..45aded21 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 e8ea880c..34ae640b 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 ab5ba3db..e1012aca 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 41b0b0c5..3f3fa9bb 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 5f63acb1..aa108132 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 ad70373b..c77092ef 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 f5411537..d469cc05 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 1fb703c1..a48cd05c 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 55318a4b..b740cf7d 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 daebbb19..9cb8d1c2 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 c0f782c0..fc5e83f5 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 e3908da5..f30f5d56 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 2eb572f2..d30421f7 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 2c117f84..a6b02d7b 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 c1091f4e..b9f056df 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 2a9a3ec3..c7516f88 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 3eb0caac..83148da5 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 f46e7fc5..bdc5d3a7 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 da79950c..0ac937f8 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 3a98911b..109bbf55 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 96a24942..4b00e6d4 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 d7f1f134..3961d3e4 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 3debb58c..93a16e95 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 116fcfab..acf7d90d 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 dfa649c6..7f541a88 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 d0f37b85..24aaff0e 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 1c2409b8..e3853967 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 4b19a585..f248236c 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 ae3f3a7b..68b858da 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 41f1ee74..c06a9b71 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 3eed1713..b273cfb2 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 ce5dd273..f17b9fa5 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 3b2324b1..1f357b58 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 df6d38f5..3c4de36b 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 8aef4c6d..5728d994 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 ef17a888..d39fc703 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 b89ef156..c15dd13a 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 6280bfc0..865d6e8e 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 95d465d0..ffc503b9 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 7de5637a..9755bc33 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 3eb9e1aa..047f4671 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 3714a620..c159153d 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 bb5b8237..d988de38 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 6a28c901..56745cd4 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 ece75ba9..1b986cc6 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 c57ef158..0fcc339c 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 201d242d..84e53ed7 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 fb360789..c7dfefb3 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 5357e86b..624e3ca7 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 c84ad832..665e1882 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 a96ae35d..b76e77fe 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 76137dca..787e0b2b 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 54e53c0e..4c190159 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 299c166f..a3288d2d 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 9ab7e769..5d6f1f40 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 3e1e55ef..ad936422 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 e541f1b3..ae4e62a4 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 08e08267..180d1aae 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 13f95118..a988b766 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 e1f39660..241d79c7 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 c31c2936..26b3a1cf 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 672782ca..07deca0b 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 fbe8fddb..a128eb24 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 7a4bcfbb..5dc67612 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 37af4b90..f6b549d7 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 7050671f..3f3ded8e 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 8cd25608..0d136316 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 2b1e8d0a..684f5c42 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 2ca67ad3..43da28e7 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 5ddb183e..3849bf2a 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 75dcaae4..8cb42f1e 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 5850eb37..0202de6e 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 882a546c..101c7409 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 9a67ea96..26a5135a 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 9c226365..07abe957 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 dfadf851..a1022b4b 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 d1e53042..188afb6d 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 610c93e5..bd717d49 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 98d971a8..cc4595fa 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 baaf48be..80117427 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 80fd06d6..34efb6be 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 4d7c37d6..3c0a7618 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 aa6ca97a..d532f9f6 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 0ea648d8..60243934 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 b8014b83..cecc1504 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 5dea8ee1..c986e29f 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 9b0c7802..bd719add 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 f07226c3..3b72ae15 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 96a9a3b1..4d832951 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 c581004a..167dcf7b 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 5b9cc50a..45352fde 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 13c679da..745ec7ae 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 2c95202e..cc8adf94 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 958e702c..14eac07f 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 026f17e4..3bed1b02 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 a9aca36f..4775d4b7 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 c7c889c9..0f83d019 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 d668059e..e50731b6 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 789ebff8..6578240f 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 4a88dbbf..1a7fc1c6 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 8eee8150..db96b2b8 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 653aa8d3..1efd6fbc 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 45f30bda..74cbea24 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 4d9e864c..d02fbc90 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 44628628..771efcf7 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 deb0bd37..79aac072 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 ce5e18d9..e00191a1 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 049ccf9f..3dd0a551 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 377a6ce5..74295dd2 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 dcd3ca5c..fbaa69da 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 adfc1013..e82f3b41 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 3b7ab657..e00b713f 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 623e9b30..c01ecb56 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 1b4b7af1..c838cbb9 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 cd0989f2..002d9c9a 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 551da2bf..4fd87756 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 00f0f9e7..115e67d5 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 b0137bec..2d45765c 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 df1d75a7..e675e722 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 0bde0a6a..b013db15 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 c0137b43..81aa0f08 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 9333733f..413f7e46 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 211b765a..52bf1ca4 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 f599717b..99f9624b 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 48659806..69d39436 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 cc5dd727..6413557c 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 8be3453a..15e2555c 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 09206c0f..dfafc40e 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 4351c169..c2b9b558 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 64308e83..f3c89437 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 f44de713..e7c9a185 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 5842f571..621c53bf 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 d46becc5..ec05cc31 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 2ba34993..d0562ff2 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 c55085c4..bca9e8d9 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 20a8a9e9..48a35142 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 a3879632..d5f4d2b5 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 b0e42291..eb47897e 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 92f80f33..7b23d476 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 3c1aff6d..f619645f 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 2008cb8f..9e20b518 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 b59b1e7b..03bbc5d9 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 2052a34f..326e074c 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 71e9509d..e6baeaa1 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 8a9ca149..d129a689 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 e1915e4b..bf879af2 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 b8818fa1..48eb2f38 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 1a921041..704f3642 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 ba46280f..a635746f 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 d7943942..138d71a3 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 159a0a04..97c9d948 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 f74a3aac..5497e2e3 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 7f66ed79..022fc680 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 5bae5ecd..d69a41bd 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 43e64a7a..5fb5b46d 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 4493327c..0eb06733 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 487aa182..30b2bfd3 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 febe1d9a..4d367de9 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 8e4e6f32..ba9ad3ad 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 439a98e7..c690cf43 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 635aa9c0..6267bf5f 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 26751912..8a255fe0 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 cc938ca5..c79de006 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 c13daf3c..dbdccfeb 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 18b65b00..ffa1ee62 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 d4127ffc..41f7bc07 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 3c5d1e2f..946a8300 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 67980c8c..ab0ea608 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 ba6bb78c..c374356e 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 df438b9a..ab2417e0 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 77066072..cba516ae 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 c4bc7a9a..745035ef 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 45c4d954..6c904efd 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 c1ac5558..e79c59c0 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 b9eb65b2..eb95b71b 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 533be878..fd81d686 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 df408a01..f252d065 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 24e9c701..717ea347 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 376b5084..a1d5fc31 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 6b91842d..863f4b04 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 8f084457..586fd82a 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 4ab047ce..7538fe0d 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 b1de6ac3..9848b2cc 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 5e1c1c4f..2cfc3ce4 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 b1eaa069..55ded02d 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 fd2fd229..13e0c1a0 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 345bdb64..64f7843b 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 89a7ad9b..a3515f80 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 5687692d..bdc84fc0 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 1e208b7b..34a3e23f 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 243e299d..d3b3e5ad 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 aeeac7bc..4382777f 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 20135a5d..4079598b 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 4a050ada..50324c4e 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 0b7a5a50..73820e8c 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 85be8415..9074a99a 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 acf778bf..110d17ce 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 1cf45cdf..3e23e9ba 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 f3cae888..b4fca3e5 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 7e29afe0..4de6afe9 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 702b9544..75cc8d08 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 becc2110..3ca99fd6 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 a23a5606..de488ab0 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 97c3d3a0..14b3b7b8 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 dd96a272..96678aa2 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 6779eae8..fb9b5154 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 48e5c1ce..034a2cee 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 88137263..e280c311 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 26b33778..cdd10a9d 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 1ffa579a..2576cf01 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 d5353a3d..79740b6c 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 c84f136e..e4818a9f 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 7216118a..8144df6b 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 5cc43e0e..35c25b92 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 1dabfccd..96984f07 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 b674054c..79eca8cc 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 5c6dcc00..42a449fd 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 e15c7683..ca11d23c 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 335ea0d3..62032713 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 846d6d5c..4faa80f1 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 d933d58d..8bf1a3c6 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 22f3540b..0d8b2aab 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 a343a70f..f5bbc796 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 be4ff5c2..358aa2e4 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 83ba9d44..d6cd8446 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 3ec2a599..49cc6e8b 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 6d0eda27..77390f83 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 8b400fed..7941418d 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 5296c827..c542532d 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 0eb75db8..800aa713 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 35543225..3aeceb2c 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 456ef1a6..c69a6dd3 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 b9988096..6d9f9f19 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 358541d8..96801880 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 03b8f9e0..21675d2f 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 4840b607..efaca622 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 df0abf47..8cfe9d38 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 71c4e7da..95cec2c9 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 a1169bec..68a4a452 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 f246e2e5..2a315378 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 81aea9bc..1173625e 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 c46a1f62..bb3a1806 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 bd9f2497..31daede6 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 0411c1e2..8c88cc34 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 a9853ce1..978acc11 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 1dd07a80..8b58f302 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 154330d5..c8d836cf 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 a09f44db..617bdf45 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 6d304af6..d3b3ef12 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 0d3b1630..505b46f1 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 508f9b06..1ea2a51b 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 6957f0c3..34d26830 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 685b6e59..1dff2968 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 63c68f8e..949abc9a 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 64ccfe80..08c75fe2 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 488e0c02..6570344f 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 68f42535..c970da86 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 dac2c89a..4669ef48 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 7c41a849..3ecfadf2 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 520b7eb3..ffaa12c7 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 9eb1c73b..56f667b6 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 d41ca087..ff5c92d7 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 f25175ec..91b29c57 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 79949693..5e88d0c8 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 cb08b70a..3d0e4230 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 b3896d44..c84b999e 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 428c98ce..6686da56 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 6d556ac1..cab7795e 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 0a042eba..71f743d1 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 7700fbf6..ddeab50d 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 9323174b..1da9ca11 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 97a2dd52..e6698f4f 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 7c99ff1b..9b0fc734 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 db12eabe..440bbd76 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 216b511c..857381d9 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 0d0f95d9..0b270e8c 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 6e738000..d3594a55 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 21955bd9..77aa6101 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 15986bbb..064fa05b 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 6e18aaab..8bdf73c2 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 0e6eb627..1c90141c 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 304f14d7..8675dd07 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 52ed2d20..494d3ba1 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 0839b0fc..e1a54d1d 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 bfd31f34..2df124d3 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 564d315e..f3be77db 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 783e330b..563e5a06 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 24d1c6aa..15910177 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 5a057ec8..88f941cc 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 55d7c80f..1b9b6654 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 bee77014..3fc8df77 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 3969012f..b07221cf 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 d635b889..eb8b16d2 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 da69a8ac..5491e4dc 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 374ac7b9..39bdc12c 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 4344eb6e..eb200c83 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 4b03643c..789610d0 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 329f74f9..e067abc1 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 5477b2c9..63d1d4bf 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 a1f0a7de..71edba3e 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 134301b9..f66da292 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 8f3b007e..63143d66 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 98558aab..d729fb2a 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 5f2375cf..03b9976c 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 15d6af71..92150e62 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 157d7375..cf92dac7 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 b437588d..f8021234 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 49cbfc4b..4ada2a09 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 29afff8d..4ead3db7 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 ab106145..65503d5f 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 a05d9ced..4ba168bc 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 c036cae7..8ccc94a1 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 a6a454bb..bf0f25d2 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 8fb22e3f..61fa23fb 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 9e24f616..8251858d 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 4f76acdb..5a7830e2 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 e11870b1..d8c9fd7e 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 47f2e9a2..cc20d7e7 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 d7c0be16..a2e7a336 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 92ce9146..c5de9d9e 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 f0fee9f2..02a3600d 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 65e054d1..f3e30cfc 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 b1e2adcd..ab1fe776 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 4488fed4..293c410a 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 b58ca89b..257e53bd 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 01a18ac7..1fc349b7 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 afc83cb2..49c9398c 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 f0f5f0a5..eed56e66 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 4ef28d46..8c5a32a5 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 156b921e..ca96d565 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 cae05f99..380923ce 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 f8fce7b5..710fc638 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 f5dbf24c..acc9a21c 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 4abaca25..6ded32d4 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 4f1c00df..726f1b92 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 5d79801e..f59c33fe 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 c38225e2..1a67af57 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 4ee05f86..6b5b4c40 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 1f1ff810..d60195bd 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 ccdbc708..e4545939 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 501aeae5..713742fb 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 b4f6a96f..a1572d7f 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 e8882eb4..94159ae9 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 e9cf3e00..b3628b7b 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 5bedbc39..c947718c 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 f1db7edc..1d630524 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 e7dd97e2..48c8f9ce 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 df721952..10354c4e 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 38a6fa5e..386557bf 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 5332d8ad..cbfa610d 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 016e6152..77322344 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 fdbc9008..74285237 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 15b0cfca..63fe589f 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 bf5fbb88..1fc70147 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 93f17285..186e983e 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 59958011..fe16257e 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 e5f8ad01..64571721 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 c9d8b91d..86d5234a 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 9bd1a458..569a805e 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 c6bae197..6be19722 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 68e8cbec..22f35ee1 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 ac6c3215..07cb5fc6 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 3c984598..4e69457d 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 1a14803e..b0812149 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 e38f172f..e85f2234 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 a2149c68..a9842fa8 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 00035c4e..139c297e 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 86f8cd45..7e2360d8 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 7efa8a14..0a6dc79e 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 964d4506..1f3a4422 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 cdb7c121..2499b7f4 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 5e082860..e10429db 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 2d96ad99..992a86e4 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 c86b6f85..46dd61cb 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 a8b57182..c037cba9 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 538be5ee..c44f82a1 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 99c7795f..312ac15d 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 3b56b2e3..52c5e03e 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 f81d6e02..514f2fed 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 53e05dc4..adc91bd5 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 4deff492..2cd284a1 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
-- 
GitLab