diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 91e11b8c0d9887cb2d819380430dc986fabe5402..36874a5d48fcfd4f7da5c793ba4abc9a002896c3 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -365,6 +365,13 @@ U32 LLCurl::Easy::report(CURLcode code)
 		responseReason = strerror(code) + " : " + mErrorBuffer;
 	}
 		
+	if(responseCode >= 300 && responseCode < 400) //redirect
+	{
+		char new_url[512] ;
+		curl_easy_getinfo(mCurlEasyHandle, CURLINFO_REDIRECT_URL, new_url);
+		responseReason = new_url ; //get the new URL.
+	}
+
 	if (mResponder)
 	{	
 		mResponder->completedRaw(responseCode, responseReason, mChannels, mOutput);
diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml
index 3f67a70d7ac179943d599d234ac87e6ef93fe2f6..d02a13a67131183e48ab8fd9f282bc5340de94d7 100644
--- a/indra/newview/app_settings/low_graphics.xml
+++ b/indra/newview/app_settings/low_graphics.xml
@@ -4,6 +4,8 @@
 	<RenderAvatarCloth value="FALSE"/>
 	<!--Default for now-->
 	<RenderAvatarLODFactor value="0.5"/>
+  <!--Default for now-->
+  <RenderAvatarMaxVisible value="3"/>
 	<!--NO SHADERS-->
 	<RenderAvatarVP value="FALSE"/>
 	<!--Short Range-->
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 5f31ccbb198cfc92f17d6a9b0de25ba418fafab1..f1c1a142adbc2c652e3aaf6c145b29169340f10b 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -65,6 +65,7 @@ list Low
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	0
 RenderAvatarLODFactor		1	0.5
+RenderAvatarMaxVisible      1   3
 RenderAvatarVP				1	0
 RenderFarClip				1	64
 RenderFlexTimeFactor		1	0.5
diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index 61a8e51c50e5d04e71e5b6eb6deae5ab3ffc3427..d1d11ee173606b7e1f4ef832b59948b294741021 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -63,6 +63,7 @@ list Low
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	0
 RenderAvatarLODFactor		1	0.5
+RenderAvatarMaxVisible      1   3
 RenderAvatarVP				1	0
 RenderFarClip				1	64
 RenderFlexTimeFactor		1	0.5
diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index 12d47a904c0def93caca1ffb0042fb7b25e63914..efd7ec7a912b193271699415583bee2581113272 100644
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -65,6 +65,7 @@ list Low
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	0
 RenderAvatarLODFactor		1	0.5
+RenderAvatarMaxVisible      1   3
 RenderAvatarVP				1	0
 RenderFarClip				1	64
 RenderFlexTimeFactor		1	0.5
diff --git a/indra/newview/featuretable_solaris.txt b/indra/newview/featuretable_solaris.txt
index f24cbde5e2e5c351536bb418f5ec24ddb94b6dce..6edd2806865b09790bb834dcbfe0d0a0dcc974d4 100644
--- a/indra/newview/featuretable_solaris.txt
+++ b/indra/newview/featuretable_solaris.txt
@@ -117,6 +117,7 @@ UseOcclusion		0	0
 list low
 RenderVBO			1	0
 RenderAniso			1	0
+RenderAvatarMaxVisible      1   3
 RenderLighting		1	0
 
 list medium
diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp
index 1a5d55d793b1f7011e140e903dc04bd484443bd3..1571415e63473cdadc3841a5bb76c3c7e849731e 100644
--- a/indra/newview/lldrawpooltree.cpp
+++ b/indra/newview/lldrawpooltree.cpp
@@ -113,9 +113,12 @@ void LLDrawPoolTree::render(S32 pass)
 			 iter != mDrawFace.end(); iter++)
 		{
 			LLFace *face = *iter;
-			face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
-			face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0); 
-			gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices());
+			if(face->mVertexBuffer.notNull())
+			{
+				face->mVertexBuffer->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
+				face->mVertexBuffer->drawRange(LLRender::TRIANGLES, 0, face->mVertexBuffer->getRequestedVerts()-1, face->mVertexBuffer->getRequestedIndices(), 0); 
+				gPipeline.addTrianglesDrawn(face->mVertexBuffer->getRequestedIndices());
+			}
 		}
 	}
 }
@@ -333,7 +336,7 @@ void LLDrawPoolTree::renderTree(BOOL selecting)
 			S32 stop_depth = 0;
 			F32 app_angle = treep->getAppAngle()*LLVOTree::sTreeFactor;
 			F32 alpha = 1.0;
-			S32 trunk_LOD = 0;
+			S32 trunk_LOD = LLVOTree::sMAX_NUM_TREE_LOD_LEVELS;
 
 			for (S32 j = 0; j < 4; j++)
 			{
@@ -344,6 +347,10 @@ void LLDrawPoolTree::renderTree(BOOL selecting)
 					break;
 				}
 			} 
