diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 853f279c95aca53e113fda0de32892e79845e45b..925fca1b4be8b348604f52fa7fea11c1a65bd72a 100755
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -207,6 +207,10 @@ namespace {
 #endif
 }
 
+namespace LLError
+{
+	void clean();
+}
 
 namespace
 {
@@ -352,7 +356,11 @@ namespace
 		Globals()
 			:	messageStreamInUse(false)
 			{ }
-		
+
+		~Globals()
+		{
+			LLError::clean();
+		}
 	};
 
 	void Globals::addCallSite(LLError::CallSite& site)
@@ -380,8 +388,9 @@ namespace
 		   is.
 		   See C++ FAQ Lite, sections 10.12 through 10.14
 		*/
-		static Globals* globals = new Globals;		
-		return *globals;
+
+		static Globals globals;
+		return globals;
 	}
 }
 
@@ -415,6 +424,7 @@ namespace LLError
 		static void reset();
 		static Settings* saveAndReset();
 		static void restore(Settings*);
+		static void clean();
 		
 	private:
 		Settings()
@@ -446,6 +456,15 @@ namespace LLError
 		}
 		return *p;
 	}
+
+	void Settings::clean()
+	{
+		Globals::get().invalidateCallSites();
+
+		Settings*& p = getPtr();
+		delete p;
+		p = NULL;
+	}
 	
 	void Settings::reset()
 	{
@@ -480,10 +499,7 @@ namespace LLError
 		static Settings* currentSettings = NULL;
 		return currentSettings;
 	}
-}
 
-namespace LLError
-{
 	CallSite::CallSite(ELevel level,
 					const char* file,
 					int line,
@@ -721,11 +737,7 @@ namespace LLError
 			setLevels(s.tagLevelMap,		entry["tags"],		level);
 		}
 	}
-}
-
 
-namespace LLError
-{
 	Recorder::~Recorder()
 		{ }
 
@@ -756,18 +768,26 @@ namespace LLError
 			std::remove(s.recorders.begin(), s.recorders.end(), recorder),
 			s.recorders.end());
 	}
-}
 
-namespace LLError
-{
+	void deleteRecorder(LLError::Settings& settings)
+	{
+		removeRecorder(settings.fileRecorder);
+		delete settings.fileRecorder;
+		settings.fileRecorder = NULL;
+		settings.fileRecorderFileName.clear();
+	}
+
+	void clean()
+	{
+		deleteRecorder(LLError::Settings::get());
+		LLError::Settings::clean();
+	}
+
 	void logToFile(const std::string& file_name)
 	{
 		LLError::Settings& s = LLError::Settings::get();
 
-		removeRecorder(s.fileRecorder);
-		delete s.fileRecorder;
-		s.fileRecorder = NULL;
-		s.fileRecorderFileName.clear();
+		deleteRecorder(s);
 		
 		if (file_name.empty())
 		{
@@ -839,8 +859,6 @@ namespace
 			}
 		}
 	}
-}
-
 
 /*
 Recorder formats:
@@ -870,7 +888,6 @@ You get:
 	
 */
 
-namespace {
 	bool checkLevelMap(const LevelMap& map, const std::string& key,
 						LLError::ELevel& level)
 	{
@@ -1127,13 +1144,7 @@ namespace LLError
 			s.crashFunction(message);
 		}
 	}
-}
-
-
-
 
