diff --git a/indra/llcharacter/lljointstate.h b/indra/llcharacter/lljointstate.h
index b9c91f80b5d1a0020d9bf13e6a575a8918de7c63..1ccc6b50937ecfe66eb0e9c1252ffc63a18783d1 100755
--- a/indra/llcharacter/lljointstate.h
+++ b/indra/llcharacter/lljointstate.h
@@ -64,22 +64,18 @@ class LLJointState : public LLRefCount
 public:
 	// Constructor
 	LLJointState()
-	{
-		mUsage = 0;
-		mJoint = NULL;
-		mUsage = 0;
-		mWeight = 0.f;
-		mPriority = LLJoint::USE_MOTION_PRIORITY;
-	}
+		: mUsage(0)
+		, mJoint(NULL)
+		, mWeight(0.f)
+		, mPriority(LLJoint::USE_MOTION_PRIORITY)
+	{}
 
 	LLJointState(LLJoint* joint)
-	{
-		mUsage = 0;
-		mJoint = joint;
-		mUsage = 0;
-		mWeight = 0.f;
-		mPriority = LLJoint::USE_MOTION_PRIORITY;
-	}
+		: mUsage(0)
+		, mJoint(joint)
+		, mWeight(0.f)
+		, mPriority(LLJoint::USE_MOTION_PRIORITY)
+	{}
 
 	// joint that this state is applied to
 	LLJoint* getJoint()				{ return mJoint; }
diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp
index ed80af36d895231bb722eecee1bb180fb85dc0fd..f942a976b7ecba321780038b53000b595be329e7 100755
--- a/indra/llcommon/llmd5.cpp
+++ b/indra/llcommon/llmd5.cpp
@@ -118,6 +118,12 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
 
   buffer_space = 64 - buffer_index;  // how much space is left in buffer
 
+  // now, transform each 64-byte piece of the input, bypassing the buffer
+  if (input == NULL || input_length == 0){
+	  std::cerr << "LLMD5::update:  Invalid input!" << std::endl;
+	  return;
+  }
+
   // Transform as many times as possible.
   if (input_length >= buffer_space) { // ie. we have enough to fill the buffer
     // fill the rest of the buffer and transform
@@ -127,12 +133,6 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
 		buffer_space);
     transform (buffer);
 
-    // now, transform each 64-byte piece of the input, bypassing the buffer
-  if (input == NULL || input_length == 0){
-	std::cerr << "LLMD5::update:  Invalid input!" << std::endl;
-	return;
-  }
-
     for (input_index = buffer_space; input_index + 63 < input_length; 
 	 input_index += 64)
       transform (input+input_index);
diff --git a/indra/llmath/llsphere.cpp b/indra/llmath/llsphere.cpp
index 740047b93afe5eb9125e886cfa267efbe9b83f71..a8d6200488dfae1188f040af9da356cb0226fd9f 100755
--- a/indra/llmath/llsphere.cpp
+++ b/indra/llmath/llsphere.cpp
@@ -248,8 +248,8 @@ LLSphere LLSphere::getBoundingSphere(const std::vector<LLSphere>& sphere_list)
 		// compute the starting step-size
 		F32 minimum_radius = 0.5f * llmin(diagonal.mV[VX], llmin(diagonal.mV[VY], diagonal.mV[VZ]));
 		F32 step_length = bounding_radius - minimum_radius;
-		S32 step_count = 0;
-		S32 max_step_count = 12;
+		//S32 step_count = 0;
+		//S32 max_step_count = 12;
 		F32 half_milimeter = 0.0005f;
 
 		// wander the center around in search of tighter solutions
@@ -258,7 +258,7 @@ LLSphere LLSphere::getBoundingSphere(const std::vector<LLSphere>& sphere_list)
 		S32 last_dz = 2;
 
 		while (step_length > half_milimeter
-				&& step_count < max_step_count)
+				/*&& step_count < max_step_count*/)
 		{
 			// the algorithm for testing the maximum radius could be expensive enough
 			// that it makes sense to NOT duplicate testing when possible, so we keep
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index aa8dd7697cb0e36c78d8dfcecfbaa69e49bc7ac0..1f96d1557d8f8ce6e49b2d0f2545bb060a6a397a 100755
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -1681,11 +1681,11 @@ LLSD LLModel::writeModel(
 						}
 					}
 					
