diff --git a/indra/llappearance/llpolyskeletaldistortion.cpp b/indra/llappearance/llpolyskeletaldistortion.cpp
index 0ec45bb1ca7fd70671ee9e4f8572223471f6cba2..cf3d41cf6cf80e99f5d00609e0da6a992815e9b5 100644
--- a/indra/llappearance/llpolyskeletaldistortion.cpp
+++ b/indra/llappearance/llpolyskeletaldistortion.cpp
@@ -212,10 +212,12 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex )
         // needed? 
         // joint->storeScaleForReset( newScale );				
 
+#ifdef ENABLE_DEBUG
         // BENTO for detailed stack tracing of params.
         std::stringstream ostr;
         ostr << "LLPolySkeletalDistortion::apply, id " << getID() << " " << getName() << " effective wt " << effective_weight << " last wt " << mLastWeight << " scaleDelta " << scaleDelta << " offset " << offset;
         LLScopedContextString str(ostr.str());
+#endif
 
         joint->setScale(newScale, true);
     }
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index a685df592563bcd05f4b144d463508cb7dcb2baa..2eb52e3768a3e6a9c9efbb0b81b4cd176004535d 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -325,13 +325,18 @@ const LLVector3& LLJoint::getPosition()
 	return mXform.getPosition();
 }
 
+
 bool do_debug_joint(const std::string& name)
 {
+#ifdef ENABLE_DEBUG
     if (std::find(LLJoint::s_debugJointNames.begin(), LLJoint::s_debugJointNames.end(),name) != LLJoint::s_debugJointNames.end())
     {
         return true;
     }
     return false;
+#else
+	return false;
+#endif
 }
 
 //--------------------------------------------------------------------
@@ -345,14 +350,17 @@ void LLJoint::setPosition( const LLVector3& requested_pos, bool apply_attachment
     LLUUID mesh_id;
     if (apply_attachment_overrides && m_attachmentPosOverrides.findActiveOverride(mesh_id,active_override))
     {  
+#ifdef ENABLE_DEBUG
         if (pos != active_override && do_debug_joint(getName()))
         {
             LLScopedContextString str("setPosition");
             LL_DEBUGS("Avatar") << " joint " << getName() << " requested_pos " << requested_pos
                                 << " overriden by attachment " << active_override << LL_ENDL;
         }
+#endif
         pos = active_override;
     }
+#ifdef ENABLE_DEBUG
 	if ((pos != getPosition()) && do_debug_joint(getName()))
 	{
         LLScopedContextString str("setPosition");
@@ -362,6 +370,7 @@ void LLJoint::setPosition( const LLVector3& requested_pos, bool apply_attachment
         LL_DEBUGS("Avatar") << "CONTEXT:\n" << "====================\n" << con_status << "====================" << LL_ENDL;
         LL_DEBUGS("Avatar") << "STACK:\n" << "====================\n" << cs << "====================" << LL_ENDL;
 	}
+#endif
     if (pos != getPosition())
     {
         mXform.setPosition(pos);
@@ -888,14 +897,17 @@ void LLJoint::setScale( const LLVector3& requested_scale, bool apply_attachment_
     LLVector3 active_override;
     if (apply_attachment_overrides && m_attachmentScaleOverrides.findActiveOverride(mesh_id,active_override))
     {  
+#ifdef ENABLE_DEBUG
         if (scale != active_override && do_debug_joint(getName()))
         {
             LLScopedContextString str("setScale");
             LL_DEBUGS("Avatar") << " joint " << getName() << " requested_scale " << requested_scale
                                 << " overriden by attachment " << active_override << LL_ENDL;
         }
+#endif
         scale = active_override;
     }
+#ifdef ENABLE_DEBUG
 	if ((mXform.getScale() != scale) && do_debug_joint(getName()))
 	{	
         LLScopedContextString str("setScale");
@@ -905,6 +917,7 @@ void LLJoint::setScale( const LLVector3& requested_scale, bool apply_attachment_
         LL_DEBUGS("Avatar") << "CONTEXT:\n" << "====================\n" << con_status << LL_ENDL;
         LL_DEBUGS("Avatar") << "STACK:\n" << "====================\n" << cs << "====================" << LL_ENDL;
 	}
+#endif
     mXform.setScale(scale);
     touch();
 
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index f4b5d8852919c3a2d4c31a7ffd03b55c58f48fd1..c62183d65ecfbd73a252ca818e09e45d4317fd2d 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -863,7 +863,7 @@ void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) {
         }
 
         if (gDebugGL) {
-            assert_glerror();
+			stop_glerror();
         }
     }
 #endif
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index b3b6cbfd7626796a18516f6aeb3185cdea1bb0f4..01777d63d5f7e34a6788fd5f8aead2f0a5ff662d 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2474,7 +2474,9 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time)
 		mNeedsExtentUpdate = ((LLDrawable::getCurrentFrame()+mID.mData[0])%upd_freq==0);
 	}
     
+#ifdef ENABLE_DEBUG
     LLScopedContextString str("avatar_idle_update " + getFullname());
+#endif
     
 	checkTextureLoading() ;
 	
@@ -4362,6 +4364,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 	}
 
 	BOOL visible = isVisible();
