diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index 1a948fdd008fbe28a0a4bcf209a00c644b32dd76..da55ababab4b18cde1adc79a5b21192b09aa776e 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -94,7 +94,8 @@ LLPanel::LLPanel(const LLPanel::Params& p)
 	mBorder(NULL),
 	mLabel(p.label),
 	mCommitCallbackRegistrar(false),
-	mEnableCallbackRegistrar(false)
+	mEnableCallbackRegistrar(false),
+	mXMLFilename("")
 {
 	setIsChrome(FALSE);
 
@@ -486,8 +487,13 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
 		LLFastTimer timer(FTM_PANEL_SETUP);
 
 		LLXMLNodePtr referenced_xml;
-		std::string xml_filename;
-		node->getAttributeString("filename", xml_filename);
+		std::string xml_filename = mXMLFilename;
+		
+		// if the panel didn't provide a filename, check the node
+		if (xml_filename.empty())
+		{
+			node->getAttributeString("filename", xml_filename);
+		}
 
 		if (!xml_filename.empty())
 		{
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index 552a621a8e8638d5a7efcf30228b6b10d5e57c9b..2a70467ffc34718ae995848d7b575c38b2c5aed6 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -249,6 +249,8 @@ public:
 
 	//call onOpen to let panel know when it's about to be shown or activated
 	virtual void	onOpen(const LLSD& key) {}
+
+	void setXMLFilename(std::string filename) { mXMLFilename = filename; };
 	
 protected:
 	// Override to set not found list
@@ -278,6 +280,9 @@ private:
 	ui_string_map_t	mUIStrings;
 
 	std::string		mRequirementsError;
+
+	// for setting the xml filename when building panel in context dependent cases
+	std::string		mXMLFilename;
 	
 }; // end class LLPanel
 
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 6050fbfa5d503cf0e7e0659f535ecdedf7f32b20..1a7f72d49c75153ed1f2a9a46ff117e59371a3ec 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -422,7 +422,7 @@ void LLFloaterPreference::apply()
 			panel->apply();
 	}
 	// hardware menu apply
-	LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::findTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
+	LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
 	if (hardware_settings)
 	{
 		hardware_settings->apply();
@@ -514,7 +514,7 @@ void LLFloaterPreference::cancel()
 	LLFloaterReg::hideInstance("pref_joystick");
 	
 	// cancel hardware menu
-	LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::findTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
+	LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
 	if (hardware_settings)
 	{
 		hardware_settings->cancel();
@@ -649,7 +649,7 @@ void LLFloaterPreference::refreshEnabledGraphics()
 	{
 		instance->refreshEnabledState();
 	}
-	LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::findTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
+	LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
 	if (hardware_settings)
 	{
 		hardware_settings->refreshEnabledState();
diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp
index 954da8abd7657dfe1bc2429467c99b4287c8c42b..0b4e0f9317cc2243cf92dd4a8197de454726b1db 100644
--- a/indra/newview/llimpanel.cpp
+++ b/indra/newview/llimpanel.cpp
@@ -2151,8 +2151,7 @@ void* LLIMFloater::createPanelIMControl(void* userdata)
 {
 	LLIMFloater *self = (LLIMFloater*)userdata;
 	self->mControlPanel = new LLPanelIMControlPanel();
-	LLUICtrlFactory::getInstance()->buildPanel(self->mControlPanel, "panel_im_control_panel.xml");
-	self->mControlPanel->setVisible(FALSE);
+	self->mControlPanel->setXMLFilename("panel_im_control_panel.xml");
 	return self->mControlPanel;
 }
 
@@ -2162,8 +2161,7 @@ void* LLIMFloater::createPanelGroupControl(void* userdata)
 {
 	LLIMFloater *self = (LLIMFloater*)userdata;
 	self->mControlPanel = new LLPanelGroupControlPanel();
-	LLUICtrlFactory::getInstance()->buildPanel(self->mControlPanel, "panel_group_control_panel.xml");
-	self->mControlPanel->setVisible(FALSE);
+	self->mControlPanel->setXMLFilename("panel_group_control_panel.xml");
 	return self->mControlPanel;
 }
 
diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp
index 1d50bb26f6eb1b2011e691933d650fd59db7b72c..51cdc5af93ebe31f1d221ecf19f7bb2ea0b17276 100644
--- a/indra/newview/llpanelimcontrolpanel.cpp
+++ b/indra/newview/llpanelimcontrolpanel.cpp
@@ -53,6 +53,7 @@ BOOL LLPanelIMControlPanel::postBuild()
 	childSetAction("add_friend_btn", boost::bind(&LLPanelIMControlPanel::onAddFriendButtonClicked, this));
 	childSetAction("call_btn", boost::bind(&LLPanelIMControlPanel::onCallButtonClicked, this));
 	childSetAction("share_btn", boost::bind(&LLPanelIMControlPanel::onShareButtonClicked, this));
+	childSetEnabled("add_friend_btn", !LLAvatarActions::isFriend(getChild<LLAvatarIconCtrl>("avatar_icon")->getAvatarId()));
 
 	return TRUE;
 }
diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp
index 0558cc34884bf02b03966499809760fd68966856..9990c22dac216b8e6dd0c7aded337dcb0c4f1ec0 100644
--- a/indra/newview/llsidetray.cpp
+++ b/indra/newview/llsidetray.cpp
@@ -34,6 +34,7 @@
 
 #include "lltextbox.h"
 
+#include "llbottomtray.h"
 #include "llsidetray.h"
 #include "llviewerwindow.h"
 #include "llaccordionctrl.h"
@@ -650,7 +651,7 @@ void	LLSideTray::setPanelRect	()
 	if(!mCollapsed)
 		panel_width+=mMaxBarWidth;
 
-	S32 panel_height = parent_rect.getHeight()-fake_top_offset;
+	S32 panel_height = parent_rect.getHeight() - fake_top_offset - LLBottomTray::getInstance()->getRect().getHeight();
 	LLRect panel_rect;
 	panel_rect.setLeftTopAndSize( parent_rect.mRight-panel_width, parent_rect.mTop-fake_top_offset, panel_width, panel_height);
 	setRect(panel_rect);
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index e757090da8eb2d0783186946f46a2390db32fe41..2b1dbf8e84a2a6d7107d6d34a4e1dd6f61b7ffde 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2440,7 +2440,7 @@ void LLViewerWindow::updateUI()
 
 	updateWorldViewRect();
 
-	updateBottomTrayRect();
+	//updateBottomTrayRect();
 
 	LLView::sMouseHandlerMessage.clear();