+			if(trunk_LOD >= LLVOTree::sMAX_NUM_TREE_LOD_LEVELS)
+			{
+				continue ; //do not render.
+			}
 
 			if (app_angle < (THRESH_ANGLE_FOR_BILLBOARD - BLEND_RANGE_FOR_BILLBOARD))
 			{
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 7fa04ce57413895ce33fe3ea1495641141234a97..913a0b92c21631d41fc5ecdd81377382f3420eaa 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -328,11 +328,7 @@ class HTTPGetResponder : public LLCurl::Responder
 					partial = true;
 				}
 			}
-			else
-			{
-				worker->setGetStatus(status, reason);
-// 				llwarns << status << ": " << reason << llendl;
-			}
+
 			if (!success)
 			{
 				worker->setGetStatus(status, reason);
@@ -904,7 +900,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				if (mGetStatus == HTTP_NOT_FOUND)
 				{
 					mHTTPFailCount = max_attempts = 1; // Don't retry
-					//llinfos << "Texture missing from server (404): " << mUrl << llendl;
+					llwarns << "Texture missing from server (404): " << mUrl << llendl;
 
 					//roll back to try UDP
 					mState = INIT ;
@@ -921,6 +917,17 @@ bool LLTextureFetchWorker::doWork(S32 param)
 					max_attempts = mHTTPFailCount+1; // Keep retrying
 					LL_INFOS_ONCE("Texture") << "Texture server busy (503): " << mUrl << LL_ENDL;
 				}
+				else if(mGetStatus >= HTTP_MULTIPLE_CHOICES && mGetStatus < HTTP_BAD_REQUEST) //http re-direct
+				{
+					++mHTTPFailCount;
+					max_attempts = 5 ; //try at most 5 times to avoid infinite redirection loop.
+
+					llwarns << "HTTP GET failed because of redirection: "  << mUrl
+							<< " Status: " << mGetStatus << " Reason: '" << mGetReason << llendl ;
+
+					//assign to the new url
+					mUrl = mGetReason ;
+				}
 				else
 				{
 					const S32 HTTP_MAX_RETRY_COUNT = 3;
@@ -930,6 +937,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 							<< " Status: " << mGetStatus << " Reason: '" << mGetReason << "'"
 							<< " Attempt:" << mHTTPFailCount+1 << "/" << max_attempts << llendl;
 				}
+
 				if (mHTTPFailCount >= max_attempts)
 				{
 					if (cur_size > 0)
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index b89c0cd6385c4c0aa1d72b60d6dd590c23847870..eb5b6c6618dc6a86e86dacd82eb3cf353f73291d 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -66,12 +66,14 @@ const F32 LEAF_TOP = 1.0f;
 const F32 LEAF_BOTTOM = 0.52f;
 const F32 LEAF_WIDTH = 1.f;
 
-S32 LLVOTree::sLODVertexOffset[4];
-S32 LLVOTree::sLODVertexCount[4];
-S32 LLVOTree::sLODIndexOffset[4];
-S32 LLVOTree::sLODIndexCount[4];
-S32 LLVOTree::sLODSlices[4] = {10, 5, 4, 3};
-F32 LLVOTree::sLODAngles[4] = {30.f, 20.f, 15.f, 0.f};
+const S32 LLVOTree::sMAX_NUM_TREE_LOD_LEVELS = 4 ;
+
+S32 LLVOTree::sLODVertexOffset[sMAX_NUM_TREE_LOD_LEVELS];
+S32 LLVOTree::sLODVertexCount[sMAX_NUM_TREE_LOD_LEVELS];
+S32 LLVOTree::sLODIndexOffset[sMAX_NUM_TREE_LOD_LEVELS];
+S32 LLVOTree::sLODIndexCount[sMAX_NUM_TREE_LOD_LEVELS];
+S32 LLVOTree::sLODSlices[sMAX_NUM_TREE_LOD_LEVELS] = {10, 5, 4, 3};
+F32 LLVOTree::sLODAngles[sMAX_NUM_TREE_LOD_LEVELS] = {30.f, 20.f, 15.f, 0.00001f};
 
 F32 LLVOTree::sTreeFactor = 1.f;
 
@@ -373,12 +375,11 @@ BOOL LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 		}
 	}
 
-	S32 trunk_LOD = 0;
+	S32 trunk_LOD = sMAX_NUM_TREE_LOD_LEVELS ;
 	F32 app_angle = getAppAngle()*LLVOTree::sTreeFactor;
 