-namespace LLError
-{
 	Settings* saveAndResetSettings()
 	{
 		return Settings::saveAndReset();
@@ -1226,10 +1237,7 @@ namespace LLError
 
 		return chars ? time_str : "time error";
 	}
-}
-
-namespace LLError
-{     
+     
 	char** LLCallStacks::sBuffer = NULL ;
 	S32    LLCallStacks::sIndex  = 0 ;
 
diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp
index fb2d43e3b0d6c25af71214e8cf3f1bbe255198fd..aa66ceb4ecce28bbcab64fc6b497a1e7db2e84b0 100755
--- a/indra/llcrashlogger/llcrashlogger.cpp
+++ b/indra/llcrashlogger/llcrashlogger.cpp
@@ -44,7 +44,7 @@
 #include "llsdserialize.h"
 #include "llproxy.h"
 
-LLPumpIO* gServicePump;
+LLPumpIO* gServicePump = NULL;
 BOOL gBreak = false;
 BOOL gSent = false;
 
@@ -80,7 +80,8 @@ LLCrashLogger::LLCrashLogger() :
 
 LLCrashLogger::~LLCrashLogger()
 {
-
+	delete gServicePump;
+	gServicePump = NULL;
 }
 
 // TRIM_SIZE must remain larger than LINE_SEARCH_SIZE.
diff --git a/indra/llmessage/llhttpsender.cpp b/indra/llmessage/llhttpsender.cpp
index c48cbc42a6264b9e5ceb6671c46a377f97ad7baf..d0bd343db6ddbb2f0b4c44061bf7863263335359 100755
--- a/indra/llmessage/llhttpsender.cpp
+++ b/indra/llmessage/llhttpsender.cpp
@@ -38,7 +38,7 @@ namespace
 {
 	typedef std::map<LLHost, LLHTTPSender*> SenderMap;
 	static SenderMap senderMap;
-	static LLHTTPSender* defaultSender = new LLHTTPSender();
+	static LLPointer<LLHTTPSender> defaultSender(new LLHTTPSender());
 }
 
 //virtual 
@@ -90,6 +90,5 @@ void LLHTTPSender::clearSender(const LLHost& host)
 //static 
 void LLHTTPSender::setDefaultSender(LLHTTPSender* sender)
 {
-	delete defaultSender;
 	defaultSender = sender;
 }
diff --git a/indra/llmessage/llhttpsender.h b/indra/llmessage/llhttpsender.h
index 88920db24d4c515712179affa83f8774f8e0ca08..ff8fa2f95b16fbfddb136227489118cefd52f4d9 100755
--- a/indra/llmessage/llhttpsender.h
+++ b/indra/llmessage/llhttpsender.h
@@ -32,7 +32,7 @@
 class LLHost;
 class LLSD;
 
-class LLHTTPSender
+class LLHTTPSender : public LLThreadSafeRefCount
 {
  public:
 
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index e63b41f97c56121288d418204658dace49e273ec..17b9b91ba795b9a50a768d2fd2850305af33aa69 100755
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -330,17 +330,16 @@ class LLRegisterPanelClass
 
 // local static instance for registering a particular panel class
 template<typename T>
-class LLRegisterPanelClassWrapper
-:	public LLRegisterPanelClass
+	class LLPanelInjector
 {
 public:
-	// reigister with either the provided builder, or the generic templated builder
-	LLRegisterPanelClassWrapper(const std::string& tag);
+	// register with either the provided builder, or the generic templated builder
+	LLPanelInjector(const std::string& tag);
 };
 
 
 template<typename T>
-LLRegisterPanelClassWrapper<T>::LLRegisterPanelClassWrapper(const std::string& tag) 
+	LLPanelInjector<T>::LLPanelInjector(const std::string& tag) 
 {
 	LLRegisterPanelClass::instance().addPanelClass(tag,&LLRegisterPanelClass::defaultPanelClassBuilder<T>);
 }
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 80a80f42989bc155bbd758064a66005a5dafb346..2764025d75d82c99a4799ff0e8272c26fe451a07 100755
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -200,14 +200,6 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
                      LPSTR     lpCmdLine,
                      int       nCmdShow)
 {
-#ifdef INCLUDE_VLD
-	// only works for debug builds (hard coded into vld.h)
-	#ifdef _DEBUG
-		// start with Visual Leak Detector turned off
-		VLDGlobalDisable();
-	#endif // _DEBUG
-#endif // INCLUDE_VLD
-
 	const S32 MAX_HEAPS = 255;
 	DWORD heap_enable_lfh_error[MAX_HEAPS];
 	S32 num_heaps = 0;
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index e86d6930e89025c04ebb19a369fdb2f99758c89a..e200e0ee9ed8e4fe8caf8bea674163adcd9d8025 100755
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -43,7 +43,7 @@
 #include "llpaneloutfitedit.h"
 #include "lltrans.h"
 
-static LLRegisterPanelClassWrapper<LLCOFWearables> t_cof_wearables("cof_wearables");
+static LLPanelInjector<LLCOFWearables> t_cof_wearables("cof_wearables");
 
 const LLSD REARRANGE = LLSD().with("rearrange", LLSD());
 
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index c85d048c5a9163aa98848ac7161b3cb210f3e5db..d0939b3eee5f7ddcecc353ad5d3b7caf2ca2f625 100755
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -151,7 +151,7 @@ void LLPanelCameraItem::setValue(const LLSD& value)
 	getChildView("selected_picture")->setVisible( value["selected"]);
 }
 
-static LLRegisterPanelClassWrapper<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel");
+static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel");
 
 //-------------------------------------------------------------------------------
 // LLPanelCameraZoom
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index c339ee3bebc1cc03586e4a119a3886a3123c1e5f..b50a2e6f853b2fb4d172f35eafdc3caff84bd0d6 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -1823,7 +1823,7 @@ class LLPanelPreference::Updater : public LLEventTimer
 	callback_t mCallback;
 };
 //----------------------------------------------------------------------------
-static LLRegisterPanelClassWrapper<LLPanelPreference> t_places("panel_preference");
+static LLPanelInjector<LLPanelPreference> t_places("panel_preference");
 LLPanelPreference::LLPanelPreference()
 : LLPanel(),
   mBandWidthUpdater(NULL)