+#ifdef ENABLE_DEBUG
     bool is_control_avatar = isControlAvatar(); // capture state to simplify tracing
 	bool is_attachment = false;
 	if (is_control_avatar)
@@ -4373,6 +4376,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
     LLScopedContextString str("updateCharacter " + getFullname() + " is_control_avatar "
                               + boost::lexical_cast<std::string>(is_control_avatar) 
                               + " is_attachment " + boost::lexical_cast<std::string>(is_attachment));
+#endif
 
 	// For fading out the names above heads, only let the timer
 	// run if we're visible.
@@ -6037,7 +6041,9 @@ bool LLVOAvatar::jointIsRiggedTo(const LLJoint *joint) const
 
 void LLVOAvatar::clearAttachmentOverrides()
 {
+#ifdef ENABLE_DEBUG
     LLScopedContextString str("clearAttachmentOverrides " + getFullname());
+#endif
 
     for (S32 i=0; i<LL_CHARACTER_MAX_ANIMATED_JOINTS; i++)
 	{
@@ -6069,10 +6075,12 @@ void LLVOAvatar::clearAttachmentOverrides()
 //-----------------------------------------------------------------------------
 void LLVOAvatar::rebuildAttachmentOverrides()
 {
+#ifdef ENABLE_DEBUG
     LLScopedContextString str("rebuildAttachmentOverrides " + getFullname());
 
     LL_DEBUGS("AnimatedObjects") << "rebuilding" << LL_ENDL;
     dumpStack("AnimatedObjectsStack");
+#endif
     
     clearAttachmentOverrides();
 
@@ -6119,10 +6127,12 @@ void LLVOAvatar::rebuildAttachmentOverrides()
 // -----------------------------------------------------------------------------
 void LLVOAvatar::updateAttachmentOverrides()
 {
+#ifdef ENABLE_DEBUG
     LLScopedContextString str("updateAttachmentOverrides " + getFullname());
 
     LL_DEBUGS("AnimatedObjects") << "updating" << LL_ENDL;
     dumpStack("AnimatedObjectsStack");
+#endif
 
     std::set<LLUUID> meshes_seen;
     
@@ -6241,10 +6251,12 @@ void LLVOAvatar::addAttachmentOverridesForObject(LLViewerObject *vo, std::set<LL
         return;
 	}
 
+#ifdef ENABLE_DEBUG
     LLScopedContextString str("addAttachmentOverridesForObject " + getFullname());
     
     LL_DEBUGS("AnimatedObjects") << "adding" << LL_ENDL;
     dumpStack("AnimatedObjectsStack");
+#endif
     
 	// Process all children
     if (recursive)
@@ -10075,10 +10087,13 @@ void LLVOAvatar::updateRiggingInfo()
     }
 
     //LL_INFOS() << "done update rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL;
+#if ENABLE_DEBUG
     LL_DEBUGS("RigSpammish") << getFullname() << " after update rig tab:" << LL_ENDL;
+
     S32 joint_count, box_count;
     showRigInfoTabExtents(this, mJointRiggingInfoTab, joint_count, box_count);
     LL_DEBUGS("RigSpammish") << "uses " << joint_count << " joints " << " nonzero boxes: " << box_count << LL_ENDL;
+#endif
 }
 
 // virtual
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 526c5657ab3580fe9d5cc12dc6ef36aecd63b34e..3ae03065690f30ddec63320bc2854bff3c9b4d40 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -5502,9 +5502,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 				continue;
 			}
 
-            std::string vobj_name = llformat("Vol%p", vobj);
-
-			if (vobj->isMesh() &&
+			bool is_mesh = vobj->isMesh();
+			if (is_mesh &&
 				((vobj->getVolume() && !vobj->getVolume()->isMeshAssetLoaded()) || !gMeshRepo.meshRezEnabled()))
 			{
 				continue;
@@ -5517,12 +5516,13 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 				group->mSurfaceArea += volume->getSurfaceArea() * llmax(llmax(scale.mV[0], scale.mV[1]), scale.mV[2]);
 			}
 
-            bool is_mesh = vobj->isMesh();
-            F32 est_tris = vobj->getEstTrianglesMax();
-
             vobj->updateControlAvatar();
             
-            LL_DEBUGS("AnimatedObjectsLinkset") << vobj_name << " rebuilding, isAttachment: " << (U32) vobj->isAttachment()
+#if ENABLE_DEBUG
+			std::string vobj_name = llformat("Vol%p", vobj);
+
+			F32 est_tris = vobj->getEstTrianglesMax();
+			LL_DEBUGS("AnimatedObjectsLinkset") << vobj_name << " rebuilding, isAttachment: " << (U32) vobj->isAttachment()
                                                 << " is_mesh " << is_mesh
                                                 << " est_tris " << est_tris
                                                 << " is_animated " << vobj->isAnimatedObject()
@@ -5536,6 +5536,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
                                                 << LL_ENDL;
 
 			llassert_always(vobj);
+#endif
+
 			vobj->updateTextureVirtualSize(true);
 			vobj->preRebuild();