-	for (S32 j = 0; j < 4; j++)
+	for (S32 j = 0; j < sMAX_NUM_TREE_LOD_LEVELS; j++)
 	{
-
 		if (app_angle > LLVOTree::sLODAngles[j])
 		{
 			trunk_LOD = j;
@@ -445,16 +446,15 @@ void LLVOTree::setPixelAreaAndAngle(LLAgent &agent)
 	
 	// This should be the camera's center, as soon as we move to all region-local.
 	LLVector3 relative_position = getPositionAgent() - gAgentCamera.getCameraPositionAgent();
-	F32 range = relative_position.length();				// ugh, square root
+	F32 range_squared = relative_position.lengthSquared() ;				
 
 	F32 max_scale = mBillboardScale * getMaxScale();
 	F32 area = max_scale * (max_scale*mBillboardRatio);
 
 	// Compute pixels per meter at the given range
-	F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / 
-						   (tan(LLViewerCamera::getInstance()->getView()) * range);
+	F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / tan(LLViewerCamera::getInstance()->getView());
 
-	mPixelArea = (pixels_per_meter) * (pixels_per_meter) * area;
+	mPixelArea = (pixels_per_meter) * (pixels_per_meter) * area / range_squared;
 #if 0
 	// mAppAngle is a bit of voodoo;
 	// use the one calculated LLViewerObject::setPixelAreaAndAngle above
@@ -506,6 +506,13 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
 {
 	LLFastTimer ftm(FTM_UPDATE_TREE);
 
+	if(mTrunkLOD >= sMAX_NUM_TREE_LOD_LEVELS) //do not display the tree.
+	{
+		mReferenceBuffer = NULL ;
+		mDrawable->getFace(0)->mVertexBuffer = NULL ;
+		return TRUE ;
+	}
+
 	if (mReferenceBuffer.isNull() || mDrawable->getFace(0)->mVertexBuffer.isNull())
 	{
 		const F32 SRR3 = 0.577350269f; // sqrt(1/3)
@@ -523,7 +530,7 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
 		face->mCenterAgent = getPositionAgent();
 		face->mCenterLocal = face->mCenterAgent;
 
-		for (lod = 0; lod < 4; lod++)
+		for (lod = 0; lod < sMAX_NUM_TREE_LOD_LEVELS; lod++)
 		{
 			slices = sLODSlices[lod];
 			sLODVertexOffset[lod] = max_vertices;
@@ -700,7 +707,7 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
 		// Generate the vertices
 		// Generate the indices
 
-		for (lod = 0; lod < 4; lod++)
+		for (lod = 0; lod < sMAX_NUM_TREE_LOD_LEVELS; lod++)
 		{
 			slices = sLODSlices[lod];
 			F32 base_radius = 0.65f;
@@ -892,7 +899,6 @@ void LLVOTree::updateMesh()
 	S32 stop_depth = 0;
 	F32 alpha = 1.0;
 	
-
 	U32 vert_count = 0;
 	U32 index_count = 0;
 	
diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h
index feac9e0675e2b1c0a6c9c9ec3e3110e90aa21276..036ad692b1700b1db30361130f7feb07ec5b42f1 100644
--- a/indra/newview/llvotree.h
+++ b/indra/newview/llvotree.h
@@ -152,6 +152,7 @@ class LLVOTree : public LLViewerObject
 	};
 
 	static F32 sTreeFactor;			// Tree level of detail factor
+	static const S32 sMAX_NUM_TREE_LOD_LEVELS ;
 
 	friend class LLDrawPoolTree;
 protected:
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 0a56f711ddd0f27929be368465edc52830c6b583..10beb89940cd10ee67ccf7ca351031044de7c888 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -160,7 +160,7 @@
      layout="topleft"
      left="5"
      name="CustomGraphics Panel"
-     top="124"
+     top="76"
      width="485">
 		<text
 		type="string"
@@ -351,7 +351,7 @@
 		top_delta="0"
 		width="128">
 			m
-		</text>
+		</text>    
 		<slider
 		control_name="RenderMaxPartCount"
 		decimal_digits="0"
@@ -367,6 +367,34 @@
 		name="MaxParticleCount"
 		top_pad="7"
 		width="303" />
+    <slider
+    control_name="RenderAvatarMaxVisible"
+    decimal_digits="0"
+    follows="left|top"
+    height="16"
+    increment="2"
+    initial_value="35"
+    label="Max. avatar draw distance:"
+    label_width="185"
+    layout="topleft"
+    left_delta="0"
+    max_val="65"
+    min_val="1"
+    name="MaxAvatarDrawDistance"
+    top_pad="4"
+    width="290" />
+    <text
+    type="string"
+    length="1"
+    follows="left|top"
+    height="12"
+    layout="topleft"
+    left_delta="291"
+    name="DrawDistanceMeterText2"
+    top_delta="0"
+    width="128">
+      m
+    </text>
 		<slider
 		control_name="RenderGlowResolutionPow"
 		decimal_digits="0"
@@ -377,7 +405,7 @@
 		label="Post process quality:"
 		label_width="185"
 		layout="topleft"
-		left_delta="0"
+		left="200"
 		max_val="9"
 		min_val="8"
 		name="RenderPostProcess"
@@ -522,7 +550,7 @@
         layout="topleft"
         left="469"
         name="PostProcessText"
-        top="305"
+        top="60"
         width="128">
            Low
         </text>
@@ -607,7 +635,7 @@
         layout="topleft"
         left="200"
         name="LightingDetailText"
-        top_pad="8"
+        top_pad="18"
         width="140">
            Lighting detail:
         </text>
@@ -644,7 +672,7 @@
         layout="topleft"
         left_pad="-30"
         name="TerrainDetailText"
-        top="465"
+        top="226"
         width="155">
            Terrain detail:
         </text>