@@ -2063,8 +2063,8 @@ class LLPanelPreferencePrivacy : public LLPanelPreference
 	std::list<std::string> mAccountIndependentSettings;
 };
 
-static LLRegisterPanelClassWrapper<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
-static LLRegisterPanelClassWrapper<LLPanelPreferencePrivacy> t_pref_privacy("panel_preference_privacy");
+static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
+static LLPanelInjector<LLPanelPreferencePrivacy> t_pref_privacy("panel_preference_privacy");
 
 BOOL LLPanelPreferenceGraphics::postBuild()
 {
diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index 2a74c8e3eac8f145a9de54d7fe8d5183041ae6ab..9490769d8caf08c08620a37b7d8ab03ea91a42b5 100644
--- a/indra/newview/llfloatersocial.cpp
+++ b/indra/newview/llfloatersocial.cpp
@@ -47,10 +47,10 @@
 #include "llviewercontrol.h"
 #include "llviewermedia.h"
 
-static LLRegisterPanelClassWrapper<LLSocialStatusPanel> t_panel_status("llsocialstatuspanel");
-static LLRegisterPanelClassWrapper<LLSocialPhotoPanel> t_panel_photo("llsocialphotopanel");
-static LLRegisterPanelClassWrapper<LLSocialCheckinPanel> t_panel_checkin("llsocialcheckinpanel");
-static LLRegisterPanelClassWrapper<LLSocialAccountPanel> t_panel_account("llsocialaccountpanel");
+static LLPanelInjector<LLSocialStatusPanel> t_panel_status("llsocialstatuspanel");
+static LLPanelInjector<LLSocialPhotoPanel> t_panel_photo("llsocialphotopanel");
+static LLPanelInjector<LLSocialCheckinPanel> t_panel_checkin("llsocialcheckinpanel");
+static LLPanelInjector<LLSocialAccountPanel> t_panel_account("llsocialaccountpanel");
 
 const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte
 const std::string DEFAULT_CHECKIN_LOCATION_URL = "http://maps.secondlife.com/";
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index c15b6bd0d35020c33f10033592d0e42f56fb7aad..ff8bfafb791da2fd4a87f61f0032e27e580d00ec 100755
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -343,7 +343,7 @@ class LLOutfitContextMenu : public LLListContextMenu
 
 //////////////////////////////////////////////////////////////////////////
 
-static LLRegisterPanelClassWrapper<LLOutfitsList> t_outfits_list("outfits_list");
+static LLPanelInjector<LLOutfitsList> t_outfits_list("outfits_list");
 
 LLOutfitsList::LLOutfitsList()
 	:	LLPanelAppearanceTab()
diff --git a/indra/newview/llpanelblockedlist.cpp b/indra/newview/llpanelblockedlist.cpp
index 115114bb53ba5f3fa2171b299855a7bb19575855..9665314e7535c9ab0a04e5c876c9899ca0406f6a 100755
--- a/indra/newview/llpanelblockedlist.cpp
+++ b/indra/newview/llpanelblockedlist.cpp
@@ -48,7 +48,7 @@
 #include "llsidetraypanelcontainer.h"
 #include "llviewercontrol.h"
 
-static LLRegisterPanelClassWrapper<LLPanelBlockedList> t_panel_blocked_list("panel_block_list_sidetray");
+static LLPanelInjector<LLPanelBlockedList> t_panel_blocked_list("panel_block_list_sidetray");
 
 //
 // Constants
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index e71dba5caee73871c17c7e9d531ceeed95a2b2a2..0621cc8fad1e7e1e76bc1a6f84418016f1a66128 100755
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -62,7 +62,7 @@
 #include "llappearancemgr.h"
 
 // register panel with appropriate XML
-static LLRegisterPanelClassWrapper<LLPanelEditWearable> t_edit_wearable("panel_edit_wearable");
+static LLPanelInjector<LLPanelEditWearable> t_edit_wearable("panel_edit_wearable");
 
 // subparts of the UI for focus, camera position, etc.
 enum ESubpart {
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index a0ca82da46a7307c70be1b27e1cbd8bc723a5a1c..c872a15af7fadcc7128ff5e9229c6305bf915a4d 100755
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -56,7 +56,7 @@
 
 #include "lltrans.h"
 
-static LLRegisterPanelClassWrapper<LLPanelGroup> t_panel_group("panel_group_info_sidetray");
+static LLPanelInjector<LLPanelGroup> t_panel_group("panel_group_info_sidetray");
 
 
 
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 68835ec5b8075ad54d31be18351c39eae5eeef50..eaf33c71086a83d6ee20fb788c4be27dc997b1cf 100755
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -53,7 +53,7 @@
 #include "lltrans.h"
 #include "llviewerwindow.h"
 
-static LLRegisterPanelClassWrapper<LLPanelGroupGeneral> t_panel_group_general("panel_group_general");
+static LLPanelInjector<LLPanelGroupGeneral> t_panel_group_general("panel_group_general");
 
 // consts
 const S32 MATURE_CONTENT = 1;
diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp
index c927aeacb30d4b495e9110bc5501ce5595042ea4..17707557bb2cae8304c8ce32f6a2e9355386bef4 100755
--- a/indra/newview/llpanelgrouplandmoney.cpp
+++ b/indra/newview/llpanelgrouplandmoney.cpp
@@ -55,7 +55,7 @@
 #include "llfloaterworldmap.h"
 #include "llviewermessage.h"
 
-static LLRegisterPanelClassWrapper<LLPanelGroupLandMoney> t_panel_group_money("panel_group_land_money");
+static LLPanelInjector<LLPanelGroupLandMoney> t_panel_group_money("panel_group_land_money");
 
 
 
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index 522ba5afae403b2c17f3492adf4200ab0dbf7e09..0dfb8fef53fad5d27dbbebc423a84f4a64d0f21f 100755
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -57,7 +57,7 @@
 #include "llnotificationsutil.h"
 #include "llgiveinventory.h"
 
-static LLRegisterPanelClassWrapper<LLPanelGroupNotices> t_panel_group_notices("panel_group_notices");
+static LLPanelInjector<LLPanelGroupNotices> t_panel_group_notices("panel_group_notices");
 
 
 /////////////////////////
diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp
index b89e7b8b73bb2604db5aed3b68eae7a29c736a50..c30c932c415c64c15b2e9e6aee67f3d93125bc2a 100755
--- a/indra/newview/llpanelgrouproles.cpp
+++ b/indra/newview/llpanelgrouproles.cpp
@@ -55,7 +55,7 @@
 
 #include "roles_constants.h"
 
-static LLRegisterPanelClassWrapper<LLPanelGroupRoles> t_panel_group_roles("panel_group_roles");
+static LLPanelInjector<LLPanelGroupRoles> t_panel_group_roles("panel_group_roles");
 
 bool agentCanRemoveFromRole(const LLUUID& group_id,
 							const LLUUID& role_id)
@@ -733,7 +733,7 @@ void LLPanelGroupSubTab::setFooterEnabled(BOOL enable)
 ////////////////////////////
 
 
-static LLRegisterPanelClassWrapper<LLPanelGroupMembersSubTab> t_panel_group_members_subtab("panel_group_members_subtab");
+static LLPanelInjector<LLPanelGroupMembersSubTab> t_panel_group_members_subtab("panel_group_members_subtab");
 
 LLPanelGroupMembersSubTab::LLPanelGroupMembersSubTab()
 : 	LLPanelGroupSubTab(),
@@ -1755,7 +1755,7 @@ void LLPanelGroupMembersSubTab::updateMembers()
 // LLPanelGroupRolesSubTab
 ////////////////////////////
 
-static LLRegisterPanelClassWrapper<LLPanelGroupRolesSubTab> t_panel_group_roles_subtab("panel_group_roles_subtab");
+static LLPanelInjector<LLPanelGroupRolesSubTab> t_panel_group_roles_subtab("panel_group_roles_subtab");
 
 LLPanelGroupRolesSubTab::LLPanelGroupRolesSubTab()
   : LLPanelGroupSubTab(),
@@ -2469,7 +2469,7 @@ void LLPanelGroupRolesSubTab::saveRoleChanges(bool select_saved_role)
 // LLPanelGroupActionsSubTab
 ////////////////////////////
 
-static LLRegisterPanelClassWrapper<LLPanelGroupActionsSubTab> t_panel_group_actions_subtab("panel_group_actions_subtab");
+static LLPanelInjector<LLPanelGroupActionsSubTab> t_panel_group_actions_subtab("panel_group_actions_subtab");
 
 
 LLPanelGroupActionsSubTab::LLPanelGroupActionsSubTab()
diff --git a/indra/newview/llpanelhome.cpp b/indra/newview/llpanelhome.cpp
index b03bab31272a8cd5dfca70e90f21b8fd79c03a4e..ab0ccffae49004807417e601a1840ff78ec416c9 100755
--- a/indra/newview/llpanelhome.cpp
+++ b/indra/newview/llpanelhome.cpp
@@ -31,7 +31,7 @@
 #include "llmediactrl.h"
 #include "llviewerhome.h"
 
-static LLRegisterPanelClassWrapper<LLPanelHome> t_home("panel_sidetray_home");
+static LLPanelInjector<LLPanelHome> t_home("panel_sidetray_home");
 
 LLPanelHome::LLPanelHome() :
 	LLPanel(),
diff --git a/indra/newview/llpanellandmarkinfo.cpp b/indra/newview/llpanellandmarkinfo.cpp
index 5c9b968ac908e3c5b19b0c8af053df0d6b60e712..934f8ed8c751a8d129cd3b8372f634b5821c2b9d 100755
--- a/indra/newview/llpanellandmarkinfo.cpp
+++ b/indra/newview/llpanellandmarkinfo.cpp
@@ -53,7 +53,7 @@ typedef std::pair<LLUUID, std::string> folder_pair_t;
 static bool cmp_folders(const folder_pair_t& left, const folder_pair_t& right);
 static void collectLandmarkFolders(LLInventoryModel::cat_array_t& cats);
 
-static LLRegisterPanelClassWrapper<LLPanelLandmarkInfo> t_landmark_info("panel_landmark_info");
+static LLPanelInjector<LLPanelLandmarkInfo> t_landmark_info("panel_landmark_info");
 
 // Statics for textures filenames
 static std::string icon_pg;
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index bd173fadc7377b7a6aa384d3d549af6cf3c74829..68c22c12fd1ee838fcb01d9dd19fc733e5870b8c 100755
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -58,7 +58,7 @@
 
 const std::string FILTERS_FILENAME("filters.xml");
 
-static LLRegisterPanelClassWrapper<LLPanelMainInventory> t_inventory("panel_main_inventory");
+static LLPanelInjector<LLPanelMainInventory> t_inventory("panel_main_inventory");
 
 void on_file_loaded_for_save(BOOL success, 
 							 LLViewerFetchedTexture *src_vi,
diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp
index dcecce6fe427725e64c552514f07050a0185fd96..79e079f6bdfb95f2b1a776eb480d651c4f6eff4a 100755
--- a/indra/newview/llpanelmarketplaceinbox.cpp
+++ b/indra/newview/llpanelmarketplaceinbox.cpp
@@ -38,7 +38,7 @@
 #include "llviewercontrol.h"
 
 
-static LLRegisterPanelClassWrapper<LLPanelMarketplaceInbox> t_panel_marketplace_inbox("panel_marketplace_inbox");
+static LLPanelInjector<LLPanelMarketplaceInbox> t_panel_marketplace_inbox("panel_marketplace_inbox");
 
 const LLPanelMarketplaceInbox::Params& LLPanelMarketplaceInbox::getDefaultParams() 
 { 
diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp
index a9af56f750b12a9bfbe43d876268136fbe44281d..7a408e736f53e0e1040fe57cf70e0d38e6072d38 100755
--- a/indra/newview/llpanelme.cpp
+++ b/indra/newview/llpanelme.cpp
@@ -48,7 +48,7 @@
 #include "lltabcontainer.h"
 #include "lltexturectrl.h"
 
-static LLRegisterPanelClassWrapper<LLPanelMe> t_panel_me_profile("panel_me");
+static LLPanelInjector<LLPanelMe> t_panel_me_profile("panel_me");
 
 LLPanelMe::LLPanelMe(void) 
  : LLPanelProfile()
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index c09d4393c81c79e3f9f2a5a8e9fd9fc2e0c7d92b..f75d76da94dbcd91d47fec0ab6c8e4df01a4f228 100755
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -74,7 +74,7 @@
 #include "llwearabletype.h"
 #include "llweb.h"
 
-static LLRegisterPanelClassWrapper<LLPanelOutfitEdit> t_outfit_edit("panel_outfit_edit");
+static LLPanelInjector<LLPanelOutfitEdit> t_outfit_edit("panel_outfit_edit");
 
 const U64 WEARABLE_MASK = (1LL << LLInventoryType::IT_WEARABLE);
 const U64 ATTACHMENT_MASK = (1LL << LLInventoryType::IT_ATTACHMENT) | (1LL << LLInventoryType::IT_OBJECT);
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp
index f90236f6f2890ac53dc1c9677f610063980cacbc..e0132d20fbf11915da8aad689499e615a5cc9da9 100755
--- a/indra/newview/llpaneloutfitsinventory.cpp
+++ b/indra/newview/llpaneloutfitsinventory.cpp
@@ -46,7 +46,7 @@
 static const std::string OUTFITS_TAB_NAME = "outfitslist_tab";
 static const std::string COF_TAB_NAME = "cof_tab";
 
-static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory");
+static LLPanelInjector<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory");
 
 LLPanelOutfitsInventory::LLPanelOutfitsInventory() :
 	mMyOutfitsPanel(NULL),
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index f551fc96eed45eb26e32bd38619887de1734ca37..f5542ee7a6cd38f1a5ebc2cbd6d088b0d8d3f22e 100755
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -216,7 +216,7 @@ static const LLAvatarItemStatusComparator STATUS_COMPARATOR;
 static LLAvatarItemDistanceComparator DISTANCE_COMPARATOR;
 static const LLAvatarItemRecentSpeakerComparator RECENT_SPEAKER_COMPARATOR;
 
-static LLRegisterPanelClassWrapper<LLPanelPeople> t_people("panel_people");
+static LLPanelInjector<LLPanelPeople> t_people("panel_people");
 
 //=============================================================================
 
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index cfbc8f1a94de31af71f925184fb24c8ac0dd78e1..f0617266dbd6ffd9fddc8694f635c5f6faec8e8d 100755
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -69,7 +69,7 @@ static const std::string CLASSIFIED_ID("classified_id");
 static const std::string CLASSIFIED_NAME("classified_name");
 
 
-static LLRegisterPanelClassWrapper<LLPanelPicks> t_panel_picks("panel_picks");
+static LLPanelInjector<LLPanelPicks> t_panel_picks("panel_picks");
 
 
 class LLPickHandler : public LLCommandHandler,
diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp
index 5d9971c16c14ad562dc7a8e9aaa32b42bbf453c0..14b5d9af47c435a8326ef2be09b7093991842d1b 100755
--- a/indra/newview/llpanelplaceprofile.cpp
+++ b/indra/newview/llpanelplaceprofile.cpp
@@ -53,7 +53,7 @@
 #include "llviewerparcelmgr.h"
 #include "llviewerregion.h"
 
-static LLRegisterPanelClassWrapper<LLPanelPlaceProfile> t_place_profile("panel_place_profile");
+static LLPanelInjector<LLPanelPlaceProfile> t_place_profile("panel_place_profile");
 
 // Statics for textures filenames
 static std::string icon_pg;
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index 8bb3ace2d9f1af8e3943f61e7ac9a3a9f3ccc68d..499b9ab62e15db1be86679f2c1eca3f6595acc1e 100755
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -229,7 +229,7 @@ class LLPlacesRemoteParcelInfoObserver : public LLRemoteParcelInfoObserver
 };
 
 
-static LLRegisterPanelClassWrapper<LLPanelPlaces> t_places("panel_places");
+static LLPanelInjector<LLPanelPlaces> t_places("panel_places");
 
 LLPanelPlaces::LLPanelPlaces()
 	:	LLPanel(),
diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp
index 381c11348d58084db53d1914060313dc1b020493..47e46a968f84b94ddd07e797d7986687571fb3c9 100755
--- a/indra/newview/llpanelsnapshotinventory.cpp
+++ b/indra/newview/llpanelsnapshotinventory.cpp
@@ -60,7 +60,7 @@ class LLPanelSnapshotInventory
 	void onSend();
 };
 
-static LLRegisterPanelClassWrapper<LLPanelSnapshotInventory> panel_class("llpanelsnapshotinventory");
+static LLPanelInjector<LLPanelSnapshotInventory> panel_class("llpanelsnapshotinventory");
 
 LLPanelSnapshotInventory::LLPanelSnapshotInventory()
 {
diff --git a/indra/newview/llpanelsnapshotlocal.cpp b/indra/newview/llpanelsnapshotlocal.cpp
index d153ff598d0f16820a94fc0a1920f16af4c0c595..43e38b95e25c4004b781d16b57d65db8641713b9 100755
--- a/indra/newview/llpanelsnapshotlocal.cpp
+++ b/indra/newview/llpanelsnapshotlocal.cpp
@@ -63,7 +63,7 @@ class LLPanelSnapshotLocal
 	void onSaveFlyoutCommit(LLUICtrl* ctrl);
 };
 
-static LLRegisterPanelClassWrapper<LLPanelSnapshotLocal> panel_class("llpanelsnapshotlocal");
+static LLPanelInjector<LLPanelSnapshotLocal> panel_class("llpanelsnapshotlocal");
 
 LLPanelSnapshotLocal::LLPanelSnapshotLocal()
 {
diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp
index 554fabe5b3d38f0cd9dded22f1b071b327c9e7cb..455c1c9e5fa08264d209c9ab3cea7afdcdab93d0 100755
--- a/indra/newview/llpanelsnapshotoptions.cpp
+++ b/indra/newview/llpanelsnapshotoptions.cpp
@@ -56,7 +56,7 @@ class LLPanelSnapshotOptions
 	void onSaveToComputer();
 };
 
-static LLRegisterPanelClassWrapper<LLPanelSnapshotOptions> panel_class("llpanelsnapshotoptions");
+static LLPanelInjector<LLPanelSnapshotOptions> panel_class("llpanelsnapshotoptions");
 
 LLPanelSnapshotOptions::LLPanelSnapshotOptions()
 {
diff --git a/indra/newview/llpanelsnapshotpostcard.cpp b/indra/newview/llpanelsnapshotpostcard.cpp
index f2bb8f530bacde41a115b58965d7b304cfb21458..aa109e9a512fffb936a3fec90625a20f8437cb63 100755
--- a/indra/newview/llpanelsnapshotpostcard.cpp
+++ b/indra/newview/llpanelsnapshotpostcard.cpp
@@ -79,7 +79,7 @@ class LLPanelSnapshotPostcard
 	std::string mAgentEmail;
 };
 
-static LLRegisterPanelClassWrapper<LLPanelSnapshotPostcard> panel_class("llpanelsnapshotpostcard");
+static LLPanelInjector<LLPanelSnapshotPostcard> panel_class("llpanelsnapshotpostcard");
 
 LLPanelSnapshotPostcard::LLPanelSnapshotPostcard()
 :	mHasFirstMsgFocus(false)
diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp
index a7063183692ba9aebe9fbebec93c6f9b92c8786e..8949eb73ebafe3cb5c29fdc639b0773090f4a3d5 100755
--- a/indra/newview/llpanelsnapshotprofile.cpp
+++ b/indra/newview/llpanelsnapshotprofile.cpp
@@ -64,7 +64,7 @@ class LLPanelSnapshotProfile
 	void onSend();
 };
 
-static LLRegisterPanelClassWrapper<LLPanelSnapshotProfile> panel_class("llpanelsnapshotprofile");
+static LLPanelInjector<LLPanelSnapshotProfile> panel_class("llpanelsnapshotprofile");
 
 LLPanelSnapshotProfile::LLPanelSnapshotProfile()
 {
diff --git a/indra/newview/llpanelvoicedevicesettings.cpp b/indra/newview/llpanelvoicedevicesettings.cpp
index 6be2ea6481cc0fa5e8563173fe23c6307c214f79..6f0a1624a793c5312a8f39ad32c10617883f494a 100755
--- a/indra/newview/llpanelvoicedevicesettings.cpp
+++ b/indra/newview/llpanelvoicedevicesettings.cpp
@@ -40,7 +40,7 @@
 #include "lluictrlfactory.h"
 
 
-static LLRegisterPanelClassWrapper<LLPanelVoiceDeviceSettings> t_panel_group_general("panel_voice_device_settings");
+static LLPanelInjector<LLPanelVoiceDeviceSettings> t_panel_group_general("panel_voice_device_settings");
 static const std::string DEFAULT_DEVICE("Default");
 
 
diff --git a/indra/newview/llpanelvoiceeffect.cpp b/indra/newview/llpanelvoiceeffect.cpp
index 5fec6d967d4d8978083b15e615d19053e43482c9..7da553801a1ea4d05930b6d797dbf62fc6713d07 100755
--- a/indra/newview/llpanelvoiceeffect.cpp
+++ b/indra/newview/llpanelvoiceeffect.cpp
@@ -36,7 +36,7 @@
 #include "lltransientfloatermgr.h"
 #include "llvoiceclient.h"
 
-static LLRegisterPanelClassWrapper<LLPanelVoiceEffect> t_panel_voice_effect("panel_voice_effect");
+static LLPanelInjector<LLPanelVoiceEffect> t_panel_voice_effect("panel_voice_effect");
 
 LLPanelVoiceEffect::LLPanelVoiceEffect()
 	: mVoiceEffectCombo(NULL)
diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp
index aa3ed22bee8b7b089e559e9187c0f0391a5da882..edb624e3aad90df8319fd163b3dff2d6a2538718 100755
--- a/indra/newview/llpanelwearing.cpp
+++ b/indra/newview/llpanelwearing.cpp
@@ -151,7 +151,7 @@ class LLWearingContextMenu : public LLListContextMenu
 
 std::string LLPanelAppearanceTab::sFilterSubString = LLStringUtil::null;
 
-static LLRegisterPanelClassWrapper<LLPanelWearing> t_panel_wearing("panel_wearing");
+static LLPanelInjector<LLPanelWearing> t_panel_wearing("panel_wearing");
 
 LLPanelWearing::LLPanelWearing()
 	:	LLPanelAppearanceTab()
diff --git a/indra/newview/llpopupview.cpp b/indra/newview/llpopupview.cpp
index 08829c11840d5fd5b57cdfb2efb1a78048ab90ea..153f0930c27ab5ee3b9af6545e9f8ce1fb4307ca 100755
--- a/indra/newview/llpopupview.cpp
+++ b/indra/newview/llpopupview.cpp
@@ -27,7 +27,7 @@
 
 #include "llpopupview.h"
 
-static LLRegisterPanelClassWrapper<LLPopupView> r("popup_holder");
+static LLPanelInjector<LLPopupView> r("popup_holder");
 
 bool view_visible_and_enabled(LLView* viewp)
 {
diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp
index 989f0b0e6056a4cc7448a1f73d10dc74cdc732cc..1257ee7f9492870b42f2afca006f28d7c11b02ff 100755
--- a/indra/newview/llprogressview.cpp
+++ b/indra/newview/llprogressview.cpp
@@ -59,7 +59,7 @@ S32 gStartImageWidth = 1;
 S32 gStartImageHeight = 1;
 const F32 FADE_TO_WORLD_TIME = 1.0f;
 
-static LLRegisterPanelClassWrapper<LLProgressView> r("progress_view");
+static LLPanelInjector<LLProgressView> r("progress_view");
 
 // XUI: Translate
 LLProgressView::LLProgressView() 
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index df413ab849aee3ebc3e3f713da1e3b51170ca3e6..ec6a1d9bdc156e77231f29d1a89bed30767a547d 100755
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -49,7 +49,7 @@
 #include "llvoavatarself.h"
 #include "llviewerwearable.h"
 
-static LLRegisterPanelClassWrapper<LLSidepanelAppearance> t_appearance("sidepanel_appearance");
+static LLPanelInjector<LLSidepanelAppearance> t_appearance("sidepanel_appearance");
 
 class LLCurrentlyWornFetchObserver : public LLInventoryFetchItemsObserver
 {
diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp
index fe844ce5e4da1bd99384b4e1226f1da15ae31cf1..1ce691f696b47aba3eeb6bfca8a4411b478425b8 100755
--- a/indra/newview/llsidepanelinventory.cpp
+++ b/indra/newview/llsidepanelinventory.cpp
@@ -59,7 +59,7 @@
 #include "llviewernetwork.h"
 #include "llweb.h"
 
-static LLRegisterPanelClassWrapper<LLSidepanelInventory> t_inventory("sidepanel_inventory");
+static LLPanelInjector<LLSidepanelInventory> t_inventory("sidepanel_inventory");
 
 //
 // Constants
diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp
index 92c2863ffdf49124f54c38ee7b28f74412e7e8ac..e52b2f25597f0a45ff682c5e19bb78d6560aa826 100755
--- a/indra/newview/llsidepaneliteminfo.cpp
+++ b/indra/newview/llsidepaneliteminfo.cpp
@@ -127,7 +127,7 @@ void LLObjectInventoryObserver::inventoryChanged(LLViewerObject* object,
 /// Class LLSidepanelItemInfo
 ///----------------------------------------------------------------------------
 
-static LLRegisterPanelClassWrapper<LLSidepanelItemInfo> t_item_info("sidepanel_item_info");
+static LLPanelInjector<LLSidepanelItemInfo> t_item_info("sidepanel_item_info");
 
 // Default constructor
 LLSidepanelItemInfo::LLSidepanelItemInfo(const LLPanel::Params& p)
diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp
index 9be6d0c5f1a8242920dba7885f1731eebf5e8eaa..44280989297e61addbc1678ec835bf914f09bc9a 100755
--- a/indra/newview/llsidepaneltaskinfo.cpp
+++ b/indra/newview/llsidepaneltaskinfo.cpp
@@ -71,7 +71,7 @@
 
 LLSidepanelTaskInfo* LLSidepanelTaskInfo::sActivePanel = NULL;
 
-static LLRegisterPanelClassWrapper<LLSidepanelTaskInfo> t_task_info("sidepanel_task_info");
+static LLPanelInjector<LLSidepanelTaskInfo> t_task_info("sidepanel_task_info");
 
 // Default constructor
 LLSidepanelTaskInfo::LLSidepanelTaskInfo()
diff --git a/indra/newview/lltool.h b/indra/newview/lltool.h
index ecc435d84413e9373b27f16e9c0ca0c4c6753d65..c5bad9d53272635821f71587dfe9764290faeebb 100755
--- a/indra/newview/lltool.h
+++ b/indra/newview/lltool.h
@@ -39,7 +39,7 @@ class LLView;
 class LLPanel;
 
 class LLTool
-:	public LLMouseHandler
+:	public LLMouseHandler, public LLThreadSafeRefCount
 {
 public:
 	LLTool( const std::string& name, LLToolComposite* composite = NULL );
diff --git a/indra/newview/lltoolcomp.cpp b/indra/newview/lltoolcomp.cpp
index 5270c3d33ff12f83dca2d1d0a9b449225fab4aa1..b75d6b3dcbdb0d85f446b22ae74964bbc3f2078e 100755
--- a/indra/newview/lltoolcomp.cpp
+++ b/indra/newview/lltoolcomp.cpp
@@ -61,7 +61,7 @@ extern LLControlGroup gSavedSettings;
 
 
 // we use this in various places instead of NULL
-static LLTool* sNullTool = new LLTool(std::string("null"), NULL); 
+static LLPointer<LLTool> sNullTool(new LLTool(std::string("null"), NULL)); 
 
 //-----------------------------------------------------------------------
 // LLToolComposite