diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
index 5addbbb1763ade3c49fd27dfdb8984578dbfb4f6..65d9209983e74e5ea677ede25935b472b4484cf2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 525b68c43793a499514e4057fbca9c0e4fecd647..2691fc8dedb64b85a8cc3ecac5660e3c842fc23b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -36,19 +36,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index a2a7dea20d5cf6206d564605e01401f2e29804c3..a012cb50304c7283716ca09638d5c3ef6bda7b23 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
index d227346163e052e600adeb27bf51434921bc82fd..dfb36980b006cb6b56ceda38ee0540fbf584e0c3 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 86f014df35f903b93b8eb89b37bcc63cd70f5020..f6160815ebb51b5afa5b3720d8cc2702bd041150 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index 495e86c8db084f43eace6d130f07536a127fde9a..0ae09df0c6d1262e6e475f2e3ef6b566bb2f2fdd 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -37,19 +37,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 	//get distance
 	float d = length(lv);
 	
-	//normalize light vector
-	lv *= 1.0/d;
+	float da = 0.0;
+
+	if (d > 0.0 && la > 0.0 && fa > 0.0)
+	{
+		//normalize light vector
+		lv *= 1.0/d;
 	
-	//distance attenuation
-	float dist2 = d*d/(la*la);
-	float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+		//distance attenuation
+		float dist2 = d*d/(la*la);
+		da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
 
-	// spotlight coefficient.
-	float spot = max(dot(-ln, lv), is_pointlight);
-	da *= spot*spot; // GL_SPOT_EXPONENT=2
+		// spotlight coefficient.
+		float spot = max(dot(-ln, lv), is_pointlight);
+		da *= spot*spot; // GL_SPOT_EXPONENT=2
 
-	//angular attenuation
-	da *= calcDirectionalLight(n, lv);
+		//angular attenuation
+		da *= calcDirectionalLight(n, lv);
+	}
 
 	return da;	
 }
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index b79f120eda4f9d7f9af87bd39721c0d58cace10c..1ba553f9275ffc9c71d306fd28be53ebd4d22428 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -1702,7 +1702,13 @@ void LLMeshUploadThread::doIterativeUpload()
 		}
 
 		//queue up models for hull generation
-		DecompRequest* request = new DecompRequest(data.mModel[LLModel::LOD_HIGH], data.mBaseModel, this);
+		LLModel* physics = data.mModel[LLModel::LOD_PHYSICS];
+		if (physics == NULL)
+		{ //no physics model available, use high lod
+			physics = data.mModel[LLModel::LOD_HIGH];
+		}
+		
+		DecompRequest* request = new DecompRequest(physics, data.mBaseModel, this);
 		gMeshRepo.mDecompThread->submitRequest(request);
 	}