diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h
index 9a6453ea482e9ecc97fd8fa027551e65b4be1443..2401951465f7b0bc1ced52f6c16c240f9aaa6af4 100644
--- a/indra/llcommon/llpointer.h
+++ b/indra/llcommon/llpointer.h
@@ -129,16 +129,6 @@ template <class Type> class LLPointer
 	void ref();                             
 	void unref();
 #else
-
-	void assign(const LLPointer<Type>& ptr)
-	{
-		if( mPointer != ptr.mPointer )
-		{
-			unref(); 
-			mPointer = ptr.mPointer;
-			ref();
-		}
-	}
 	void ref()                             
 	{ 
 		if (mPointer)
@@ -161,7 +151,18 @@ template <class Type> class LLPointer
 			}
 		}
 	}
-#endif
+#endif // LL_LIBRARY_INCLUDE
+
+	void assign(const LLPointer<Type>& ptr)
+	{
+		if (mPointer != ptr.mPointer)
+		{
+			unref();
+			mPointer = ptr.mPointer;
+			ref();
+		}
+	}
+
 protected:
 	Type*	mPointer;
 };
@@ -264,7 +265,7 @@ template <class Type> class LLConstPointer
 #ifdef LL_LIBRARY_INCLUDE
 	void ref();                             
 	void unref();
-#else
+#else // LL_LIBRARY_INCLUDE
 	void ref()                             
 	{ 
 		if (mPointer)
@@ -277,9 +278,9 @@ template <class Type> class LLConstPointer
 	{
 		if (mPointer)
 		{
-			const Type *tempp = mPointer;
+			const Type *temp = mPointer;
 			mPointer = NULL;
-			tempp->unref();
+			temp->unref();
 			if (mPointer != NULL)
 			{
 				LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL;
@@ -287,7 +288,7 @@ template <class Type> class LLConstPointer
 			}
 		}
 	}
-#endif
+#endif // LL_LIBRARY_INCLUDE
 protected:
 	const Type*	mPointer;
 };
diff --git a/indra/llcommon/llrefcount.cpp b/indra/llcommon/llrefcount.cpp
index 6852b5536aecdfebb1627ae218cfcfed26bacc78..3eae252ed58487fd2f11b4fef776d7afbe87b91e 100644
--- a/indra/llcommon/llrefcount.cpp
+++ b/indra/llcommon/llrefcount.cpp
@@ -30,7 +30,7 @@
 #include "llerror.h"
 
 // maximum reference count before sounding memory leak alarm
-const S32 gMaxRefCount = S32_MAX;
+const S32 gMaxRefCount = LL_REFCOUNT_FREE;
 
 LLRefCount::LLRefCount(const LLRefCount& other)
 :	mRef(0)
diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h
index 2080da15653d8e9974b3d2d09aa38755aa981151..2281bf87da8058f00920961f0665e7b4bf629e37 100644
--- a/indra/llcommon/llrefcount.h
+++ b/indra/llcommon/llrefcount.h
@@ -51,21 +51,17 @@ class LL_COMMON_API LLRefCount
 public:
 	LLRefCount();
 
-    inline void validateRefCount() const
-    {
-        llassert(mRef > 0); // ref count below 0, likely corrupted
-        llassert(mRef < gMaxRefCount); // ref count excessive, likely memory leak
-    }
-
 	inline void ref() const
 	{ 
+		llassert(mRef != LL_REFCOUNT_FREE); // object is deleted
 		mRef++; 
-        validateRefCount();
+		llassert(mRef < gMaxRefCount); // ref count excessive, likely memory leak
 	} 
 
 	inline S32 unref() const
 	{
-        validateRefCount();
+		llassert(mRef != LL_REFCOUNT_FREE); // object is deleted
+		llassert(mRef > 0); // ref count below 1, likely corrupted
 		if (0 == --mRef)
 		{
             mRef = LL_REFCOUNT_FREE; // set to nonsense yet recognizable value to aid in debugging
diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp
index 495153981b8183f06d4a9b9a88a986913ca77680..519d11e2ad61a0fafa4e9ebee8dbe13a04342b54 100644
--- a/indra/newview/llmodelpreview.cpp
+++ b/indra/newview/llmodelpreview.cpp
@@ -270,6 +270,7 @@ void LLModelPreview::rebuildUploadData()
 {
     assert_main_thread();
 
+    mDefaultPhysicsShapeP = NULL;
     mUploadData.clear();
     mTextureSet.clear();