diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 790ba25112be746599e5864003c2068716c69a0e..ff743802170263af651af6c0eda16c4e29bf1d82 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -2049,8 +2049,8 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in)
 	freePickMask();
 
     if (mFormatType != GL_UNSIGNED_BYTE ||
-        mFormatPrimary != GL_RGBA ||
-        mFormatPrimary != GL_SRGB_ALPHA)
+        ((mFormatPrimary != GL_RGBA)
+      && (mFormatPrimary != GL_SRGB_ALPHA)))
     {
         //cannot generate a pick mask for this texture
         return;
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index d5ffdef4c955d3f228bca12f4aeadc3f27399ba1..f184b22ccb7c7dbce08a15673ac90d57a7cbaa96 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -112,26 +112,6 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask)
 	mMouseDownX = x;
 	mMouseDownY = y;
 
-#if 0
-	LLTimer pick_timer;
-	BOOL pick_rigged = false; //gSavedSettings.getBOOL("AnimatedObjectsAllowLeftClick");
-	mPick = gViewerWindow->pickImmediate(x, y, FALSE, pick_rigged);
-	LLViewerObject *object = mPick.getObject();
-	LLViewerObject *parent = object ? object->getRootEdit() : NULL;
-	if (!object
-		|| object->isAttachment()
-		|| object->getClickAction() == CLICK_ACTION_DISABLED
-		|| (!useClickAction(mask, object, parent) && !object->flagHandleTouch() && !(parent && parent->flagHandleTouch())))
-	{
-		// Unless we are hovering over actionable visible object
-		// left mouse down always picks transparent (but see handleMouseUp).
-		// Also see LLToolPie::handleHover() - priorities are a bit different there.
-		// Todo: we need a more consistent set of rules to work with
-		mPick = gViewerWindow->pickImmediate(x, y, TRUE /*transparent*/, pick_rigged);
-	}
-	LL_INFOS() << "pick_rigged is " << (S32) pick_rigged << " pick time elapsed " << pick_timer.getElapsedTimeF32() << LL_ENDL;
-#endif
-
 	//left mouse down always picks transparent (but see handleMouseUp)
 	mPick = gViewerWindow->pickImmediate(x, y, TRUE, FALSE);
 	mPick.mKeyMask = mask;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 3866045b1d950986bc6800641554b924fed80882..dcefa22e757c2dade53b817a797719ba760701bf 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4579,12 +4579,10 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a&
 					}
 				}
 
+                BOOL no_texture = !face->getTexture() || !face->getTexture()->hasGLTexture();
+                BOOL mask       = no_texture ? FALSE : face->getTexture()->getMask(face->surfaceToTexture(tc, p, n));
 				if (face &&
-					(ignore_alpha ||
-					pick_transparent || 
-					!face->getTexture() || 
-					!face->getTexture()->hasGLTexture() || 
-					face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))))
+					(ignore_alpha || pick_transparent || no_texture || mask))
 				{
 					local_end = p;
 					if (face_hitp != NULL)