diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index ebc9ee244e7131733c1e5372629bbfa9f63c97a7..270d5294f9f8076ae25b2c32ed1f918de5f4f09b 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -3201,7 +3201,23 @@ S32	LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
 	LLFontGL::EWordWrapStyle word_wrap_style = (line_offset == 0) 
 		? LLFontGL::WORD_BOUNDARY_IF_POSSIBLE 
 		: LLFontGL::ONLY_WORD_BOUNDARIES;
-	S32 num_chars = mStyle->getFont()->maxDrawableChars(text.c_str() + segment_offset + mStart, 
+	
+	
+	LLWString offsetString(text.c_str() + segment_offset + mStart);
+
+	if(getLength() < segment_offset + mStart)
+	{
+		llerrs << "getLength() < segment_offset + mStart\t getLength()\t" << getLength() << "\tsegment_offset:\t" 
+						<< segment_offset << "\tmStart:\t" << mStart << "\tsegments\t" << mEditor.mSegments.size() << "\tmax_chars\t" << max_chars << llendl;
+	}
+
+	if(offsetString.length() + 1 < max_chars)
+	{
+		llerrs << "offsetString.length() + 1 < max_chars\t max_chars:\t" << max_chars << "\toffsetString.length():\t" << offsetString.length()
+			<< getLength() << "\tsegment_offset:\t" << segment_offset << "\tmStart:\t" << mStart << "\tsegments\t" << mEditor.mSegments.size() << llendl;
+	}
+	
+	S32 num_chars = mStyle->getFont()->maxDrawableChars(offsetString.c_str(), 
 												(F32)num_pixels,
 												max_chars, 
 												word_wrap_style);
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index b221daf9365283c724366b9551b2b0c5419ff39c..43c6b558bc920e7d6cd7199a7fac6e5eb2fc3881 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -174,6 +174,7 @@ void LLNotificationChiclet::onMenuItemClicked(const LLSD& user_data)
 	if("close all" == action)
 	{
 		LLNotificationWellWindow::getInstance()->closeAll();
+		LLIMWellWindow::getInstance()->closeAll();
 	}
 }
 
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index 171509af59d1e3f953610db5e6ade8e83815674c..89b608b5864000f7d950b879b3b415700634440b 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -485,11 +485,14 @@ void LLFloaterIMNearbyChat::onChatBoxKeystroke()
 		if (LLGestureMgr::instance().matchPrefix(utf8_trigger, &utf8_out_str))
 		{
 			std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size());
-			mInputEditor->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part
+			if (!rest_of_match.empty())
+			{
+				mInputEditor->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part
 
-			// Select to end of line, starting from the character
-			// after the last one the user typed.
-			mInputEditor->selectNext(rest_of_match, false);
+				// Select to end of line, starting from the character
+				// after the last one the user typed.
+				mInputEditor->selectNext(rest_of_match, false);
+			}
 		}
 		else if (matchChatTypeTrigger(utf8_trigger, &utf8_out_str))
 		{
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index a84dbcd84a112f5d1b9ca2b280841fce523f8bc7..ca04d27d1133032ce4ddfbb7a9b424628fd0b7cb 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -224,8 +224,9 @@ void on_new_message(const LLSD& msg)
     // actions:
 
     // 0. nothing - exit
-    if ("none" == user_preferences ||
+    if (("none" == user_preferences ||
     		ON_TOP_AND_ITEM_IS_SELECTED == conversations_floater_status)
+    	&& session_floater->isMessagePaneExpanded())
     {
     	return;
     }
@@ -294,9 +295,10 @@ void on_new_message(const LLSD& msg)
     }
 
     // 4. Toast
-    if ("toast" == user_preferences &&
+    if (("toast" == user_preferences &&
     		(CLOSED == conversations_floater_status
     		    || NOT_ON_TOP == conversations_floater_status))
+    		    || !session_floater->isMessagePaneExpanded())
     {
         //Show IM toasts (upper right toasts)
         // Skip toasting for system messages and for nearby chat