-					F32* src_tc = (F32*) face.mTexCoords[j].mV;
-
 					//texcoord
 					if (face.mTexCoords)
 					{
+						F32* src_tc = (F32*) face.mTexCoords[j].mV;
+
 						for (U32 k = 0; k < 2; ++k)
 						{ //for each component
 							//convert to 16-bit normalized
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 0af402efea701eb68c23de328d31cf3af2bd393e..1ca6e99ecf95e3b4632f13c50233f5a8d2d939d1 100755
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -53,7 +53,7 @@ bool LLRender::sGLCoreProfile = false;
 static const U32 LL_NUM_TEXTURE_LAYERS = 32; 
 static const U32 LL_NUM_LIGHT_UNITS = 8;
 
-static GLenum sGLTextureType[] =
+static const GLenum sGLTextureType[] =
 {
 	GL_TEXTURE_2D,
 	GL_TEXTURE_RECTANGLE_ARB,
@@ -61,14 +61,14 @@ static GLenum sGLTextureType[] =
 	GL_TEXTURE_2D_MULTISAMPLE
 };
 
-static GLint sGLAddressMode[] =
+static const GLint sGLAddressMode[] =
 {	
 	GL_REPEAT,
 	GL_MIRRORED_REPEAT,
 	GL_CLAMP_TO_EDGE
 };
 
-static GLenum sGLCompareFunc[] =
+static const GLenum sGLCompareFunc[] =
 {
 	GL_NEVER,
 	GL_ALWAYS,
@@ -82,7 +82,7 @@ static GLenum sGLCompareFunc[] =
 
 const U32 immediate_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD0;
 
-static GLenum sGLBlendFactor[] =
+static const GLenum sGLBlendFactor[] =
 {
 	GL_ONE,
 	GL_ZERO,
@@ -99,12 +99,12 @@ static GLenum sGLBlendFactor[] =
 };
 
 LLTexUnit::LLTexUnit(S32 index)
-: mCurrTexType(TT_NONE), mCurrBlendType(TB_MULT), 
-mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT),
-mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR),
-mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA),
-mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0),
-mHasMipMaps(false)
+	: mCurrTexType(TT_NONE), mCurrBlendType(TB_MULT), 
+	mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT),
+	mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR),
+	mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA),
+	mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0),
+	mHasMipMaps(false)
 {
 	llassert_always(index < (S32)LL_NUM_TEXTURE_LAYERS);
 	mIndex = index;
@@ -1189,7 +1189,7 @@ void LLRender::syncMatrices()
 
 	if (shader)
 	{
-		llassert(shader);
+		//llassert(shader);
 
 		bool mvp_done = false;
 
@@ -1288,7 +1288,7 @@ void LLRender::syncMatrices()
 	}
 	else if (!LLGLSLShader::sNoFixedFunction)
 	{
-		GLenum mode[] = 
+		static const GLenum mode[] = 
 		{
 			GL_MODELVIEW,
 			GL_PROJECTION,
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index 0a30f4c807fefa91ca85edf89ab2bfc455584aec..0aa1fbe90572aaf143bb54a473b4a5e56efd90dd 100755
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -122,6 +122,7 @@ class LLWindow : public LLInstanceTracker<LLWindow>
 	virtual void gatherInput() = 0;
 	virtual void delayInputProcessing() = 0;
 	virtual void swapBuffers() = 0;
+	virtual void restoreGLContext() = 0;
 	virtual void bringToFront() = 0;
 	virtual void focusClient() { };		// this may not have meaning or be required on other platforms, therefore, it's not abstract
 	virtual void setOldResize(bool oldresize) { };
diff --git a/indra/llwindow/llwindowheadless.cpp b/indra/llwindow/llwindowheadless.cpp
index e6e6bc67ff0ee0bc9dbf13c0e22f19a2012f463c..b6f67c6107768edf3ebda844f0af90453a1a8bc9 100755
--- a/indra/llwindow/llwindowheadless.cpp
+++ b/indra/llwindow/llwindowheadless.cpp
@@ -52,3 +52,6 @@ void LLWindowHeadless::swapBuffers()
 {
 }
 
+void LLWindowHeadless::restoreGLContext()
+{
+}
diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h
index 1f767f4c97d65716942ba819684b4fc217478951..5975ee3410709958ba5b3b0f8edb8aad97acdb21 100755
--- a/indra/llwindow/llwindowheadless.h
+++ b/indra/llwindow/llwindowheadless.h
@@ -74,8 +74,10 @@ class LLWindowHeadless : public LLWindow
 	/*virtual*/ void gatherInput() {};
 	/*virtual*/ void delayInputProcessing() {};
 	/*virtual*/ void swapBuffers();
+	/*virtual*/ void restoreGLContext();
 
-	// handy coordinate space conversion routines
+	
+    // handy coordinate space conversion routines
 	/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to) { return FALSE; };
 	/*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to) { return FALSE; };
 	/*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to) { return FALSE; };
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index e8d0a8bdb804e2a1f158996ea7f67ca64179fedf..9ed298a48182cb55f3bbcdd4c8c05117b28c79da 100755
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -901,6 +901,11 @@ void LLWindowMacOSX::swapBuffers()
 	CGLFlushDrawable(mContext);
 }
 
+void LLWindowMacOSX::restoreGLContext()
+{
+    CGLSetCurrentContext(mContext);
+}
+
 F32 LLWindowMacOSX::getGamma()
 {
 	F32 result = 2.2;	// Default to something sane
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index 825fd05c5f7cbdbfc499761e14aa534c56d59a68..194c9bb27a93835d90ab0bf460a69b1ee1d03db8 100755
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -87,6 +87,8 @@ class LLWindowMacOSX : public LLWindow
 	/*virtual*/ void gatherInput();
 	/*virtual*/ void delayInputProcessing() {};
 	/*virtual*/ void swapBuffers();
+	/*virtual*/ void restoreGLContext();
+
 
 	// handy coordinate space conversion routines
 	/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
diff --git a/indra/llwindow/llwindowmesaheadless.h b/indra/llwindow/llwindowmesaheadless.h
index 8f70aee4f61c9c031d85a5b5dcf7cf8fcd1e102b..00e42240e6581ab5711eec62321480177ee121d9 100755
--- a/indra/llwindow/llwindowmesaheadless.h
+++ b/indra/llwindow/llwindowmesaheadless.h
@@ -77,6 +77,7 @@ class LLWindowMesaHeadless : public LLWindow
 	/*virtual*/ void gatherInput() {};
 	/*virtual*/ void delayInputProcessing() {};
 	/*virtual*/ void swapBuffers();
+	/*virtual*/ void restoreGLContext() {};
 
 	// handy coordinate space conversion routines
 	/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to) { return FALSE; };
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index c5ce892a042c9d0ea423610d07b5875b6d23cea5..7193e6f45ab2205bb71084c99bc75ce17674a07a 100755
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -97,6 +97,7 @@ class LLWindowSDL : public LLWindow
 	/*virtual*/ void processMiscNativeEvents();
 	/*virtual*/ void gatherInput();
 	/*virtual*/ void swapBuffers();
+	/*virtual*/ void restoreGLContext() {};
 
 	/*virtual*/ void delayInputProcessing() { };
 
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index 169d264808d18677a807a5520e82783eeab7e750..2ca8d48fc7dc96f973a23e077d53bc09224c7aa4 100755
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -83,6 +83,7 @@ class LLWindowWin32 : public LLWindow
 	/*virtual*/ void gatherInput();
 	/*virtual*/ void delayInputProcessing();
 	/*virtual*/ void swapBuffers();
+	/*virtual*/ void restoreGLContext() {};
 
 	// handy coordinate space conversion routines
 	/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp
index 131675310ee1b5082a2a33d369a9f7b2bf728427..803e2b2fb22e9544df263b883be8b6c326b1d5b3 100755
--- a/indra/newview/lldaycyclemanager.cpp
+++ b/indra/newview/lldaycyclemanager.cpp
@@ -207,7 +207,7 @@ bool LLDayCycleManager::addPreset(const std::string& name, const LLSD& data)
 {
 	if (name.empty())
 	{
-		llassert(name.empty());
+		//llassert(name.empty());
 		return false;
 	}
 
diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index 897ee8429a75eb1c9205d3bcdfd3d5da349de966..4a89fc92b420eb47115f855014cf16037d8fe245 100755
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -64,6 +64,8 @@
 #include "llimagedimensionsinfo.h"
 #include "llviewercontrol.h"
 #include "lltrans.h"
+#include "llviewerdisplay.h"
+
 /*=======================================*/
 /*  Formal declarations, constants, etc. */
 /*=======================================*/ 
@@ -842,6 +844,9 @@ bool LLLocalBitmapMgr::addUnit()
 	LLFilePicker& picker = LLFilePicker::instance();
 	if (picker.getMultipleOpenFiles(LLFilePicker::FFLOAD_IMAGE))
 	{
+		//For fix problem with Core Flow view on OSX
+        restoreGLContext();
+        
 		sTimer.stopTimer();
 
 		std::string filename = picker.getFirstFile();
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 981e4c40aa904533c1adf9ecf3215b19836eaa91..dfbb128d3b7f37bdb3cf66e1ddabc7d293b59c2d 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1344,6 +1344,14 @@ void swap()
 	gDisplaySwapBuffers = TRUE;
 }
 
+void restoreGLContext()
+{
+	if(gViewerWindow && gViewerWindow->getWindow()) 
+	{
+		gViewerWindow->getWindow()->restoreGLContext();
+	}
+}
+
 void renderCoordinateAxes()
 {
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
diff --git a/indra/newview/llviewerdisplay.h b/indra/newview/llviewerdisplay.h
index f6467d7f93c4a65bdd0cb385732fcb87f34060a6..dcc78fe42f03a513b4a9ab6269ae9fb9b8552893 100755
--- a/indra/newview/llviewerdisplay.h
+++ b/indra/newview/llviewerdisplay.h
@@ -34,6 +34,8 @@ void display_cleanup();
 
 void display(BOOL rebuild = TRUE, F32 zoom_factor = 1.f, int subfield = 0, BOOL for_snapshot = FALSE);
 
+void restoreGLContext();
+
 extern BOOL gDisplaySwapBuffers;
 extern BOOL gDepthDirty;
 extern BOOL	gTeleportDisplay;