diff --git a/.hgtags b/.hgtags
index c1b268bf2b31b2a9bf1e149144435820edeea8f7..b333b9384d9285b923658970f6719c8926ad9e23 100755
--- a/.hgtags
+++ b/.hgtags
@@ -555,3 +555,4 @@ ab2ec5c5423b277d23fd0511ce50c15123ff2e03 6.2.3-release
 ece699718f163921717bb95a6131e94af4c4138f 6.3.1-release
 07f5d5bc9faebb45695853d40a9549773db816c0 6.3.2-release
 d9a4bd15e2c852953d6c8e84d6f3b7ca442c0e7f 6.3.3-release
+4033b3f57e76f087235145a3016886ccdc87ffa3 6.3.4-release
diff --git a/indra/llappearance/llwearabletype.cpp b/indra/llappearance/llwearabletype.cpp
index 0e29bbe783e08219000a94ec341fef76122f8d5e..dc02b5e2257b4e6e7bb27333c506fc8eda8a04ec 100644
--- a/indra/llappearance/llwearabletype.cpp
+++ b/indra/llappearance/llwearabletype.cpp
@@ -29,18 +29,6 @@
 #include "llinventorytype.h"
 #include "llinventorydefines.h"
 
-static LLTranslationBridge* sTrans = NULL;
-
-// static
-void LLWearableType::initClass(LLTranslationBridge* trans)
-{
-	sTrans = trans;
-}
-
-void LLWearableType::cleanupClass()
-{
-	delete sTrans;
-}
 
 struct WearableEntry : public LLDictionaryEntry
 {
@@ -53,7 +41,7 @@ struct WearableEntry : public LLDictionaryEntry
 		LLDictionaryEntry(name),
 		mAssetType(assetType),
 		mDefaultNewName(default_new_name),
-		mLabel(sTrans->getString(name)),
+		mLabel(LLWearableType::getInstance()->mTrans->getString(name)),
 		mIconName(iconName),
 		mDisableCameraSwitch(disable_camera_switch),
 		mAllowMultiwear(allow_multiwear)
@@ -76,6 +64,12 @@ class LLWearableDictionary : public LLSingleton<LLWearableDictionary>,
 
 LLWearableDictionary::LLWearableDictionary()
 {
+    if (!LLWearableType::instanceExists())
+    {
+        // LLWearableType is effectively a wrapper around LLWearableDictionary and is used as storage for LLTranslationBridge
+        // Todo: consider merging LLWearableType and LLWearableDictionary
+        LL_WARNS() << "Initing LLWearableDictionary without LLWearableType" << LL_ENDL;
+    }
 	addEntry(LLWearableType::WT_SHAPE,        new WearableEntry("shape",       "New Shape",			LLAssetType::AT_BODYPART, 	LLInventoryType::ICONNAME_BODYPART_SHAPE, FALSE, FALSE));
 	addEntry(LLWearableType::WT_SKIN,         new WearableEntry("skin",        "New Skin",			LLAssetType::AT_BODYPART, 	LLInventoryType::ICONNAME_BODYPART_SKIN, FALSE, FALSE));
 	addEntry(LLWearableType::WT_HAIR,         new WearableEntry("hair",        "New Hair",			LLAssetType::AT_BODYPART, 	LLInventoryType::ICONNAME_BODYPART_HAIR, FALSE, FALSE));
@@ -99,6 +93,20 @@ LLWearableDictionary::LLWearableDictionary()
 	addEntry(LLWearableType::WT_NONE,      	  new WearableEntry("none",        "Invalid Wearable", 	LLAssetType::AT_NONE, 		LLInventoryType::ICONNAME_NONE, FALSE, FALSE));
 }
 
+
+// class LLWearableType
+
+LLWearableType::LLWearableType(LLTranslationBridge* trans)
+{
+    // LLTranslationBridge exists, but is not ready at this point in time since strings.xml is not yet loaded
+    mTrans = trans;
+}
+
+LLWearableType::~LLWearableType()
+{
+    delete mTrans;
+}
+
 // static
 LLWearableType::EType LLWearableType::typeNameToType(const std::string& type_name)
 {
diff --git a/indra/llappearance/llwearabletype.h b/indra/llappearance/llwearabletype.h
index ac81376538ed1d2d94f33babf891ee980f2e34dc..5fe969822a9e64027da017d7a965b9dc3daec777 100644
--- a/indra/llappearance/llwearabletype.h
+++ b/indra/llappearance/llwearabletype.h
@@ -42,8 +42,11 @@ class LLTranslationBridge
 };
 
 
-class LLWearableType
+class LLWearableType : public LLParamSingleton<LLWearableType>
 {
+	LLSINGLETON(LLWearableType, LLTranslationBridge* trans);
+	~LLWearableType();
+	friend struct WearableEntry;
 public: 
 	enum EType
 	{
@@ -70,9 +73,8 @@ class LLWearableType
 		WT_NONE		  = -1,
 	};
 
-	static void			initClass(LLTranslationBridge* trans); // initializes static members
-	static void			cleanupClass(); // initializes static members
-
+	// Most methods are wrappers for dictionary, but if LLWearableType is not initialized,
+	// they will crash. Whole LLWearableType is just wrapper for convinient calls.
 	static const std::string& 			getTypeName(EType type);
 	static const std::string& 			getTypeDefaultNewName(EType type);
 	static const std::string& 			getTypeLabel(EType type);
@@ -81,11 +83,12 @@ class LLWearableType
 	static LLInventoryType::EIconName 	getIconName(EType type);
 	static BOOL 						getDisableCameraSwitch(EType type);
 	static BOOL 						getAllowMultiwear(EType type);
-    static EType						inventoryFlagsToWearableType(U32 flags);
+
+	static EType						inventoryFlagsToWearableType(U32 flags);
 
 protected:
-	LLWearableType() {}
-	~LLWearableType() {}
+
+	LLTranslationBridge* mTrans;
 };
 
 #endif  // LL_LLWEARABLETYPE_H
diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp
index 9fbd78a0003e10067cc16234fdc86363a3cebbc0..c45c14457048ecc65da4fc5593f4a5d54972c211 100644
--- a/indra/llcommon/llsingleton.cpp
+++ b/indra/llcommon/llsingleton.cpp
@@ -134,12 +134,6 @@ LLSingletonBase::list_t& LLSingletonBase::get_initializing()
     return LLSingletonBase::MasterList::instance().get_initializing_();
 }
 
-//static
-LLSingletonBase::list_t& LLSingletonBase::get_initializing_from(MasterList* master)
-{
-    return master->get_initializing_();
-}
-
 LLSingletonBase::~LLSingletonBase() {}
 
 void LLSingletonBase::push_initializing(const char* name)
@@ -156,7 +150,7 @@ void LLSingletonBase::pop_initializing()
     if (list.empty())
     {
         logerrs("Underflow in stack of currently-initializing LLSingletons at ",
-                demangle(typeid(*this).name()).c_str(), "::getInstance()");
+                classname(this).c_str(), "::getInstance()");
     }
 
     // Now we know list.back() exists: capture it
@@ -178,14 +172,39 @@ void LLSingletonBase::pop_initializing()
     if (back != this)
     {
         logerrs("Push/pop mismatch in stack of currently-initializing LLSingletons: ",
-                demangle(typeid(*this).name()).c_str(), "::getInstance() trying to pop ",
-                demangle(typeid(*back).name()).c_str());
+                classname(this).c_str(), "::getInstance() trying to pop ",
+                classname(back).c_str());
     }
 
     // log AFTER popping so logging singletons don't cry circularity
     log_initializing("Popping", typeid(*back).name());
 }
 
+void LLSingletonBase::reset_initializing(list_t::size_type size)
+{
+    // called for cleanup in case the LLSingleton subclass constructor throws
+    // an exception
+
+    // The tricky thing about this, the reason we have a separate method
+    // instead of just calling pop_initializing(), is (hopefully remote)
+    // possibility that the exception happened *before* the
+    // push_initializing() call in LLSingletonBase's constructor. So only
+    // remove the stack top if in fact we've pushed something more than the
+    // previous size.
+    list_t& list(get_initializing());
+
+    while (list.size() > size)
+    {
+        list.pop_back();
+    }
+
+    // as in pop_initializing()
+    if (list.empty())
+    {
+        MasterList::instance().cleanup_initializing_();
+    }
+}
+
 //static
 void LLSingletonBase::log_initializing(const char* verb, const char* name)
 {
@@ -197,7 +216,7 @@ void LLSingletonBase::log_initializing(const char* verb, const char* name)
              ri != rend; ++ri)
         {
             LLSingletonBase* sb(*ri);
-            LL_CONT << ' ' << demangle(typeid(*sb).name());
+            LL_CONT << ' ' << classname(sb);
         }
         LL_ENDL;
     }
@@ -231,7 +250,7 @@ void LLSingletonBase::capture_dependency(list_t& initializing, EInitState initSt
                 // 'found' is an iterator; *found is an LLSingletonBase*; **found
                 // is the actual LLSingletonBase instance.
                 LLSingletonBase* foundp(*found);
-                out << demangle(typeid(*foundp).name()) << " -> ";
+                out << classname(foundp) << " -> ";
             }
             // We promise to capture dependencies from both the constructor
             // and the initSingleton() method, so an LLSingleton's instance
@@ -245,7 +264,7 @@ void LLSingletonBase::capture_dependency(list_t& initializing, EInitState initSt
             if (initState == CONSTRUCTING)
             {
                 logerrs("LLSingleton circularity in Constructor: ", out.str().c_str(),
-                    demangle(typeid(*this).name()).c_str(), "");
+                    classname(this).c_str(), "");
             }
             else if (it_next == initializing.end())
             {
@@ -256,14 +275,14 @@ void LLSingletonBase::capture_dependency(list_t& initializing, EInitState initSt
                 // Example: LLNotifications singleton initializes default channels.
                 // Channels register themselves with singleton once done.
                 logdebugs("LLSingleton circularity: ", out.str().c_str(),
-                    demangle(typeid(*this).name()).c_str(), "");
+                    classname(this).c_str(), "");
             }
             else
             {
                 // Actual circularity with other singleton (or single singleton is used extensively).
                 // Dependency can be unclear.
                 logwarns("LLSingleton circularity: ", out.str().c_str(),
-                    demangle(typeid(*this).name()).c_str(), "");
+                    classname(this).c_str(), "");
             }
         }
         else
@@ -276,8 +295,8 @@ void LLSingletonBase::capture_dependency(list_t& initializing, EInitState initSt
             if (current->mDepends.insert(this).second)
             {
                 // only log the FIRST time we hit this dependency!
-                logdebugs(demangle(typeid(*current).name()).c_str(),
-                          " depends on ", demangle(typeid(*this).name()).c_str());
+                logdebugs(classname(current).c_str(),
+                          " depends on ", classname(this).c_str());
             }
         }
     }
@@ -336,19 +355,19 @@ void LLSingletonBase::cleanupAll()
             sp->mCleaned = true;
 
             logdebugs("calling ",
-                      demangle(typeid(*sp).name()).c_str(), "::cleanupSingleton()");
+                      classname(sp).c_str(), "::cleanupSingleton()");
             try
             {
                 sp->cleanupSingleton();
             }
             catch (const std::exception& e)
             {
-                logwarns("Exception in ", demangle(typeid(*sp).name()).c_str(),
+                logwarns("Exception in ", classname(sp).c_str(),
                          "::cleanupSingleton(): ", e.what());
             }
             catch (...)
             {
-                logwarns("Unknown exception in ", demangle(typeid(*sp).name()).c_str(),
+                logwarns("Unknown exception in ", classname(sp).c_str(),
                          "::cleanupSingleton()");
             }
         }
@@ -363,7 +382,7 @@ void LLSingletonBase::deleteAll()
     {
         // Capture the class name first: in case of exception, don't count on
         // being able to extract it later.
-        const std::string name = demangle(typeid(*sp).name());
+        const std::string name = classname(sp);
         try
         {
             // Call static method through instance function pointer.
@@ -440,7 +459,17 @@ void LLSingletonBase::logerrs(const char* p1, const char* p2, const char* p3, co
     log(LLError::LEVEL_ERROR, p1, p2, p3, p4);
     // The other important side effect of LL_ERRS() is
     // https://www.youtube.com/watch?v=OMG7paGJqhQ (emphasis on OMG)
-    LLError::crashAndLoop(std::string());
+    std::ostringstream out;
+    out << p1 << p2 << p3 << p4;
+    auto crash = LLError::getFatalFunction();
+    if (crash)
+    {
+        crash(out.str());
+    }
+    else
+    {
+        LLError::crashAndLoop(out.str());
+    }
 }
 
 std::string LLSingletonBase::demangle(const char* mangled)
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 859e271e26c661a88a726456bcaf128d61f83672..0da6d548ab007aaf1719acba4a4093919d7f9b3b 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -31,6 +31,18 @@
 #include <vector>
 #include <typeinfo>
 
+#if LL_WINDOWS
+#pragma warning (push)
+#pragma warning (disable:4265)
+#endif
+// warning C4265: 'std::_Pad' : class has virtual functions, but destructor is not virtual
+
+#include <mutex>
+
+#if LL_WINDOWS
+#pragma warning (pop)
+#endif
+
 class LLSingletonBase: private boost::noncopyable
 {
 public:
@@ -43,7 +55,6 @@ class LLSingletonBase: private boost::noncopyable
     // This, on the other hand, is a stack whose top indicates the LLSingleton
     // currently being initialized.
     static list_t& get_initializing();
-    static list_t& get_initializing_from(MasterList*);
     // Produce a vector<LLSingletonBase*> of master list, in dependency order.
     typedef std::vector<LLSingletonBase*> vec_t;
     static vec_t dep_sort();
@@ -57,10 +68,11 @@ class LLSingletonBase: private boost::noncopyable
     typedef enum e_init_state
     {
         UNINITIALIZED = 0,          // must be default-initialized state
-        CONSTRUCTING,
-        INITIALIZING,
-        INITIALIZED,
-        DELETED
+        CONSTRUCTING,               // within DERIVED_TYPE constructor
+        CONSTRUCTED,                // finished DERIVED_TYPE constructor
+        INITIALIZING,               // within DERIVED_TYPE::initSingleton()
+        INITIALIZED,                // normal case
+        DELETED                     // deleteSingleton() or deleteAll() called
     } EInitState;
 
     // Define tag<T> to pass to our template constructor. You can't explicitly
@@ -100,6 +112,9 @@ class LLSingletonBase: private boost::noncopyable
     // That being the case, we control exactly when it happens -- and we can
     // pop the stack immediately thereafter.
     void pop_initializing();
+    // Remove 'this' from the init stack in case of exception in the
+    // LLSingleton subclass constructor.
+    static void reset_initializing(list_t::size_type size);
 private:
     // logging
     static void log_initializing(const char* verb, const char* name);
@@ -115,6 +130,10 @@ class LLSingletonBase: private boost::noncopyable
     static void logwarns(const char* p1, const char* p2="",
                          const char* p3="", const char* p4="");
     static std::string demangle(const char* mangled);
+    template <typename T>
+    static std::string classname()       { return demangle(typeid(T).name()); }
+    template <typename T>
+    static std::string classname(T* ptr) { return demangle(typeid(*ptr).name()); }
 
     // Default methods in case subclass doesn't declare them.
     virtual void initSingleton() {}
@@ -178,7 +197,15 @@ struct LLSingleton_manage_master
     void remove(LLSingletonBase* sb) { sb->remove_master(); }
     void push_initializing(LLSingletonBase* sb) { sb->push_initializing(typeid(T).name()); }
     void pop_initializing (LLSingletonBase* sb) { sb->pop_initializing(); }
-    LLSingletonBase::list_t& get_initializing(T*) { return LLSingletonBase::get_initializing(); }
+    // used for init stack cleanup in case an LLSingleton subclass constructor
+    // throws an exception
+    void reset_initializing(LLSingletonBase::list_t::size_type size)
+    {
+        LLSingletonBase::reset_initializing(size);
+    }
+    // For any LLSingleton subclass except the MasterList, obtain the init
+    // stack from the MasterList singleton instance.
+    LLSingletonBase::list_t& get_initializing() { return LLSingletonBase::get_initializing(); }
 };
 
 // But for the specific case of LLSingletonBase::MasterList, don't.
@@ -189,9 +216,14 @@ struct LLSingleton_manage_master<LLSingletonBase::MasterList>
     void remove(LLSingletonBase*) {}
     void push_initializing(LLSingletonBase*) {}
     void pop_initializing (LLSingletonBase*) {}
-    LLSingletonBase::list_t& get_initializing(LLSingletonBase::MasterList* instance)
+    // since we never pushed, no need to clean up
+    void reset_initializing(LLSingletonBase::list_t::size_type size) {}
+    LLSingletonBase::list_t& get_initializing()
     {
-        return LLSingletonBase::get_initializing_from(instance);
+        // The MasterList shouldn't depend on any other LLSingletons. We'd
+        // get into trouble if we tried to recursively engage that machinery.
+        static LLSingletonBase::list_t sDummyList;
+        return sDummyList;
     }
 };
 
@@ -201,10 +233,19 @@ LLSingletonBase::LLSingletonBase(tag<DERIVED_TYPE>):
     mCleaned(false),
     mDeleteSingleton(NULL)
 {
-    // Make this the currently-initializing LLSingleton.
+    // This is the earliest possible point at which we can push this new
+    // instance onto the init stack. LLSingleton::constructSingleton() can't
+    // do it before calling the constructor, because it doesn't have an
+    // instance pointer until the constructor returns. Fortunately this
+    // constructor is guaranteed to be called before any subclass constructor.
+    // Make this new instance the currently-initializing LLSingleton.
     LLSingleton_manage_master<DERIVED_TYPE>().push_initializing(this);
 }
 
+// forward declare for friend directive within LLSingleton
+template <typename DERIVED_TYPE>
+class LLParamSingleton;
+
 /**
  * LLSingleton implements the getInstance() method part of the Singleton
  * pattern. It can't make the derived class constructors protected, though, so
@@ -270,9 +311,94 @@ template <typename DERIVED_TYPE>
 class LLSingleton : public LLSingletonBase
 {
 private:
-    static DERIVED_TYPE* constructSingleton()
+    // Allow LLParamSingleton subclass -- but NOT DERIVED_TYPE itself -- to
+    // access our private members.
+    friend class LLParamSingleton<DERIVED_TYPE>;
+
+    // LLSingleton only supports a nullary constructor. However, the specific
+    // purpose for its subclass LLParamSingleton is to support Singletons
+    // requiring constructor arguments. constructSingleton() supports both use
+    // cases.
+    template <typename... Args>
+    static void constructSingleton(Args&&... args)
+    {
+        auto prev_size = LLSingleton_manage_master<DERIVED_TYPE>().get_initializing().size();
+        // getInstance() calls are from within constructor
+        sData.mInitState = CONSTRUCTING;
+        try
+        {
+            sData.mInstance = new DERIVED_TYPE(std::forward<Args>(args)...);
+            // we have called constructor, have not yet called initSingleton()
+            sData.mInitState = CONSTRUCTED;
+        }
+        catch (const std::exception& err)
+        {
+            // LLSingletonBase might -- or might not -- have pushed the new
+            // instance onto the init stack before the exception. Reset the
+            // init stack to its previous size BEFORE logging so log-machinery
+            // LLSingletons don't record a dependency on DERIVED_TYPE!
+            LLSingleton_manage_master<DERIVED_TYPE>().reset_initializing(prev_size);
+            logwarns("Error constructing ", classname<DERIVED_TYPE>().c_str(),
+                     ": ", err.what());
+            // There isn't a separate EInitState value meaning "we attempted
+            // to construct this LLSingleton subclass but could not," so use
+            // DELETED. That seems slightly more appropriate than UNINITIALIZED.
+            sData.mInitState = DELETED;
+            // propagate the exception
+            throw;
+        }
+    }
+
+    static void finishInitializing()
+    {
+        // getInstance() calls are from within initSingleton()
+        sData.mInitState = INITIALIZING;
+        try
+        {
+            // initialize singleton after constructing it so that it can
+            // reference other singletons which in turn depend on it, thus
+            // breaking cyclic dependencies
+            sData.mInstance->initSingleton();
+            sData.mInitState = INITIALIZED;
+
+            // pop this off stack of initializing singletons
+            pop_initializing();
+        }
+        catch (const std::exception& err)
+        {
+            // pop this off stack of initializing singletons here, too --
+            // BEFORE logging, so log-machinery LLSingletons don't record a
+            // dependency on DERIVED_TYPE!
+            pop_initializing();
+            logwarns("Error in ", classname<DERIVED_TYPE>().c_str(),
+                     "::initSingleton(): ", err.what());
+            // and get rid of the instance entirely
+            deleteSingleton();
+            // propagate the exception
+            throw;
+        }
+    }
+
+    static void pop_initializing()
     {
-        return new DERIVED_TYPE();
+        // route through LLSingleton_manage_master so we Do The Right Thing
+        // (namely, nothing) for MasterList
+        LLSingleton_manage_master<DERIVED_TYPE>().pop_initializing(sData.mInstance);
+    }
+
+    // Without this 'using' declaration, the static method we're declaring
+    // here would hide the base-class method we want it to call.
+    using LLSingletonBase::capture_dependency;
+    static void capture_dependency()
+    {
+        // By this point, if DERIVED_TYPE was pushed onto the initializing
+        // stack, it has been popped off. So the top of that stack, if any, is
+        // an LLSingleton that directly depends on DERIVED_TYPE. If
+        // getInstance() was called by another LLSingleton, rather than from
+        // vanilla application code, record the dependency.
+        sData.mInstance->capture_dependency(
+            LLSingleton_manage_master<DERIVED_TYPE>().get_initializing(),
+            sData.mInitState);
     }
 
     // We know of no way to instruct the compiler that every subclass
@@ -285,34 +411,17 @@ class LLSingleton : public LLSingletonBase
     // subclass body.
     virtual void you_must_use_LLSINGLETON_macro() = 0;
 
-    // stores pointer to singleton instance
-    struct SingletonLifetimeManager
+    // The purpose of this struct is to engage the C++11 guarantee that static
+    // variables declared in function scope are initialized exactly once, even
+    // if multiple threads concurrently reach the same declaration.
+    // https://en.cppreference.com/w/cpp/language/storage_duration#Static_local_variables
+    // Since getInstance() declares a static instance of SingletonInitializer,
+    // only the first call to getInstance() calls constructSingleton().
+    struct SingletonInitializer
     {
-        SingletonLifetimeManager()
-        {
-            construct();
-        }
-
-        static void construct()
-        {
-            sData.mInitState = CONSTRUCTING;
-            sData.mInstance = constructSingleton();
-            sData.mInitState = INITIALIZING;
-        }
-
-        ~SingletonLifetimeManager()
+        SingletonInitializer()
         {
-            // The dependencies between LLSingletons, and the arbitrary order
-            // of static-object destruction, mean that we DO NOT WANT this
-            // destructor to delete this LLSingleton. This destructor will run
-            // without regard to any other LLSingleton whose cleanup might
-            // depend on its existence. If you want to clean up LLSingletons,
-            // call LLSingletonBase::deleteAll() sometime before static-object
-            // destruction begins. That method will properly honor cross-
-            // LLSingleton dependencies. Otherwise we simply leak LLSingleton
-            // instances at shutdown. Since the whole process is terminating
-            // anyway, that's not necessarily a bad thing; it depends on what
-            // resources your LLSingleton instances are managing.
+            constructSingleton();
         }
     };
 
@@ -363,64 +472,59 @@ class LLSingleton : public LLSingletonBase
     static void deleteSingleton()
     {
         delete sData.mInstance;
-        sData.mInstance = NULL;
-        sData.mInitState = DELETED;
+        // SingletonData state handled by destructor, above
     }
 
     static DERIVED_TYPE* getInstance()
     {
-        static SingletonLifetimeManager sLifeTimeMgr;
+        // call constructSingleton() only the first time we get here
+        static SingletonInitializer sInitializer;
 
         switch (sData.mInitState)
         {
         case UNINITIALIZED:
             // should never be uninitialized at this point
             logerrs("Uninitialized singleton ",
-                    demangle(typeid(DERIVED_TYPE).name()).c_str());
+                    classname<DERIVED_TYPE>().c_str());
             return NULL;
 
         case CONSTRUCTING:
+            // here if DERIVED_TYPE's constructor (directly or indirectly)
+            // calls DERIVED_TYPE::getInstance()
             logerrs("Tried to access singleton ",
-                    demangle(typeid(DERIVED_TYPE).name()).c_str(),
+                    classname<DERIVED_TYPE>().c_str(),
                     " from singleton constructor!");
             return NULL;
 
-        case INITIALIZING:
-            // go ahead and flag ourselves as initialized so we can be
-            // reentrant during initialization
-            sData.mInitState = INITIALIZED; 
-            // initialize singleton after constructing it so that it can
-            // reference other singletons which in turn depend on it, thus
-            // breaking cyclic dependencies
-            sData.mInstance->initSingleton();
-            // pop this off stack of initializing singletons
-            LLSingleton_manage_master<DERIVED_TYPE>().pop_initializing(sData.mInstance);
+        case CONSTRUCTED:
+            // first time through: set to CONSTRUCTED by
+            // constructSingleton(), called by sInitializer's constructor;
+            // still have to call initSingleton()
+            finishInitializing();
             break;
 
+        case INITIALIZING:
+            // here if DERIVED_TYPE::initSingleton() (directly or indirectly)
+            // calls DERIVED_TYPE::getInstance(): go ahead and allow it
         case INITIALIZED:
+            // normal subsequent calls
             break;
 
         case DELETED:
+            // called after deleteSingleton()
             logwarns("Trying to access deleted singleton ",
-                     demangle(typeid(DERIVED_TYPE).name()).c_str(),
+                     classname<DERIVED_TYPE>().c_str(),
                      " -- creating new instance");
-            SingletonLifetimeManager::construct();
-            // same as first time construction
-            sData.mInitState = INITIALIZED; 
-            sData.mInstance->initSingleton(); 
-            // pop this off stack of initializing singletons
-            LLSingleton_manage_master<DERIVED_TYPE>().pop_initializing(sData.mInstance);
+            // This recovery sequence is NOT thread-safe! We would need a
+            // recursive_mutex a la LLParamSingleton.
+            constructSingleton();
+            finishInitializing();
             break;
         }
 
-        // By this point, if DERIVED_TYPE was pushed onto the initializing
-        // stack, it has been popped off. So the top of that stack, if any, is
-        // an LLSingleton that directly depends on DERIVED_TYPE. If this call
-        // came from another LLSingleton, rather than from vanilla application
-        // code, record the dependency.
-        sData.mInstance->capture_dependency(
-            LLSingleton_manage_master<DERIVED_TYPE>().get_initializing(sData.mInstance),
-            sData.mInitState);
+        // record the dependency, if any: check if we got here from another
+        // LLSingleton's constructor or initSingleton() method
+        capture_dependency();
         return sData.mInstance;
     }
 
@@ -460,6 +564,173 @@ class LLSingleton : public LLSingletonBase
 template<typename T>
 typename LLSingleton<T>::SingletonData LLSingleton<T>::sData;
 
+
+/**
+ * LLParamSingleton<T> is like LLSingleton<T>, except in the following ways:
+ *
+ * * It is NOT instantiated on demand (instance() or getInstance()). You must
+ *   first call initParamSingleton(constructor args...).
+ * * Before initParamSingleton(), calling instance() or getInstance() dies with
+ *   LL_ERRS.
+ * * initParamSingleton() may be called only once. A second call dies with
+ *   LL_ERRS.
+ * * However, distinct initParamSingleton() calls can be used to engage
+ *   different constructors, as long as only one such call is executed at
+ *   runtime.
+ * * Unlike LLSingleton, an LLParamSingleton cannot be "revived" by an
+ *   instance() or getInstance() call after deleteSingleton().
+ *
+ * Importantly, though, each LLParamSingleton subclass does participate in the
+ * dependency-ordered LLSingletonBase::deleteAll() processing.
+ */
+template <typename DERIVED_TYPE>
+class LLParamSingleton : public LLSingleton<DERIVED_TYPE>
+{
+private:
+    typedef LLSingleton<DERIVED_TYPE> super;
+    // Use a recursive_mutex in case of constructor circularity. With a
+    // non-recursive mutex, that would result in deadlock rather than the
+    // logerrs() call in getInstance().
+    typedef std::recursive_mutex mutex_t;
+
+public:
+    using super::deleteSingleton;
+    using super::instanceExists;
+    using super::wasDeleted;
+
+    // Passes arguments to DERIVED_TYPE's constructor and sets appropriate states
+    template <typename... Args>
+    static void initParamSingleton(Args&&... args)
+    {
+        // In case racing threads both call initParamSingleton() at the same
+        // time, serialize them. One should initialize; the other should see
+        // mInitState already set.
+        std::unique_lock<mutex_t> lk(getMutex());
+        // For organizational purposes this function shouldn't be called twice
+        if (super::sData.mInitState != super::UNINITIALIZED)
+        {
+            super::logerrs("Tried to initialize singleton ",
+                           super::template classname<DERIVED_TYPE>().c_str(),
+                           " twice!");
+        }
+        else
+        {
+            super::constructSingleton(std::forward<Args>(args)...);
+            super::finishInitializing();
+        }
+    }
+
+    static DERIVED_TYPE* getInstance()
+    {
+        // In case racing threads call getInstance() at the same moment as
+        // initParamSingleton(), serialize the calls.
+        std::unique_lock<mutex_t> lk(getMutex());
+
+        switch (super::sData.mInitState)
+        {
+        case super::UNINITIALIZED:
+            super::logerrs("Uninitialized param singleton ",
+                           super::template classname<DERIVED_TYPE>().c_str());
+            break;
+
+        case super::CONSTRUCTING:
+            super::logerrs("Tried to access param singleton ",
+                           super::template classname<DERIVED_TYPE>().c_str(),
+                           " from singleton constructor!");
+            break;
+
+        case super::CONSTRUCTED:
+            // Should never happen!? The CONSTRUCTED state is specifically to
+            // navigate through LLSingleton::SingletonInitializer getting
+            // constructed (once) before LLSingleton::getInstance()'s switch
+            // on mInitState. But our initParamSingleton() method calls
+            // constructSingleton() and then calls finishInitializing(), which
+            // immediately sets INITIALIZING. Why are we here?
+            super::logerrs("Param singleton ",
+                           super::template classname<DERIVED_TYPE>().c_str(),
+                           "::initSingleton() not yet called");
+            break;
+
+        case super::INITIALIZING:
+            // As with LLSingleton, explicitly permit circular calls from
+            // within initSingleton()
+        case super::INITIALIZED:
+            // for any valid call, capture dependencies
+            super::capture_dependency();
+            return super::sData.mInstance;
+
+        case super::DELETED:
+            super::logerrs("Trying to access deleted param singleton ",
+                           super::template classname<DERIVED_TYPE>().c_str());
+            break;
+        }
+
+        // should never actually get here; this is to pacify the compiler,
+        // which assumes control might return from logerrs()
+        return nullptr;
+    }
+
+    // instance() is replicated here so it calls
+    // LLParamSingleton::getInstance() rather than LLSingleton::getInstance()
+    // -- avoid making getInstance() virtual
+    static DERIVED_TYPE& instance()
+    {
+        return *getInstance();
+    }
+
+private:
+    // sMutex must be a function-local static rather than a static member. One
+    // of the essential features of LLSingleton and friends is that they must
+    // support getInstance() even when the containing module's static
+    // variables have not yet been runtime-initialized. A mutex requires
+    // construction. A static class member might not yet have been
+    // constructed.
+    //
+    // We could store a dumb mutex_t*, notice when it's NULL and allocate a
+    // heap mutex -- but that's vulnerable to race conditions. And we can't
+    // defend the dumb pointer with another mutex.
+    //
+    // We could store a std::atomic<mutex_t*> -- but a default-constructed
+    // std::atomic<T> does not contain a valid T, even a default-constructed
+    // T! Which means std::atomic, too, requires runtime initialization.
+    //
+    // But a function-local static is guaranteed to be initialized exactly
+    // once, the first time control reaches that declaration.
+    static mutex_t& getMutex()
+    {
+        static mutex_t sMutex;
+        return sMutex;
+    }
+};
+
+/**
+ * Initialization locked singleton, only derived class can decide when to initialize.
+ * Starts locked.
+ * For cases when singleton has a dependency onto something or.
+ *
+ * LLLockedSingleton is like an LLParamSingleton with a nullary constructor.
+ * It cannot be instantiated on demand (instance() or getInstance() call) --
+ * it must be instantiated by calling construct(). However, it does
+ * participate in dependency-ordered LLSingletonBase::deleteAll() processing.
+ */
+template <typename DT>
+class LLLockedSingleton : public LLParamSingleton<DT>
+{
+    typedef LLParamSingleton<DT> super;
+
+public:
+    using super::deleteSingleton;
+    using super::getInstance;
+    using super::instance;
+    using super::instanceExists;
+    using super::wasDeleted;
+
+    static void construct()
+    {
+        super::initParamSingleton();
+    }
+};
+
 /**
  * Use LLSINGLETON(Foo); at the start of an LLSingleton<Foo> subclass body
  * when you want to declare an out-of-line constructor:
@@ -484,13 +755,13 @@ typename LLSingleton<T>::SingletonData LLSingleton<T>::sData;
  * file, use 'inline' (unless it's a template class) to avoid duplicate-symbol
  * errors at link time.
  */
-#define LLSINGLETON(DERIVED_CLASS)                                      \
+#define LLSINGLETON(DERIVED_CLASS, ...)                                 \
 private:                                                                \
     /* implement LLSingleton pure virtual method whose sole purpose */  \
     /* is to remind people to use this macro */                         \
     virtual void you_must_use_LLSINGLETON_macro() {}                    \
     friend class LLSingleton<DERIVED_CLASS>;                            \
-    DERIVED_CLASS()
+    DERIVED_CLASS(__VA_ARGS__)
 
 /**
  * Use LLSINGLETON_EMPTY_CTOR(Foo); at the start of an LLSingleton<Foo>
diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp
index a459d17fb8b58b2692bf731910eb204116ab8495..fa02d2bb1a0013e23baf4978c5842ec8e3eac73f 100644
--- a/indra/llcommon/tests/lleventcoro_test.cpp
+++ b/indra/llcommon/tests/lleventcoro_test.cpp
@@ -506,16 +506,10 @@ namespace tut
             replyName = waiter.getName0();
             errorName = waiter.getName1();
             WrapLLErrs capture;
-            try
-            {
-                result = waiter.suspendWithLog();
-                debug("no exception");
-            }
-            catch (const WrapLLErrs::FatalException& e)
-            {
-                debug(STRINGIZE("exception " << e.what()));
-                threw = e.what();
-            }
+            threw = capture.catch_llerrs([&waiter, &debug](){
+                    result = waiter.suspendWithLog();
+                    debug("no exception");
+                });
         }
         END
     }
@@ -762,18 +756,13 @@ namespace tut
         {
             LLCoroEventPumps waiter;
             WrapLLErrs capture;
-            try
-            {
-                result = waiter.postAndSuspendWithLog(
-                    LLSDMap("value", 31)("fail", LLSD()),
-                    immediateAPI.getPump(), "reply", "error");
-                debug("no exception");
-            }
-            catch (const WrapLLErrs::FatalException& e)
-            {
-                debug(STRINGIZE("exception " << e.what()));
-                threw = e.what();
-            }
+            threw = capture.catch_llerrs(
+                [&waiter, &debug](){
+                    result = waiter.postAndSuspendWithLog(
+                        LLSDMap("value", 31)("fail", LLSD()),
+                        immediateAPI.getPump(), "reply", "error");
+                    debug("no exception");
+                });
         }
         END
     }
diff --git a/indra/llcommon/tests/lleventdispatcher_test.cpp b/indra/llcommon/tests/lleventdispatcher_test.cpp
index 5a4df81bf1ecbc9e74a1bc9f54723cff38c04dfd..a181d5c941e09a5855eafe0d2bb8f76096bc7734 100644
--- a/indra/llcommon/tests/lleventdispatcher_test.cpp
+++ b/indra/llcommon/tests/lleventdispatcher_test.cpp
@@ -22,6 +22,7 @@
 #include "llsdutil.h"
 #include "stringize.h"
 #include "tests/wrapllerrs.h"
+#include "../test/catch_and_store_what_in.h"
 
 #include <map>
 #include <string>
@@ -630,16 +631,9 @@ namespace tut
 
         void call_exc(const std::string& func, const LLSD& args, const std::string& exc_frag)
         {
-            std::string threw;
-            try
-            {
-                work(func, args);
-            }
-            catch (const std::runtime_error& e)
-            {
-                cout << "*** " << e.what() << '\n';
-                threw = e.what();
-            }
+            std::string threw = catch_what<std::runtime_error>([this, &func, &args](){
+                    work(func, args);
+                });
             ensure_has(threw, exc_frag);
         }
 
@@ -717,15 +711,9 @@ namespace tut
         LLSD attempts(LLSDArray(17)(LLSDMap("pi", 3.14)("two", 2)));
         foreach(LLSD ae, inArray(attempts))
         {
-            std::string threw;
-            try
-            {
-                work.add("freena_err", "freena", freena, ae);
-            }
-            catch (const std::exception& e)
-            {
-                threw = e.what();
-            }
+            std::string threw = catch_what<std::exception>([this, &ae](){
+                    work.add("freena_err", "freena", freena, ae);
+                });
             ensure_has(threw, "must be an array");
         }
     }
@@ -734,15 +722,9 @@ namespace tut
     void object::test<2>()
     {
         set_test_name("map-style registration with badly-formed defaults");
-        std::string threw;
-        try
-        {
-            work.add("freena_err", "freena", freena, LLSDArray("a")("b"), 17);
-        }
-        catch (const std::exception& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = catch_what<std::exception>([this](){
+                work.add("freena_err", "freena", freena, LLSDArray("a")("b"), 17);
+            });
         ensure_has(threw, "must be a map or an array");
     }
 
@@ -750,17 +732,11 @@ namespace tut
     void object::test<3>()
     {
         set_test_name("map-style registration with too many array defaults");
-        std::string threw;
-        try
-        {
-            work.add("freena_err", "freena", freena,
-                     LLSDArray("a")("b"),
-                     LLSDArray(17)(0.9)("gack"));
-        }
-        catch (const std::exception& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = catch_what<std::exception>([this](){
+                work.add("freena_err", "freena", freena,
+                         LLSDArray("a")("b"),
+                         LLSDArray(17)(0.9)("gack"));
+            });
         ensure_has(threw, "shorter than");
     }
 
@@ -768,17 +744,11 @@ namespace tut
     void object::test<4>()
     {
         set_test_name("map-style registration with too many map defaults");
-        std::string threw;
-        try
-        {
-            work.add("freena_err", "freena", freena,
-                     LLSDArray("a")("b"),
-                     LLSDMap("b", 17)("foo", 3.14)("bar", "sinister"));
-        }
-        catch (const std::exception& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = catch_what<std::exception>([this](){
+                work.add("freena_err", "freena", freena,
+                         LLSDArray("a")("b"),
+                         LLSDMap("b", 17)("foo", 3.14)("bar", "sinister"));
+            });
         ensure_has(threw, "nonexistent params");
         ensure_has(threw, "foo");
         ensure_has(threw, "bar");
@@ -1039,16 +1009,9 @@ namespace tut
         // We don't have a comparable helper function for the one-arg
         // operator() method, and it's not worth building one just for this
         // case. Write it out.
-        std::string threw;
-        try
-        {
-            work(LLSDMap("op", "freek"));
-        }
-        catch (const std::runtime_error& e)
-        {
-            cout << "*** " << e.what() << "\n";
-            threw = e.what();
-        }
+        std::string threw = catch_what<std::runtime_error>([this](){
+                work(LLSDMap("op", "freek"));
+            });
         ensure_has(threw, "bad");
         ensure_has(threw, "op");
         ensure_has(threw, "freek");
diff --git a/indra/llcommon/tests/lleventfilter_test.cpp b/indra/llcommon/tests/lleventfilter_test.cpp
index eb98b12ef5260395b35e1c4fc429ce00cea847ec..1875013794fe1abd6c5703d6b322341211856c65 100644
--- a/indra/llcommon/tests/lleventfilter_test.cpp
+++ b/indra/llcommon/tests/lleventfilter_test.cpp
@@ -350,15 +350,9 @@ namespace tut
         // Now let the timer expire.
         filter.forceTimeout();
         // Notice the timeout.
-        std::string threw;
-        try
-        {
-            mainloop.post(17);
-        }
-        catch (const WrapLLErrs::FatalException& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = capture.catch_llerrs([this](){
+                mainloop.post(17);
+            });
         ensure_contains("errorAfter() timeout exception", threw, "timeout");
         // Timing out cancels the timer. Verify that.
         listener0.reset(0);
diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp
index c7d4b8a06bdd879d364cf14395f70f38db20df24..d94fc0c56d0b2052bee78d39a47910f48acd0557 100644
--- a/indra/llcommon/tests/llinstancetracker_test.cpp
+++ b/indra/llcommon/tests/llinstancetracker_test.cpp
@@ -198,14 +198,9 @@ namespace tut
         {
             WrapLLErrs wrapper;
             Keyed::instance_iter i(Keyed::beginInstances());
-            try
-            {
-                delete keyed;
-            }
-            catch (const WrapLLErrs::FatalException& e)
-            {
-                what = e.what();
-            }
+            what = wrapper.catch_llerrs([&keyed](){
+                    delete keyed;
+                });
         }
         ensure(! what.empty());
     }
@@ -219,14 +214,9 @@ namespace tut
         {
             WrapLLErrs wrapper;
             Keyed::key_iter i(Keyed::beginKeys());
-            try
-            {
-                delete keyed;
-            }
-            catch (const WrapLLErrs::FatalException& e)
-            {
-                what = e.what();
-            }
+            what = wrapper.catch_llerrs([&keyed](){
+                    delete keyed;
+                });
         }
         ensure(! what.empty());
     }
@@ -240,14 +230,9 @@ namespace tut
         {
             WrapLLErrs wrapper;
             Unkeyed::instance_iter i(Unkeyed::beginInstances());
-            try
-            {
-                delete unkeyed;
-            }
-            catch (const WrapLLErrs::FatalException& e)
-            {
-                what = e.what();
-            }
+            what = wrapper.catch_llerrs([&unkeyed](){
+                    delete unkeyed;
+                });
         }
         ensure(! what.empty());
     }
diff --git a/indra/llcommon/tests/lllazy_test.cpp b/indra/llcommon/tests/lllazy_test.cpp
index 32a717f4fccffea7227d1801504dc331221f84dd..542306ee22a36805a70232c55fd4328aba79ac24 100644
--- a/indra/llcommon/tests/lllazy_test.cpp
+++ b/indra/llcommon/tests/lllazy_test.cpp
@@ -38,6 +38,7 @@
 #include <boost/lambda/bind.hpp>
 // other Linden headers
 #include "../test/lltut.h"
+#include "../test/catch_and_store_what_in.h"
 
 namespace bll = boost::lambda;
 
@@ -200,15 +201,9 @@ namespace tut
     void lllazy_object::test<2>()
     {
         TestNeedsTesting tnt;
-        std::string threw;
-        try
-        {
-            tnt.toolate();
-        }
-        catch (const LLLazyCommon::InstanceChange& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = catch_what<LLLazyCommon::InstanceChange>([&tnt](){
+                tnt.toolate();
+            });
         ensure_contains("InstanceChange exception", threw, "replace LLLazy instance");
     }
 
diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp
index 45648536c4db95fac6b382abc77d5e60a8fadf8e..bf0a74d10da2d9d1453f94fbb9b39788bf2b0258 100644
--- a/indra/llcommon/tests/llleap_test.cpp
+++ b/indra/llcommon/tests/llleap_test.cpp
@@ -23,7 +23,7 @@
 #include "../test/lltut.h"
 #include "../test/namedtempfile.h"
 #include "../test/catch_and_store_what_in.h"
-#include "wrapllerrs.h"
+#include "wrapllerrs.h"             // CaptureLog
 #include "llevents.h"
 #include "llprocess.h"
 #include "llstring.h"
@@ -290,12 +290,9 @@ namespace tut
     void object::test<6>()
     {
         set_test_name("empty plugin vector");
-        std::string threw;
-        try
-        {
-            LLLeap::create("empty", StringVec());
-        }
-        CATCH_AND_STORE_WHAT_IN(threw, LLLeap::Error)
+        std::string threw = catch_what<LLLeap::Error>([](){
+                LLLeap::create("empty", StringVec());
+            });
         ensure_contains("LLLeap::Error", threw, "no plugin");
         // try the suppress-exception variant
         ensure("bad launch returned non-NULL", ! LLLeap::create("empty", StringVec(), false));
@@ -308,12 +305,9 @@ namespace tut
         // Synthesize bogus executable name
         std::string BADPYTHON(PYTHON.substr(0, PYTHON.length()-1) + "x");
         CaptureLog log;
-        std::string threw;
-        try
-        {
-            LLLeap::create("bad exe", BADPYTHON);
-        }
-        CATCH_AND_STORE_WHAT_IN(threw, LLLeap::Error)
+        std::string threw = catch_what<LLLeap::Error>([&BADPYTHON](){
+                LLLeap::create("bad exe", BADPYTHON);
+            });
         ensure_contains("LLLeap::create() didn't throw", threw, "failed");
         log.messageWith("failed");
         log.messageWith(BADPYTHON);
diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp
index 5c87cdabd914600873d8d0b062735b4d899a7804..222d8320843de36a2d2db59b86d74f51a2ff689c 100644
--- a/indra/llcommon/tests/llprocess_test.cpp
+++ b/indra/llcommon/tests/llprocess_test.cpp
@@ -25,8 +25,6 @@
 #include <boost/function.hpp>
 #include <boost/algorithm/string/find_iterator.hpp>
 #include <boost/algorithm/string/finder.hpp>
-//#include <boost/lambda/lambda.hpp>
-//#include <boost/lambda/bind.hpp>
 // other Linden headers
 #include "../test/lltut.h"
 #include "../test/namedtempfile.h"
@@ -35,7 +33,7 @@
 #include "llsdutil.h"
 #include "llevents.h"
 #include "llstring.h"
-#include "wrapllerrs.h"
+#include "wrapllerrs.h"             // CaptureLog
 
 #if defined(LL_WINDOWS)
 #define sleep(secs) _sleep((secs) * 1000)
@@ -45,8 +43,7 @@
 #include <sys/wait.h>
 #endif
 
-//namespace lambda = boost::lambda;
- std::string apr_strerror_helper(apr_status_t rv)
+std::string apr_strerror_helper(apr_status_t rv)
 {
     char errbuf[256];
     apr_strerror(rv, errbuf, sizeof(errbuf));
@@ -960,12 +957,9 @@ namespace tut
 #define CATCH_IN(THREW, EXCEPTION, CODE)                                \
     do                                                                  \
     {                                                                   \
-        (THREW).clear();                                                \
-        try                                                             \
-        {                                                               \
-            CODE;                                                       \
-        }                                                               \
-        CATCH_AND_STORE_WHAT_IN(THREW, EXCEPTION)                       \
+        (THREW) = catch_what<EXCEPTION>([&](){                          \
+                CODE;                                                   \
+            });                                                         \
         ensure("failed to throw " #EXCEPTION ": " #CODE, ! (THREW).empty()); \
     } while (0)
 
diff --git a/indra/llcommon/tests/llsingleton_test.cpp b/indra/llcommon/tests/llsingleton_test.cpp
index 56886bc73fd9185932f76c82d0d72232cc5c4e5c..75ddff9d7daa427472f3408b70f170331b5c2ddb 100644
--- a/indra/llcommon/tests/llsingleton_test.cpp
+++ b/indra/llcommon/tests/llsingleton_test.cpp
@@ -29,7 +29,8 @@
 
 #include "llsingleton.h"
 #include "../test/lltut.h"
-
+#include "wrapllerrs.h"
+#include "llsd.h"
 
 // Capture execution sequence by appending to log string.
 std::string sLog;
@@ -198,4 +199,134 @@ namespace tut
 
     TESTS(A, B, 4, 5, 6, 7)
     TESTS(B, A, 8, 9, 10, 11)
+
+#define PARAMSINGLETON(cls)                                             \
+    class cls: public LLParamSingleton<cls>                             \
+    {                                                                   \
+        LLSINGLETON(cls, const LLSD::String& str): mDesc(str) {}        \
+        cls(LLSD::Integer i): mDesc(i) {}                               \
+                                                                        \
+    public:                                                             \
+        std::string desc() const { return mDesc.asString(); }           \
+                                                                        \
+    private:                                                            \
+        LLSD mDesc;                                                     \
+    }
+
+    // Declare two otherwise-identical LLParamSingleton classes so we can
+    // validly initialize each using two different constructors. If we tried
+    // to test that with a single LLParamSingleton class within the same test
+    // program, we'd get 'trying to use deleted LLParamSingleton' errors.
+    PARAMSINGLETON(PSing1);
+    PARAMSINGLETON(PSing2);
+
+    template<> template<>
+    void singleton_object_t::test<12>()
+    {
+        set_test_name("LLParamSingleton");
+
+        WrapLLErrs catcherr;
+        // query methods
+        ensure("false positive on instanceExists()", ! PSing1::instanceExists());
+        ensure("false positive on wasDeleted()", ! PSing1::wasDeleted());
+        // try to reference before initializing
+        std::string threw = catcherr.catch_llerrs([](){
+                (void)PSing1::instance();
+            });
+        ensure_contains("too-early instance() didn't throw", threw, "Uninitialized");
+        // getInstance() behaves the same as instance()
+        threw = catcherr.catch_llerrs([](){
+                (void)PSing1::getInstance();
+            });
+        ensure_contains("too-early getInstance() didn't throw", threw, "Uninitialized");
+        // initialize using LLSD::String constructor
+        PSing1::initParamSingleton("string");
+        ensure_equals(PSing1::instance().desc(), "string");
+        ensure("false negative on instanceExists()", PSing1::instanceExists());
+        // try to initialize again
+        threw = catcherr.catch_llerrs([](){
+                PSing1::initParamSingleton("again");
+            });
+        ensure_contains("second ctor(string) didn't throw", threw, "twice");
+        // try to initialize using the other constructor -- should be
+        // well-formed, but illegal at runtime
+        threw = catcherr.catch_llerrs([](){
+                PSing1::initParamSingleton(17);
+            });
+        ensure_contains("other ctor(int) didn't throw", threw, "twice");
+        PSing1::deleteSingleton();
+        ensure("false negative on wasDeleted()", PSing1::wasDeleted());
+        threw = catcherr.catch_llerrs([](){
+                (void)PSing1::instance();
+            });
+        ensure_contains("accessed deleted LLParamSingleton", threw, "deleted");
+    }
+
+    template<> template<>
+    void singleton_object_t::test<13>()
+    {
+        set_test_name("LLParamSingleton alternate ctor");
+
+        WrapLLErrs catcherr;
+        // We don't have to restate all the tests for PSing1. Only test validly
+        // using the other constructor.
+        PSing2::initParamSingleton(17);
+        ensure_equals(PSing2::instance().desc(), "17");
+        // can't do it twice
+        std::string threw = catcherr.catch_llerrs([](){
+                PSing2::initParamSingleton(34);
+            });
+        ensure_contains("second ctor(int) didn't throw", threw, "twice");
+        // can't use the other constructor either
+        threw = catcherr.catch_llerrs([](){
+                PSing2::initParamSingleton("string");
+            });
+        ensure_contains("other ctor(string) didn't throw", threw, "twice");
+    }
+
+    class CircularPCtor: public LLParamSingleton<CircularPCtor>
+    {
+        LLSINGLETON(CircularPCtor)
+        {
+            // never mind indirection, just go straight for the circularity
+            (void)instance();
+        }
+    };
+
+    template<> template<>
+    void singleton_object_t::test<14>()
+    {
+        set_test_name("Circular LLParamSingleton constructor");
+        WrapLLErrs catcherr;
+        std::string threw = catcherr.catch_llerrs([](){
+                CircularPCtor::initParamSingleton();
+            });
+        ensure_contains("constructor circularity didn't throw", threw, "constructor");
+    }
+
+    class CircularPInit: public LLParamSingleton<CircularPInit>
+    {
+        LLSINGLETON_EMPTY_CTOR(CircularPInit);
+    public:
+        virtual void initSingleton()
+        {
+            // never mind indirection, just go straight for the circularity
+            CircularPInit *pt = getInstance();
+            if (!pt)
+            {
+                throw;
+            }
+        }
+    };
+
+    template<> template<>
+    void singleton_object_t::test<15>()
+    {
+        set_test_name("Circular LLParamSingleton initSingleton()");
+        WrapLLErrs catcherr;
+        std::string threw = catcherr.catch_llerrs([](){
+                CircularPInit::initParamSingleton();
+            });
+        ensure("initSingleton() circularity threw", threw.empty());
+    }
 }
diff --git a/indra/llcommon/tests/wrapllerrs.h b/indra/llcommon/tests/wrapllerrs.h
index 08fbf19b1cdccec7323769b515246737368de2d0..b07d5afbd8fa7a7582356f670b6f9bee27896dd6 100644
--- a/indra/llcommon/tests/wrapllerrs.h
+++ b/indra/llcommon/tests/wrapllerrs.h
@@ -37,6 +37,7 @@
 #include "llerrorcontrol.h"
 #include "llexception.h"
 #include "stringize.h"
+#include "../test/catch_and_store_what_in.h"
 #include <boost/bind.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
@@ -81,6 +82,31 @@ struct WrapLLErrs
         LLTHROW(FatalException(message));
     }
 
+    /// Convenience wrapper for catch_what<FatalException>()
+    //
+    // The implementation makes it clear that this function need not be a
+    // member; it could easily be a free function. It is a member because it
+    // makes no sense to attempt to catch FatalException unless there is a
+    // WrapLLErrs instance in scope. Without a live WrapLLErrs instance, any
+    // LL_ERRS() reached by code within 'func' would terminate the test
+    // program instead of throwing FatalException.
+    //
+    // We were tempted to introduce a free function, likewise accepting
+    // arbitrary 'func', that would instantiate WrapLLErrs and then call
+    // catch_llerrs() on that instance. We decided against it, for this
+    // reason: on extending a test function containing a single call to that
+    // free function, a maintainer would most likely make additional calls to
+    // that free function, instead of switching to an explicit WrapLLErrs
+    // declaration with several calls to its catch_llerrs() member function.
+    // Even a construct such as WrapLLErrs().catch_llerrs(...) would make the
+    // object declaration more visible; it's not unreasonable to expect a
+    // maintainer to extend that by naming and reusing the WrapLLErrs instance.
+    template <typename FUNC>
+    std::string catch_llerrs(FUNC func)
+    {
+        return catch_what<FatalException>(func);
+    }
+
     std::string error;
     LLError::SettingsStoragePtr mPriorErrorSettings;
     LLError::FatalFunction mPriorFatal;
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index aed89434391e43f1e38253d0315e7bf252cc2769..7a0c8cd8f57eab57ec105a6b208dc22fffc7b5a7 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -583,39 +583,29 @@ static void bilinear_scale(const U8 *src, U32 srcW, U32 srcH, U32 srcCh, U32 src
 // LLImage
 //---------------------------------------------------------------------------
 
-//static
-std::string LLImage::sLastErrorMessage;
-LLMutex* LLImage::sMutex = NULL;
-bool LLImage::sUseNewByteRange = false;
-S32  LLImage::sMinimalReverseByteRangePercent = 75;
-
-//static
-void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent)
+LLImage::LLImage(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent)
 {
-	sUseNewByteRange = use_new_byte_range;
-    sMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent;
-	sMutex = new LLMutex();
+    mMutex = new LLMutex();
+    mUseNewByteRange = use_new_byte_range;
+    mMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent;
 }
 
-//static
-void LLImage::cleanupClass()
+LLImage::~LLImage()
 {
-	delete sMutex;
-	sMutex = NULL;
+    delete mMutex;
+    mMutex = NULL;
 }
 
-//static
-const std::string& LLImage::getLastError()
+const std::string& LLImage::getLastErrorMessage()
 {
 	static const std::string noerr("No Error");
-	return sLastErrorMessage.empty() ? noerr : sLastErrorMessage;
+	return mLastErrorMessage.empty() ? noerr : mLastErrorMessage;
 }
 
-//static
-void LLImage::setLastError(const std::string& message)
+void LLImage::setLastErrorMessage(const std::string& message)
 {
-	LLMutexLock m(sMutex);
-	sLastErrorMessage = message;
+	LLMutexLock m(mMutex);
+	mLastErrorMessage = message;
 }
 
 //---------------------------------------------------------------------------
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 8ec49d3f0f96cb806b08440a212da8f91ee7818e..9f8d06129394faeb024f88fdcee7e95946d8f00b 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -30,6 +30,7 @@
 #include "lluuid.h"
 #include "llstring.h"
 #include "llpointer.h"
+#include "llsingleton.h"
 #include "lltrace.h"
 
 const S32 MIN_IMAGE_MIP =  2; // 4x4, only used for expand/contract power of 2
@@ -88,23 +89,25 @@ typedef enum e_image_codec
 //============================================================================
 // library initialization class
 
-class LLImage
+class LLImage : public LLParamSingleton<LLImage>
 {
+	LLSINGLETON(LLImage, bool use_new_byte_range = false, S32 minimal_reverse_byte_range_percent = 75);
+	~LLImage();
 public:
-	static void initClass(bool use_new_byte_range = false, S32 minimal_reverse_byte_range_percent = 75);
-	static void cleanupClass();
 
-	static const std::string& getLastError();
-	static void setLastError(const std::string& message);
-	
-	static bool useNewByteRange() { return sUseNewByteRange; }
-    static S32  getReverseByteRangePercent() { return sMinimalReverseByteRangePercent; }
-	
-protected:
-	static LLMutex* sMutex;
-	static std::string sLastErrorMessage;
-	static bool sUseNewByteRange;
-    static S32  sMinimalReverseByteRangePercent;
+	const std::string& getLastErrorMessage();
+	static const std::string& getLastError() { return getInstance()->getLastErrorMessage(); };
+	void setLastErrorMessage(const std::string& message);
+	static void setLastError(const std::string& message) { getInstance()->setLastErrorMessage(message); }
+
+	bool useNewByteRange() { return mUseNewByteRange; }
+	S32  getReverseByteRangePercent() { return mMinimalReverseByteRangePercent; }
+
+private:
+	LLMutex* mMutex;
+	std::string mLastErrorMessage;
+	bool mUseNewByteRange;
+	S32  mMinimalReverseByteRangePercent;
 };
 
 //============================================================================
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 4bff21610fc83c861fa301f6ce189823e0d1080b..71cab0554d78943faf8faf17a60f101c56c35ce6 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -281,7 +281,7 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r
 	S32 bytes;
 	S32 new_bytes = (S32) (sqrt((F32)(w*h))*(F32)(comp)*rate*1000.f/layer_factor);
 	S32 old_bytes = (S32)((F32)(w*h*comp)*rate);
-	bytes = (LLImage::useNewByteRange() && (new_bytes < old_bytes) ? new_bytes : old_bytes);
+	bytes = (LLImage::getInstance()->useNewByteRange() && (new_bytes < old_bytes) ? new_bytes : old_bytes);
 	bytes = llmax(bytes, calcHeaderSizeJ2C());
 	return bytes;
 }
@@ -322,7 +322,7 @@ S32 LLImageJ2C::calcDiscardLevelBytes(S32 bytes)
 	{
 		S32 bytes_needed = calcDataSize(discard_level);
 		// Use TextureReverseByteRange percent (see settings.xml) of the optimal size to qualify as correct rendering for the given discard level
-		if (bytes >= (bytes_needed*LLImage::getReverseByteRangePercent()/100))
+		if (bytes >= (bytes_needed*LLImage::getInstance()->getReverseByteRangePercent()/100))
 		{
 			break;
 		}
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index ac02364a67be6dd6e412aadc4bbdff13d5746f77..c37d1d36b42fae90fef2f89f1374cae961a6c3a5 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2419,7 +2419,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
 			
 			if (idx.empty() || face.mNumIndices < 3)
 			{ //why is there an empty index list?
-				LL_WARNS() <<"Empty face present!" << LL_ENDL;
+				LL_WARNS() << "Empty face present! Face index: " << i << " Total: " << face_count << LL_ENDL;
 				continue;
 			}
 
@@ -5244,7 +5244,7 @@ bool LLVolumeFace::cacheOptimize()
 
 	LLVCacheLRU cache;
 	
-	if (mNumVertices < 3)
+	if (mNumVertices < 3 || mNumIndices < 3)
 	{ //nothing to do
 		return true;
 	}
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index ba1a2a035eac7ff0341e247f928a572dcd822a39..6a287f0cc5cf43b87145f482d3339a53f31aac60 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -49,101 +49,22 @@
 #include <map>
 #include <set>
 
-namespace LLAvatarNameCache
-{
-	use_display_name_signal_t mUseDisplayNamesSignal;
-
-	// Cache starts in a paused state until we can determine if the
-	// current region supports display names.
-	bool sRunning = false;
-	
-	// Use the People API (modern) for fetching name if true. Use the old legacy protocol if false.
-	// For testing, there's a UsePeopleAPI setting that can be flipped (must restart viewer).
-	bool sUsePeopleAPI = true;
-	
-	// Base lookup URL for name service.
-	// On simulator, loaded from indra.xml
-	// On viewer, usually a simulator capability (at People API team's request)
-	// Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/agents/"
-	std::string sNameLookupURL;
-
-	// Accumulated agent IDs for next query against service
-	typedef std::set<LLUUID> ask_queue_t;
-	ask_queue_t sAskQueue;
-
-	// Agent IDs that have been requested, but with no reply.
-	// Maps agent ID to frame time request was made.
-	typedef std::map<LLUUID, F64> pending_queue_t;
-	pending_queue_t sPendingQueue;
-
-	// Callbacks to fire when we received a name.
-	// May have multiple callbacks for a single ID, which are
-	// represented as multiple slots bound to the signal.
-	// Avoid copying signals via pointers.
-	typedef std::map<LLUUID, callback_signal_t*> signal_map_t;
-	signal_map_t sSignalMap;
-
-	// The cache at last, i.e. avatar names we know about.
-	typedef std::map<LLUUID, LLAvatarName> cache_t;
-	cache_t sCache;
-
-	// Send bulk lookup requests a few times a second at most.
-	// Only need per-frame timing resolution.
-	LLFrameTimer sRequestTimer;
-
-    // Maximum time an unrefreshed cache entry is allowed.
-    const F64 MAX_UNREFRESHED_TIME = 20.0 * 60.0;
-
-    // Time when unrefreshed cached names were checked last.
-    static F64 sLastExpireCheck;
-
-	// Time-to-live for a temp cache entry.
-	const F64 TEMP_CACHE_ENTRY_LIFETIME = 60.0;
-
-    LLCore::HttpRequest::ptr_t		sHttpRequest;
-    LLCore::HttpHeaders::ptr_t		sHttpHeaders;
-    LLCore::HttpOptions::ptr_t		sHttpOptions;
-    LLCore::HttpRequest::policy_t	sHttpPolicy;
-    LLCore::HttpRequest::priority_t	sHttpPriority;
-
-	//-----------------------------------------------------------------------
-	// Internal methods
-	//-----------------------------------------------------------------------
-
-	// Handle name response off network.
-	void processName(const LLUUID& agent_id,
-					 const LLAvatarName& av_name);
-
-	void requestNamesViaCapability();
-
-	// Legacy name system callbacks
-	void legacyNameCallback(const LLUUID& agent_id,
-							const std::string& full_name,
-							bool is_group);
-	void legacyNameFetch(const LLUUID& agent_id,
-						 const std::string& full_name,
-						 bool is_group);
-	
-	void requestNamesViaLegacy();
-
-	// Do a single callback to a given slot
-	void fireSignal(const LLUUID& agent_id,
-					const callback_slot_t& slot,
-					const LLAvatarName& av_name);
-	
-	// Is a request in-flight over the network?
-	bool isRequestPending(const LLUUID& agent_id);
 
-	// Erase expired names from cache
-	void eraseUnrefreshed();
+// Time-to-live for a temp cache entry.
+const F64 TEMP_CACHE_ENTRY_LIFETIME = 60.0;
+// Maximum time an unrefreshed cache entry is allowed.
+const F64 MAX_UNREFRESHED_TIME = 20.0 * 60.0;
 
-    bool expirationFromCacheControl(const LLSD& headers, F64 *expires);
+// Send bulk lookup requests a few times a second at most.
+// Only need per-frame timing resolution.
+static LLFrameTimer sRequestTimer;
 
-    // This is a coroutine.
-    void requestAvatarNameCache_(std::string url, std::vector<LLUUID> agentIds);
-
-    void handleAvNameCacheSuccess(const LLSD &data, const LLSD &httpResult);
-}
+// static to avoid unnessesary dependencies
+LLCore::HttpRequest::ptr_t		sHttpRequest;
+LLCore::HttpHeaders::ptr_t		sHttpHeaders;
+LLCore::HttpOptions::ptr_t		sHttpOptions;
+LLCore::HttpRequest::policy_t	sHttpPolicy;
+LLCore::HttpRequest::priority_t	sHttpPriority;
 
 /* Sample response:
 <?xml version="1.0"?>
@@ -187,6 +108,30 @@ namespace LLAvatarNameCache
 // Coroutine for sending and processing avatar name cache requests.  
 // Do not call directly.  See documentation in lleventcoro.h and llcoro.h for
 // further explanation.
+
+LLAvatarNameCache::LLAvatarNameCache()
+{
+    // Will be set to running later
+    // For now fail immediate lookups and query async ones.
+    mRunning = false;
+
+    mUsePeopleAPI = true;
+
+    sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest());
+    sHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders());
+    sHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions());
+    sHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID;
+    sHttpPriority = 0;
+}
+
+LLAvatarNameCache::~LLAvatarNameCache()
+{
+    sHttpRequest.reset();
+    sHttpHeaders.reset();
+    sHttpOptions.reset();
+    mCache.clear();
+}
+
 void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector<LLUUID> agentIds)
 {
     LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName()
@@ -205,7 +150,7 @@ void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector<LLU
     {
         bool success = true;
 
-        LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("NameCache", LLAvatarNameCache::sHttpPolicy);
+        LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("NameCache", sHttpPolicy);
         LLSD results = httpAdapter.getAndSuspend(sHttpRequest, url);
 
         LL_DEBUGS() << results << LL_ENDL;
@@ -233,12 +178,12 @@ void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector<LLU
             for ( ; it != agentIds.end(); ++it)
             {
                 const LLUUID& agent_id = *it;
-                LLAvatarNameCache::handleAgentError(agent_id);
+                LLAvatarNameCache::getInstance()->handleAgentError(agent_id);
             }
             return;
         }
 
-        LLAvatarNameCache::handleAvNameCacheSuccess(results, httpResults);
+        LLAvatarNameCache::getInstance()->handleAvNameCacheSuccess(results, httpResults);
 
     }
     catch (...)
@@ -300,15 +245,15 @@ void LLAvatarNameCache::handleAvNameCacheSuccess(const LLSD &data, const LLSD &h
         }
     }
     LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result "
-        << LLAvatarNameCache::sCache.size() << " cached names"
+        << LLAvatarNameCache::mCache.size() << " cached names"
         << LL_ENDL;
 }
 
 // Provide some fallback for agents that return errors
 void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id)
 {
-	std::map<LLUUID,LLAvatarName>::iterator existing = sCache.find(agent_id);
-	if (existing == sCache.end())
+	std::map<LLUUID,LLAvatarName>::iterator existing = mCache.find(agent_id);
+	if (existing == mCache.end())
     {
         // there is no existing cache entry, so make a temporary name from legacy
         LL_WARNS("AvNameCache") << "LLAvatarNameCache get legacy for agent "
@@ -322,7 +267,7 @@ void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id)
         // been returned by the get method, there is no need to signal anyone
 
         // Clear this agent from the pending list
-        LLAvatarNameCache::sPendingQueue.erase(agent_id);
+        LLAvatarNameCache::mPendingQueue.erase(agent_id);
 
         LLAvatarName& av_name = existing->second;
         LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent " << agent_id << LL_ENDL;
@@ -341,19 +286,19 @@ void LLAvatarNameCache::processName(const LLUUID& agent_id, const LLAvatarName&
 	}
 
 	// Add to the cache
-	sCache[agent_id] = av_name;
+	mCache[agent_id] = av_name;
 
 	// Suppress request from the queue
-	sPendingQueue.erase(agent_id);
+	mPendingQueue.erase(agent_id);
 
 	// Signal everyone waiting on this name
-	signal_map_t::iterator sig_it =	sSignalMap.find(agent_id);
-	if (sig_it != sSignalMap.end())
+	signal_map_t::iterator sig_it =	mSignalMap.find(agent_id);
+	if (sig_it != mSignalMap.end())
 	{
 		callback_signal_t* signal = sig_it->second;
 		(*signal)(agent_id, av_name);
 
-		sSignalMap.erase(agent_id);
+		mSignalMap.erase(agent_id);
 
 		delete signal;
 		signal = NULL;
@@ -379,16 +324,16 @@ void LLAvatarNameCache::requestNamesViaCapability()
 	
 	U32 ids = 0;
 	ask_queue_t::const_iterator it;
-	while(!sAskQueue.empty())
+	while(!mAskQueue.empty())
 	{
-		it = sAskQueue.begin();
+		it = mAskQueue.begin();
 		LLUUID agent_id = *it;
-		sAskQueue.erase(it);
+		mAskQueue.erase(it);
 
 		if (url.empty())
 		{
 			// ...starting new request
-			url += sNameLookupURL;
+			url += mNameLookupURL;
 			url += "?ids=";
 			ids = 1;
 		}
@@ -402,7 +347,7 @@ void LLAvatarNameCache::requestNamesViaCapability()
 		agent_ids.push_back(agent_id);
 
 		// mark request as pending
-		sPendingQueue[agent_id] = now;
+		mPendingQueue[agent_id] = now;
 
 		if (url.size() > NAME_URL_SEND_THRESHOLD)
 		{
@@ -432,7 +377,7 @@ void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id,
 	// Retrieve the name and set it to never (or almost never...) expire: when we are using the legacy
 	// protocol, we do not get an expiration date for each name and there's no reason to ask the 
 	// data again and again so we set the expiration time to the largest value admissible.
-	std::map<LLUUID,LLAvatarName>::iterator av_record = sCache.find(agent_id);
+	std::map<LLUUID,LLAvatarName>::iterator av_record = LLAvatarNameCache::getInstance()->mCache.find(agent_id);
 	LLAvatarName& av_name = av_record->second;
 	av_name.setExpires(MAX_UNREFRESHED_TIME);
 }
@@ -451,7 +396,7 @@ void LLAvatarNameCache::legacyNameFetch(const LLUUID& agent_id,
 	av_name.fromString(full_name);
 	
 	// Add to cache: we're still using the new cache even if we're using the old (legacy) protocol.
-	processName(agent_id, av_name);
+	LLAvatarNameCache::getInstance()->processName(agent_id, av_name);
 }
 
 void LLAvatarNameCache::requestNamesViaLegacy()
@@ -460,15 +405,15 @@ void LLAvatarNameCache::requestNamesViaLegacy()
 	F64 now = LLFrameTimer::getTotalSeconds();
 	std::string full_name;
 	ask_queue_t::const_iterator it;
-	for (S32 requests = 0; !sAskQueue.empty() && requests < MAX_REQUESTS; ++requests)
+	for (S32 requests = 0; !mAskQueue.empty() && requests < MAX_REQUESTS; ++requests)
 	{
-		it = sAskQueue.begin();
+		it = mAskQueue.begin();
 		LLUUID agent_id = *it;
-		sAskQueue.erase(it);
+		mAskQueue.erase(it);
 
 		// Mark as pending first, just in case the callback is immediately
 		// invoked below.  This should never happen in practice.
-		sPendingQueue[agent_id] = now;
+		mPendingQueue[agent_id] = now;
 
 		LL_DEBUGS("AvNameCache") << "agent " << agent_id << LL_ENDL;
 
@@ -477,26 +422,6 @@ void LLAvatarNameCache::requestNamesViaLegacy()
 	}
 }
 
-void LLAvatarNameCache::initClass(bool running, bool usePeopleAPI)
-{
-	sRunning = running;
-	sUsePeopleAPI = usePeopleAPI;
-
-    sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest());
-    sHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders());
-    sHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions());
-    sHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID;
-    sHttpPriority = 0;
-}
-
-void LLAvatarNameCache::cleanupClass()
-{
-    sHttpRequest.reset();
-    sHttpHeaders.reset();
-    sHttpOptions.reset();
-    sCache.clear();
-}
-
 bool LLAvatarNameCache::importFile(std::istream& istr)
 {
 	LLSD data;
@@ -517,9 +442,9 @@ bool LLAvatarNameCache::importFile(std::istream& istr)
 	{
 		agent_id.set(it->first);
 		av_name.fromLLSD( it->second );
-		sCache[agent_id] = av_name;
+		mCache[agent_id] = av_name;
 	}
-    LL_INFOS("AvNameCache") << "LLAvatarNameCache loaded " << sCache.size() << LL_ENDL;
+    LL_INFOS("AvNameCache") << "LLAvatarNameCache loaded " << mCache.size() << LL_ENDL;
 	// Some entries may have expired since the cache was stored,
     // but they will be flushed in the first call to eraseUnrefreshed
     // from LLAvatarNameResponder::idle
@@ -531,9 +456,9 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr)
 {
 	LLSD agents;
 	F64 max_unrefreshed = LLFrameTimer::getTotalSeconds() - MAX_UNREFRESHED_TIME;
-    LL_INFOS("AvNameCache") << "LLAvatarNameCache at exit cache has " << sCache.size() << LL_ENDL;
-	cache_t::const_iterator it = sCache.begin();
-	for ( ; it != sCache.end(); ++it)
+    LL_INFOS("AvNameCache") << "LLAvatarNameCache at exit cache has " << mCache.size() << LL_ENDL;
+	cache_t::const_iterator it = mCache.begin();
+	for ( ; it != mCache.end(); ++it)
 	{
 		const LLUUID& agent_id = it->first;
 		const LLAvatarName& av_name = it->second;
@@ -552,23 +477,28 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr)
 
 void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url)
 {
-	sNameLookupURL = name_lookup_url;
+	mNameLookupURL = name_lookup_url;
 }
 
 bool LLAvatarNameCache::hasNameLookupURL()
 {
-	return !sNameLookupURL.empty();
+	return !mNameLookupURL.empty();
+}
+
+void LLAvatarNameCache::setUsePeopleAPI(bool use_api)
+{
+    mUsePeopleAPI = use_api;
 }
 
 bool LLAvatarNameCache::usePeopleAPI()
 {
-	return hasNameLookupURL() && sUsePeopleAPI;
+	return hasNameLookupURL() && mUsePeopleAPI;
 }
 
 void LLAvatarNameCache::idle()
 {
 	// By convention, start running at first idle() call
-	sRunning = true;
+	mRunning = true;
 
 	// *TODO: Possibly re-enabled this based on People API load measurements
 	// 100 ms is the threshold for "user speed" operations, so we can
@@ -579,7 +509,7 @@ void LLAvatarNameCache::idle()
 		return;
 	}
 
-	if (!sAskQueue.empty())
+	if (!mAskQueue.empty())
 	{
         if (usePeopleAPI())
         {
@@ -592,7 +522,7 @@ void LLAvatarNameCache::idle()
         }
 	}
 
-	if (sAskQueue.empty())
+	if (mAskQueue.empty())
 	{
 		// cleared the list, reset the request timer.
 		sRequestTimer.resetWithExpiry(SECS_BETWEEN_REQUESTS);
@@ -607,8 +537,8 @@ bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id)
 	bool isPending = false;
 	const F64 PENDING_TIMEOUT_SECS = 5.0 * 60.0;
 
-	pending_queue_t::const_iterator it = sPendingQueue.find(agent_id);
-	if (it != sPendingQueue.end())
+	pending_queue_t::const_iterator it = mPendingQueue.find(agent_id);
+	if (it != mPendingQueue.end())
 	{
 		// in the list of requests in flight, retry if too old
 		F64 expire_time = LLFrameTimer::getTotalSeconds() - PENDING_TIMEOUT_SECS;
@@ -622,11 +552,11 @@ void LLAvatarNameCache::eraseUnrefreshed()
 	F64 now = LLFrameTimer::getTotalSeconds();
 	F64 max_unrefreshed = now - MAX_UNREFRESHED_TIME;
 
-    if (!sLastExpireCheck || sLastExpireCheck < max_unrefreshed)
+    if (!mLastExpireCheck || mLastExpireCheck < max_unrefreshed)
     {
-        sLastExpireCheck = now;
+        mLastExpireCheck = now;
         S32 expired = 0;
-        for (cache_t::iterator it = sCache.begin(); it != sCache.end();)
+        for (cache_t::iterator it = mCache.begin(); it != mCache.end();)
         {
             const LLAvatarName& av_name = it->second;
             if (av_name.mExpires < max_unrefreshed)
@@ -635,7 +565,7 @@ void LLAvatarNameCache::eraseUnrefreshed()
                                          << " user '" << av_name.getAccountName() << "' "
                                          << "expired " << now - av_name.mExpires << " secs ago"
                                          << LL_ENDL;
-                sCache.erase(it++);
+                mCache.erase(it++);
                 expired++;
             }
 			else
@@ -644,19 +574,24 @@ void LLAvatarNameCache::eraseUnrefreshed()
 			}
         }
         LL_INFOS("AvNameCache") << "LLAvatarNameCache expired " << expired << " cached avatar names, "
-                                << sCache.size() << " remaining" << LL_ENDL;
+                                << mCache.size() << " remaining" << LL_ENDL;
 	}
 }
 
+//static, wrapper
+bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
+{
+    return LLAvatarNameCache::getInstance()->getName(agent_id, av_name);
+}
 // fills in av_name if it has it in the cache, even if expired (can check expiry time)
 // returns bool specifying  if av_name was filled, false otherwise
-bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
+bool LLAvatarNameCache::getName(const LLUUID& agent_id, LLAvatarName *av_name)
 {
-	if (sRunning)
+	if (mRunning)
 	{
 		// ...only do immediate lookups when cache is running
-		std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
-		if (it != sCache.end())
+		std::map<LLUUID,LLAvatarName>::iterator it = mCache.find(agent_id);
+		if (it != mCache.end())
 		{
 			*av_name = it->second;
 
@@ -667,7 +602,7 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 				{
 					LL_DEBUGS("AvNameCache") << "LLAvatarNameCache refresh agent " << agent_id
 											 << LL_ENDL;
-					sAskQueue.insert(agent_id);
+					mAskQueue.insert(agent_id);
 				}
 			}
 				
@@ -678,7 +613,7 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 	if (!isRequestPending(agent_id))
 	{
 		LL_DEBUGS("AvNameCache") << "LLAvatarNameCache queue request for agent " << agent_id << LL_ENDL;
-		sAskQueue.insert(agent_id);
+		mAskQueue.insert(agent_id);
 	}
 
 	return false;
@@ -693,15 +628,21 @@ void LLAvatarNameCache::fireSignal(const LLUUID& agent_id,
 	signal(agent_id, av_name);
 }
 
+// static, wrapper
 LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
+{
+    return LLAvatarNameCache::getInstance()->getNameCallback(agent_id, slot);
+}
+
+LLAvatarNameCache::callback_connection_t LLAvatarNameCache::getNameCallback(const LLUUID& agent_id, callback_slot_t slot)
 {
 	callback_connection_t connection;
 
-	if (sRunning)
+	if (mRunning)
 	{
 		// ...only do immediate lookups when cache is running
-		std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
-		if (it != sCache.end())
+		std::map<LLUUID,LLAvatarName>::iterator it = mCache.find(agent_id);
+		if (it != mCache.end())
 		{
 			const LLAvatarName& av_name = it->second;
 			
@@ -717,17 +658,17 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag
 	// schedule a request
 	if (!isRequestPending(agent_id))
 	{
-		sAskQueue.insert(agent_id);
+		mAskQueue.insert(agent_id);
 	}
 
 	// always store additional callback, even if request is pending
-	signal_map_t::iterator sig_it = sSignalMap.find(agent_id);
-	if (sig_it == sSignalMap.end())
+	signal_map_t::iterator sig_it = mSignalMap.find(agent_id);
+	if (sig_it == mSignalMap.end())
 	{
 		// ...new callback for this id
 		callback_signal_t* signal = new callback_signal_t();
 		connection = signal->connect(slot);
-		sSignalMap[agent_id] = signal;
+		mSignalMap[agent_id] = signal;
 	}
 	else
 	{
@@ -760,20 +701,20 @@ void LLAvatarNameCache::setUseUsernames(bool use)
 
 void LLAvatarNameCache::erase(const LLUUID& agent_id)
 {
-	sCache.erase(agent_id);
+	mCache.erase(agent_id);
 }
 
 void LLAvatarNameCache::insert(const LLUUID& agent_id, const LLAvatarName& av_name)
 {
 	// *TODO: update timestamp if zero?
-	sCache[agent_id] = av_name;
+	mCache[agent_id] = av_name;
 }
 
 LLUUID LLAvatarNameCache::findIdByName(const std::string& name)
 {
     std::map<LLUUID, LLAvatarName>::iterator it;
-    std::map<LLUUID, LLAvatarName>::iterator end = sCache.end();
-    for (it = sCache.begin(); it != end; ++it)
+    std::map<LLUUID, LLAvatarName>::iterator end = mCache.end();
+    for (it = mCache.begin(); it != end; ++it)
     {
         if (it->second.getUserName() == name)
         {
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index 63e067c939f502871dafece78e69dfaf8da002dc..ba89d569f3f6f9ce1315a151d070861df2db1f0d 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -29,21 +29,20 @@
 #define LLAVATARNAMECACHE_H
 
 #include "llavatarname.h"	// for convenience
+#include "llsingleton.h"
 #include <boost/signals2.hpp>
+#include <set>
 
 class LLSD;
 class LLUUID;
 
-namespace LLAvatarNameCache
+class LLAvatarNameCache : public LLSingleton<LLAvatarNameCache>
 {
+	LLSINGLETON(LLAvatarNameCache);
+	~LLAvatarNameCache();
+public:
 	typedef boost::signals2::signal<void (void)> use_display_name_signal_t;
 
-	// Until the cache is set running, immediate lookups will fail and
-	// async lookups will be queued.  This allows us to block requests
-	// until we know if the first region supports display names.
-	void initClass(bool running, bool usePeopleAPI);
-	void cleanupClass();
-
 	// Import/export the name cache to file.
 	bool importFile(std::istream& istr);
 	void exportFile(std::ostream& ostr);
@@ -55,6 +54,7 @@ namespace LLAvatarNameCache
 	// Do we have a valid lookup URL, i.e. are we trying to use the
 	// more recent display name lookup system?
 	bool hasNameLookupURL();
+	void setUsePeopleAPI(bool use_api);
 	bool usePeopleAPI();
 	
 	// Periodically makes a batch request for display names not already in
@@ -63,7 +63,8 @@ namespace LLAvatarNameCache
 
 	// If name is in cache, returns true and fills in provided LLAvatarName
 	// otherwise returns false.
-	bool get(const LLUUID& agent_id, LLAvatarName *av_name);
+	static bool get(const LLUUID& agent_id, LLAvatarName *av_name);
+	bool getName(const LLUUID& agent_id, LLAvatarName *av_name);
 
 	// Callback types for get() below
 	typedef boost::signals2::signal<
@@ -74,7 +75,8 @@ namespace LLAvatarNameCache
 
 	// Fetches name information and calls callbacks.
 	// If name information is in cache, callbacks will be called immediately.
-	callback_connection_t get(const LLUUID& agent_id, callback_slot_t slot);
+	static callback_connection_t get(const LLUUID& agent_id, callback_slot_t slot);
+	callback_connection_t getNameCallback(const LLUUID& agent_id, callback_slot_t slot);
 
 	// Set display name: flips the switch and triggers the callbacks.
 	void setUseDisplayNames(bool use);
@@ -100,7 +102,83 @@ namespace LLAvatarNameCache
     F64 nameExpirationFromHeaders(const LLSD& headers);
 
 	void addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb);
-}
+
+private:
+    // Handle name response off network.
+    void processName(const LLUUID& agent_id,
+        const LLAvatarName& av_name);
+
+    void requestNamesViaCapability();
+
+    // Legacy name system callbacks
+    static void legacyNameCallback(const LLUUID& agent_id,
+        const std::string& full_name,
+        bool is_group);
+    static void legacyNameFetch(const LLUUID& agent_id,
+        const std::string& full_name,
+        bool is_group);
+
+    void requestNamesViaLegacy();
+
+    // Do a single callback to a given slot
+    void fireSignal(const LLUUID& agent_id,
+        const callback_slot_t& slot,
+        const LLAvatarName& av_name);
+
+    // Is a request in-flight over the network?
+    bool isRequestPending(const LLUUID& agent_id);
+
+    // Erase expired names from cache
+    void eraseUnrefreshed();
+
+    bool expirationFromCacheControl(const LLSD& headers, F64 *expires);
+
+    // This is a coroutine.
+    static void requestAvatarNameCache_(std::string url, std::vector<LLUUID> agentIds);
+
+    void handleAvNameCacheSuccess(const LLSD &data, const LLSD &httpResult);
+
+private:
+
+    use_display_name_signal_t mUseDisplayNamesSignal;
+
+    // Cache starts in a paused state until we can determine if the
+    // current region supports display names.
+    bool mRunning;
+
+    // Use the People API (modern) for fetching name if true. Use the old legacy protocol if false.
+    // For testing, there's a UsePeopleAPI setting that can be flipped (must restart viewer).
+    bool mUsePeopleAPI;
+
+    // Base lookup URL for name service.
+    // On simulator, loaded from indra.xml
+    // On viewer, usually a simulator capability (at People API team's request)
+    // Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/agents/"
+    std::string mNameLookupURL;
+
+    // Accumulated agent IDs for next query against service
+    typedef std::set<LLUUID> ask_queue_t;
+    ask_queue_t mAskQueue;
+
+    // Agent IDs that have been requested, but with no reply.
+    // Maps agent ID to frame time request was made.
+    typedef std::map<LLUUID, F64> pending_queue_t;
+    pending_queue_t mPendingQueue;
+
+    // Callbacks to fire when we received a name.
+    // May have multiple callbacks for a single ID, which are
+    // represented as multiple slots bound to the signal.
+    // Avoid copying signals via pointers.
+    typedef std::map<LLUUID, callback_signal_t*> signal_map_t;
+    signal_map_t mSignalMap;
+
+    // The cache at last, i.e. avatar names we know about.
+    typedef std::map<LLUUID, LLAvatarName> cache_t;
+    cache_t mCache;
+
+    // Time when unrefreshed cached names were checked last.
+    F64 mLastExpireCheck;
+};
 
 // Parse a cache-control header to get the max-age delta-seconds.
 // Returns true if header has max-age param and it parses correctly.
diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp
index dea03aab853fe6267170ca7f8163c4425672bfb8..950599217f83195b1adb0ff4ed07a461030eafb0 100644
--- a/indra/llmessage/llproxy.cpp
+++ b/indra/llmessage/llproxy.cpp
@@ -403,8 +403,11 @@ LLSocks5AuthType LLProxy::getSelectedAuthMethod() const
 //static
 void LLProxy::cleanupClass()
 {
-	getInstance()->stopSOCKSProxy();
-	deleteSingleton();
+    if (instanceExists())
+    {
+        getInstance()->stopSOCKSProxy();
+        deleteSingleton();
+    }
 }
 
 /**
diff --git a/indra/llmessage/tests/llareslistener_test.cpp b/indra/llmessage/tests/llareslistener_test.cpp
index c04696c86b721f5734214fc9ad369c3a9b44847c..254185cbd0981c9081cbd56e5966170b8370a610 100644
--- a/indra/llmessage/tests/llareslistener_test.cpp
+++ b/indra/llmessage/tests/llareslistener_test.cpp
@@ -138,15 +138,9 @@ namespace tut
         WrapLLErrs capture;
         LLSD request;
         request["op"] = "foo";
-        std::string threw;
-        try
-        {
-            LLEventPumps::instance().obtain("LLAres").post(request);
-        }
-        catch (const WrapLLErrs::FatalException& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = capture.catch_llerrs([&request](){
+                LLEventPumps::instance().obtain("LLAres").post(request);
+            });
         ensure_contains("LLAresListener bad op", threw, "bad");
     }
 
@@ -157,15 +151,9 @@ namespace tut
         WrapLLErrs capture;
         LLSD request;
         request["op"] = "rewriteURI";
-        std::string threw;
-        try
-        {
-            LLEventPumps::instance().obtain("LLAres").post(request);
-        }
-        catch (const WrapLLErrs::FatalException& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = capture.catch_llerrs([&request](){
+                LLEventPumps::instance().obtain("LLAres").post(request);
+            });
         ensure_contains("LLAresListener bad req", threw, "missing");
         ensure_contains("LLAresListener bad req", threw, "reply");
         ensure_contains("LLAresListener bad req", threw, "uri");
@@ -179,15 +167,9 @@ namespace tut
         LLSD request;
         request["op"] = "rewriteURI";
         request["reply"] = "nonexistent";
-        std::string threw;
-        try
-        {
-            LLEventPumps::instance().obtain("LLAres").post(request);
-        }
-        catch (const WrapLLErrs::FatalException& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = capture.catch_llerrs([&request](){
+                LLEventPumps::instance().obtain("LLAres").post(request);
+            });
         ensure_contains("LLAresListener bad req", threw, "missing");
         ensure_contains("LLAresListener bad req", threw, "uri");
         ensure_does_not_contain("LLAresListener bad req", threw, "reply");
@@ -201,15 +183,9 @@ namespace tut
         LLSD request;
         request["op"] = "rewriteURI";
         request["uri"] = "foo.bar.com";
-        std::string threw;
-        try
-        {
-            LLEventPumps::instance().obtain("LLAres").post(request);
-        }
-        catch (const WrapLLErrs::FatalException& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = capture.catch_llerrs([&request](){
+                LLEventPumps::instance().obtain("LLAres").post(request);
+            });
         ensure_contains("LLAresListener bad req", threw, "missing");
         ensure_contains("LLAresListener bad req", threw, "reply");
         ensure_does_not_contain("LLAresListener bad req", threw, "uri");
diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp
index 4e2ebfd51ef248fa599f1dd60108fa25a5483838..801b94580615956593154162753680cf1eafec53 100644
--- a/indra/llrender/llrender2dutils.cpp
+++ b/indra/llrender/llrender2dutils.cpp
@@ -46,8 +46,6 @@
 // Globals
 //
 const LLColor4 UI_VERTEX_COLOR(1.f, 1.f, 1.f, 1.f);
-/*static*/ LLVector2		LLRender2D::sGLScaleFactor(1.f, 1.f);
-/*static*/ LLImageProviderInterface* LLRender2D::sImageProvider = NULL;
 
 //
 // Functions
@@ -108,10 +106,11 @@ void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, S32 pixe
 	top += LLFontGL::sCurOrigin.mY;
 
 	gGL.loadUIIdentity();
-	gl_rect_2d(llfloor((F32)left * LLRender2D::sGLScaleFactor.mV[VX]) - pixel_offset,
-				llfloor((F32)top * LLRender2D::sGLScaleFactor.mV[VY]) + pixel_offset,
-				llfloor((F32)right * LLRender2D::sGLScaleFactor.mV[VX]) + pixel_offset,
-				llfloor((F32)bottom * LLRender2D::sGLScaleFactor.mV[VY]) - pixel_offset,
+	LLRender2D *r2d_inst = LLRender2D::getInstance();
+	gl_rect_2d(llfloor((F32)left * r2d_inst->mGLScaleFactor.mV[VX]) - pixel_offset,
+				llfloor((F32)top * r2d_inst->mGLScaleFactor.mV[VY]) + pixel_offset,
+				llfloor((F32)right * r2d_inst->mGLScaleFactor.mV[VX]) + pixel_offset,
+				llfloor((F32)bottom * r2d_inst->mGLScaleFactor.mV[VY]) - pixel_offset,
 				filled);
 	gGL.popUIMatrix();
 }
@@ -800,7 +799,7 @@ void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LL
 	}
 	gGL.end();
 
-	LLRender2D::setLineWidth(1.f);
+	LLRender2D::getInstance()->setLineWidth(1.f);
 }
 
 void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F32 start_angle, F32 end_angle)
@@ -967,7 +966,7 @@ void gl_rect_2d_checkerboard(const LLRect& rect, GLfloat alpha)
 	}
 	else
 	{ //polygon stipple is deprecated, use "Checker" texture
-		LLPointer<LLUIImage> img = LLRender2D::getUIImage("Checker");
+		LLPointer<LLUIImage> img = LLRender2D::getInstance()->getUIImage("Checker");
 		gGL.getTexUnit(0)->bind(img->getImage());
 		gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP);
 		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
@@ -1567,25 +1566,26 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv
 
 }
 
-// static
-void LLRender2D::initClass(LLImageProviderInterface* image_provider,
-						   const LLVector2* scale_factor)
+LLRender2D::LLRender2D(LLImageProviderInterface* image_provider)
 {
-	sGLScaleFactor = (scale_factor == NULL) ? LLVector2(1.f, 1.f) : *scale_factor;
-	sImageProvider = image_provider;
+	mGLScaleFactor = LLVector2(1.f, 1.f);
+	mImageProvider = image_provider;
+	if(mImageProvider)
+	{
+		mImageProvider->addOnRemovalCallback(resetProvider);
+	}
 }
 
-// static
-void LLRender2D::cleanupClass()
+LLRender2D::~LLRender2D()
 {
-	if(sImageProvider)
+	if(mImageProvider)
 	{
-		sImageProvider->cleanUp();
+		mImageProvider->cleanUp();
+		mImageProvider->deleteOnRemovalCallback(resetProvider);
 	}
 }
 
 
-//static
 void LLRender2D::translate(F32 x, F32 y, F32 z)
 {
 	gGL.translateUI(x,y,z);
@@ -1594,14 +1594,12 @@ void LLRender2D::translate(F32 x, F32 y, F32 z)
 	LLFontGL::sCurDepth += z;
 }
 
-//static
 void LLRender2D::pushMatrix()
 {
 	gGL.pushUIMatrix();
 	LLFontGL::sOriginStack.push_back(std::make_pair(LLFontGL::sCurOrigin, LLFontGL::sCurDepth));
 }
 
-//static
 void LLRender2D::popMatrix()
 {
 	gGL.popUIMatrix();
@@ -1610,7 +1608,6 @@ void LLRender2D::popMatrix()
 	LLFontGL::sOriginStack.pop_back();
 }
 
-//static 
 void LLRender2D::loadIdentity()
 {
 	gGL.loadUIIdentity(); 
@@ -1619,25 +1616,22 @@ void LLRender2D::loadIdentity()
 	LLFontGL::sCurDepth = 0.f;
 }
 
-//static
 void LLRender2D::setScaleFactor(const LLVector2 &scale_factor)
 {
-	sGLScaleFactor = scale_factor;
+	mGLScaleFactor = scale_factor;
 }
 
-//static
 void LLRender2D::setLineWidth(F32 width)
 {
 	gGL.flush();
-	glLineWidth(width * lerp(sGLScaleFactor.mV[VX], sGLScaleFactor.mV[VY], 0.5f));
+	glLineWidth(width * lerp(mGLScaleFactor.mV[VX], mGLScaleFactor.mV[VY], 0.5f));
 }
 
-//static
 LLPointer<LLUIImage> LLRender2D::getUIImageByID(const LLUUID& image_id, S32 priority)
 {
-	if (sImageProvider)
+	if (mImageProvider)
 	{
-		return sImageProvider->getUIImageByID(image_id, priority);
+		return mImageProvider->getUIImageByID(image_id, priority);
 	}
 	else
 	{
@@ -1645,12 +1639,49 @@ LLPointer<LLUIImage> LLRender2D::getUIImageByID(const LLUUID& image_id, S32 prio
 	}
 }
 
-//static 
 LLPointer<LLUIImage> LLRender2D::getUIImage(const std::string& name, S32 priority)
 {
-	if (!name.empty() && sImageProvider)
-		return sImageProvider->getUIImage(name, priority);
+	if (!name.empty() && mImageProvider)
+		return mImageProvider->getUIImage(name, priority);
 	else
 		return NULL;
 }
 
+// static
+void LLRender2D::resetProvider()
+{
+    if (LLRender2D::instanceExists())
+    {
+        LLRender2D::getInstance()->mImageProvider = NULL;
+    }
+}
+
+// class LLImageProviderInterface
+
+LLImageProviderInterface::~LLImageProviderInterface()
+{
+    for (callback_list_t::iterator iter = mCallbackList.begin(); iter != mCallbackList.end();)
+    {
+        callback_list_t::iterator curiter = iter++;
+        (*curiter)();
+    }
+}
+
+void LLImageProviderInterface::addOnRemovalCallback(callback_t func)
+{
+    if (!func)
+    {
+        return;
+    }
+    mCallbackList.push_back(func);
+}
+
+void LLImageProviderInterface::deleteOnRemovalCallback(callback_t func)
+{
+    callback_list_t::iterator iter = std::find(mCallbackList.begin(), mCallbackList.end(), func);
+    if (iter != mCallbackList.end())
+    {
+        mCallbackList.erase(iter);
+    }
+}
+
diff --git a/indra/llrender/llrender2dutils.h b/indra/llrender/llrender2dutils.h
index cce3b4ed511154d3887ce44259836c1a42135289..70ab006fd6573490d0857cf90b588bd29cb569a4 100644
--- a/indra/llrender/llrender2dutils.h
+++ b/indra/llrender/llrender2dutils.h
@@ -121,39 +121,54 @@ inline void gl_rect_2d_offset_local( const LLRect& rect, S32 pixel_offset, BOOL
 
 class LLImageProviderInterface;
 
-class LLRender2D
+class LLRender2D : public LLParamSingleton<LLRender2D>
 {
+	LLSINGLETON(LLRender2D, LLImageProviderInterface* image_provider);
 	LOG_CLASS(LLRender2D);
+	~LLRender2D();
 public:
-	static void initClass(LLImageProviderInterface* image_provider,
-						  const LLVector2* scale_factor);
-	static void cleanupClass();
+	void pushMatrix();
+	void popMatrix();
+	void loadIdentity();
+	void translate(F32 x, F32 y, F32 z = 0.0f);
 
-	static void pushMatrix();
-	static void popMatrix();
-	static void loadIdentity();
-	static void translate(F32 x, F32 y, F32 z = 0.0f);
+	void setLineWidth(F32 width);
+	void setScaleFactor(const LLVector2& scale_factor);
 
-	static void setLineWidth(F32 width);
-	static void setScaleFactor(const LLVector2& scale_factor);
+	LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0);
+	LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0);
 
-	static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0);
-	static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0);
+	LLVector2		mGLScaleFactor;
+
+protected:
+	// since LLRender2D has no control of image provider's lifecycle
+	// we need a way to tell LLRender2D that provider died and
+	// LLRender2D needs to be updated.
+	static void resetProvider();
 
-	static LLVector2		sGLScaleFactor;
 private:
-	static LLImageProviderInterface* sImageProvider;
+	LLImageProviderInterface* mImageProvider;
 };
 
 class LLImageProviderInterface
 {
 protected:
 	LLImageProviderInterface() {};
-	virtual ~LLImageProviderInterface() {};
+	virtual ~LLImageProviderInterface();
 public:
 	virtual LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority) = 0;
 	virtual LLPointer<LLUIImage> getUIImageByID(const LLUUID& id, S32 priority) = 0;
 	virtual void cleanUp() = 0;
+
+	// to notify holders when pointer gets deleted
+	typedef void(*callback_t)();
+	void addOnRemovalCallback(callback_t func);
+	void deleteOnRemovalCallback(callback_t func);
+
+private:
+
+	typedef std::list< callback_t >	callback_list_t;
+	callback_list_t mCallbackList;
 };
 
 
diff --git a/indra/llrender/lluiimage.cpp b/indra/llrender/lluiimage.cpp
index 5d8f92b2e6f87737a3612623fd0303385dcfbee8..c8337feabbc69e8fd985ebea177b0925c522104f 100644
--- a/indra/llrender/lluiimage.cpp
+++ b/indra/llrender/lluiimage.cpp
@@ -120,12 +120,12 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c
 		 }
 	}
 
-	LLRender2D::pushMatrix();
+	LLRender2D::getInstance()->pushMatrix();
 	{ 
 		LLVector3 rect_origin = origin_agent + (rect.mLeft * x_axis) + (rect.mBottom * y_axis); 
-		LLRender2D::translate(rect_origin.mV[VX],
-						rect_origin.mV[VY], 
-						rect_origin.mV[VZ]);
+		LLRender2D::getInstance()->translate(rect_origin.mV[VX],
+											rect_origin.mV[VY], 
+											rect_origin.mV[VZ]);
 		gGL.getTexUnit(0)->bind(getImage());
 		gGL.color4fv(color.mV);
 
@@ -142,7 +142,7 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c
 								rect.getWidth() * x_axis, 
 								rect.getHeight() * y_axis);
 		
-	} LLRender2D::popMatrix();
+	} LLRender2D::getInstance()->popMatrix();
 }
 
 
@@ -199,7 +199,7 @@ namespace LLInitParam
 			return;
 		}
 
-		LLUIImage* imagep =  LLRender2D::getUIImage(name());
+		LLUIImage* imagep =  LLRender2D::getInstance()->getUIImage(name());
 		if (imagep)
 		{
 			updateValue(imagep);
diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp
index eaf128423731da22add5a012daaaea3dd4acfe71..1034a219052f29b45ba4be46885f837573ec7c5d 100644
--- a/indra/llui/llaccordionctrltab.cpp
+++ b/indra/llui/llaccordionctrltab.cpp
@@ -977,7 +977,7 @@ void LLAccordionCtrlTab::drawChild(const LLRect& root_rect,LLView* child)
 		LLRect screen_rect;
 		localRectToScreen(child->getRect(),&screen_rect);
 		
-		if ( root_rect.overlaps(screen_rect)  && LLUI::sDirtyRect.overlaps(screen_rect))
+		if ( root_rect.overlaps(screen_rect)  && LLUI::getInstance()->mDirtyRect.overlaps(screen_rect))
 		{
 			gGL.matrixMode(LLRender::MM_MODELVIEW);
 			LLUI::pushMatrix();
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 6b7a8a8b860021a83a474a34944bb4aebf0ca257..27444b7f5b961c127558f9f124cd9c6de9689494 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -90,8 +90,8 @@ LLButton::Params::Params()
 	image_overlay_disabled_color("image_overlay_disabled_color", LLColor4::white % 0.3f),
 	image_overlay_selected_color("image_overlay_selected_color", LLColor4::white),
 	flash_color("flash_color"),
-	pad_right("pad_right", LLUI::sSettingGroups["config"]->getS32("ButtonHPad")),
-	pad_left("pad_left", LLUI::sSettingGroups["config"]->getS32("ButtonHPad")),
+	pad_right("pad_right", LLUI::getInstance()->mSettingGroups["config"]->getS32("ButtonHPad")),
+	pad_left("pad_left", LLUI::getInstance()->mSettingGroups["config"]->getS32("ButtonHPad")),
 	pad_bottom("pad_bottom"),
 	click_callback("click_callback"),
 	mouse_down_callback("mouse_down_callback"),
@@ -614,7 +614,7 @@ void LLButton::getOverlayImageSize(S32& overlay_width, S32& overlay_height)
 // virtual
 void LLButton::draw()
 {
-	static LLCachedControl<bool> sEnableButtonFlashing(*LLUI::sSettingGroups["config"], "EnableButtonFlashing", true);
+	static LLCachedControl<bool> sEnableButtonFlashing(*LLUI::getInstance()->mSettingGroups["config"], "EnableButtonFlashing", true);
 	F32 alpha = mUseDrawContextAlpha ? getDrawContext().mAlpha : getCurrentTransparency();
 
 	bool pressed_by_keyboard = FALSE;
@@ -628,7 +628,7 @@ void LLButton::draw()
 	{
 		S32 local_mouse_x ;
 		S32 local_mouse_y;
-		LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
+		LLUI::getInstance()->getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
 		mouse_pressed_and_over = pointInView(local_mouse_x, local_mouse_y);
 	}
 
@@ -1261,10 +1261,10 @@ void LLButton::showHelp(LLUICtrl* ctrl, const LLSD& sdname)
 	// search back through the button's parents for a panel
 	// with a help_topic string defined
 	std::string help_topic;
-	if (LLUI::sHelpImpl &&
+	if (LLUI::getInstance()->mHelpImpl &&
 	    ctrl->findHelpTopic(help_topic))
 	{
-		LLUI::sHelpImpl->showTopic(help_topic);
+		LLUI::getInstance()->mHelpImpl->showTopic(help_topic);
 		return; // success
 	}
 
diff --git a/indra/llui/llchatentry.cpp b/indra/llui/llchatentry.cpp
index dac001afabcf757be529aa00b85cd4b0491f021e..c50657612621d16b94134f7c49e1315eb0b019ee 100644
--- a/indra/llui/llchatentry.cpp
+++ b/indra/llui/llchatentry.cpp
@@ -201,7 +201,7 @@ BOOL LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			handled = TRUE;
 		}
@@ -225,7 +225,7 @@ BOOL LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			handled = TRUE;
 		}
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index b2ad38bddfb8e278112e0aaa2798eb763b29660e..c7f0326ed49f324b6d95187a444c365df1fc4489 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -668,7 +668,7 @@ void LLComboBox::showList()
 	mButton->setToggleState(TRUE);
 	mList->setVisible(TRUE);
 	
-	LLUI::addPopup(this);
+	LLUI::getInstance()->addPopup(this);
 
 	setUseBoundingRect(TRUE);
 //	updateBoundingRect();
@@ -694,7 +694,7 @@ void LLComboBox::hideList()
 		mList->mouseOverHighlightNthItem(-1);
 
 		setUseBoundingRect(FALSE);
-		LLUI::removePopup(this);
+		LLUI::getInstance()->removePopup(this);
 //		updateBoundingRect();
 	}
 }
diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp
index 26ae31cac660fbe4c0c1ef4909f2392bf00181a7..5f50e462336424cc88dfcf0473d9a09f01c3c7dc 100644
--- a/indra/llui/llconsole.cpp
+++ b/indra/llui/llconsole.cpp
@@ -68,7 +68,7 @@ LLConsole::LLConsole(const LLConsole::Params& p)
 		setFontSize(p.font_size_index);
 	}
 	mFadeTime = mLinePersistTime - FADE_DURATION;
-	setMaxLines(LLUI::sSettingGroups["config"]->getS32("ConsoleMaxLines"));
+	setMaxLines(LLUI::getInstance()->mSettingGroups["config"]->getS32("ConsoleMaxLines"));
 }
 
 void LLConsole::setLinePersistTime(F32 seconds)
@@ -180,7 +180,7 @@ void LLConsole::draw()
 
 	LLUIImagePtr imagep = LLUI::getUIImage("transparent");
 
-	F32 console_opacity = llclamp(LLUI::sSettingGroups["config"]->getF32("ConsoleBackgroundOpacity"), 0.f, 1.f);
+	F32 console_opacity = llclamp(LLUI::getInstance()->mSettingGroups["config"]->getF32("ConsoleBackgroundOpacity"), 0.f, 1.f);
 	LLColor4 color = LLUIColorTable::instance().getColor("ConsoleBackground");
 	color.mV[VALPHA] *= console_opacity;
 
diff --git a/indra/llui/llconsole.h b/indra/llui/llconsole.h
index 5ff05698b05b39cf5d95b463c56ef0071cae6e4f..04f5e716099335bf0495e1a0cf482116ef46f8ec 100644
--- a/indra/llui/llconsole.h
+++ b/indra/llui/llconsole.h
@@ -51,7 +51,7 @@ class LLConsole : public LLFixedBuffer, public LLUICtrl, public LLInstanceTracke
 		Optional<F32>	persist_time;
 		Optional<S32>	font_size_index;
 		Params()
-		:	max_lines("max_lines", LLUI::sSettingGroups["config"]->getS32("ConsoleMaxLines")),
+		:	max_lines("max_lines", LLUI::getInstance()->mSettingGroups["config"]->getS32("ConsoleMaxLines")),
 			persist_time("persist_time", 0.f), // forever
 			font_size_index("font_size_index")
 		{
diff --git a/indra/llui/llflashtimer.cpp b/indra/llui/llflashtimer.cpp
index 6d9c429b083b0775a3a3bc8d0d8f01fb8f734a6b..39793316f438db32e90ebaf0fcd3fba7b982e4d3 100644
--- a/indra/llui/llflashtimer.cpp
+++ b/indra/llui/llflashtimer.cpp
@@ -40,10 +40,10 @@ LLFlashTimer::LLFlashTimer(callback_t cb, S32 count, F32 period)
 	// By default use settings from settings.xml to be able change them via Debug settings. See EXT-5973.
 	// Due to Timer is implemented as derived class from EventTimer it is impossible to change period
 	// in runtime. So, both settings are made as required restart.
-	mFlashCount = 2 * ((count > 0) ? count : LLUI::sSettingGroups["config"]->getS32("FlashCount"));
+	mFlashCount = 2 * ((count > 0) ? count : LLUI::getInstance()->mSettingGroups["config"]->getS32("FlashCount"));
 	if (mPeriod <= 0)
 	{
-		mPeriod = LLUI::sSettingGroups["config"]->getF32("FlashPeriod");
+		mPeriod = LLUI::getInstance()->mSettingGroups["config"]->getF32("FlashPeriod");
 	}
 }
 
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index a245dd8f78b61aff032d15744d9496b237ccb92a..42802cd339cfece764cf1f62079919bcef0ebb86 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -215,14 +215,14 @@ void LLFloater::initClass()
 		sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] );
 	}
 
-	LLControlVariable* ctrl = LLUI::sSettingGroups["config"]->getControl("ActiveFloaterTransparency").get();
+    LLControlVariable* ctrl = LLUI::getInstance()->mSettingGroups["config"]->getControl("ActiveFloaterTransparency").get();
 	if (ctrl)
 	{
 		ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency));
 		updateActiveFloaterTransparency();
 	}
 
-	ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get();
+    ctrl = LLUI::getInstance()->mSettingGroups["config"]->getControl("InactiveFloaterTransparency").get();
 	if (ctrl)
 	{
 		ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency));
@@ -374,13 +374,13 @@ void LLFloater::layoutDragHandle()
 // static
 void LLFloater::updateActiveFloaterTransparency()
 {
-	sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency");
+    sActiveControlTransparency = LLUI::getInstance()->mSettingGroups["config"]->getF32("ActiveFloaterTransparency");
 }
 
 // static
 void LLFloater::updateInactiveFloaterTransparency()
 {
-	sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency");
+    sInactiveControlTransparency = LLUI::getInstance()->mSettingGroups["config"]->getF32("InactiveFloaterTransparency");
 }
 
 void LLFloater::addResizeCtrls()
@@ -579,7 +579,7 @@ std::string LLFloater::getControlName(const std::string& name, const LLSD& key)
 LLControlGroup*	LLFloater::getControlGroup()
 {
 	// Floater size, position, visibility, etc are saved in per-account settings.
-	return LLUI::sSettingGroups["account"];
+	return LLUI::getInstance()->mSettingGroups["account"];
 }
 
 void LLFloater::setVisible( BOOL visible )
@@ -592,7 +592,7 @@ void LLFloater::setVisible( BOOL visible )
 
 	if( !visible )
 	{
-		LLUI::removePopup(this);
+		LLUI::getInstance()->removePopup(this);
 
 		if( gFocusMgr.childHasMouseCapture( this ) )
 		{
@@ -818,7 +818,7 @@ void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent)
 
 void LLFloater::releaseFocus()
 {
-	LLUI::removePopup(this);
+	LLUI::getInstance()->removePopup(this);
 
 	setFocus(FALSE);
 
@@ -1771,13 +1771,13 @@ void LLFloater::onClickDock(LLFloater* self)
 // static
 void LLFloater::onClickHelp( LLFloater* self )
 {
-	if (self && LLUI::sHelpImpl)
+	if (self && LLUI::getInstance()->mHelpImpl)
 	{
 		// find the current help context for this floater
 		std::string help_topic;
 		if (self->findHelpTopic(help_topic))
 		{
-			LLUI::sHelpImpl->showTopic(help_topic);
+			LLUI::getInstance()->mHelpImpl->showTopic(help_topic);
 		}
 	}
 }
@@ -2931,7 +2931,7 @@ void LLFloaterView::syncFloaterTabOrder()
 	if (modal_dialog)
 	{
 		// If we have a visible modal dialog, make sure that it has focus
-		LLUI::addPopup(modal_dialog);
+		LLUI::getInstance()->addPopup(modal_dialog);
 		
 		if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) )
 		{
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index 9ef290abc024cd6629c876d12bad94ad768611b2..85e07fc6a6a0f2a3dd2a41c61e4bae891db5422b 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -445,7 +445,7 @@ void LLFloaterReg::registerControlVariables()
 		}
 	}
 
-	const LLSD& exclude_list = LLUI::sSettingGroups["config"]->getLLSD("always_showable_floaters");
+	const LLSD& exclude_list = LLUI::getInstance()->mSettingGroups["config"]->getLLSD("always_showable_floaters");
 	for (LLSD::array_const_iterator iter = exclude_list.beginArray();
 		iter != exclude_list.endArray();
 		iter++)
diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp
index 1b213c34186e7ee4d08ba30d5a04a3eab24d1877..7b0a6cbdaeb4124a93c19a3d534dfbc428737b54 100644
--- a/indra/llui/llfocusmgr.cpp
+++ b/indra/llui/llfocusmgr.cpp
@@ -183,7 +183,7 @@ void LLFocusMgr::releaseFocusIfNeeded( LLView* view )
 		}
 	}
 
-	LLUI::removePopup(view);
+	LLUI::getInstance()->removePopup(view);
 }
 
 void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL keystrokes_only)
@@ -481,7 +481,7 @@ void LLFocusMgr::setAppHasFocus(BOOL focus)
 	// release focus from "top ctrl"s, which generally hides them
 	if (!focus)
 	{
-		LLUI::clearPopups();
+		LLUI::getInstance()->clearPopups();
 	}
 	mAppHasFocus = focus; 
 }
diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp
index 895753aeae6394edc6e1383db58065a2ae593873..b05a9807d0801f8af5747d14fe07ea1d39e5aa8e 100644
--- a/indra/llui/llfolderview.cpp
+++ b/indra/llui/llfolderview.cpp
@@ -338,7 +338,7 @@ static LLTrace::BlockTimerStatHandle FTM_FILTER("Filter Folder View");
 void LLFolderView::filter( LLFolderViewFilter& filter )
 {
 	LL_RECORD_BLOCK_TIME(FTM_FILTER);
-    filter.resetTime(llclamp(LLUI::sSettingGroups["config"]->getS32(mParentPanel.get()->getVisible() ? "FilterItemsMaxTimePerFrameVisible" : "FilterItemsMaxTimePerFrameUnvisible"), 1, 100));
+    filter.resetTime(llclamp(LLUI::getInstance()->mSettingGroups["config"]->getS32(mParentPanel.get()->getVisible() ? "FilterItemsMaxTimePerFrameVisible" : "FilterItemsMaxTimePerFrameUnvisible"), 1, 100));
 
     // Note: we filter the model, not the view
 	getViewModelItem()->filter(filter);
@@ -657,7 +657,7 @@ void LLFolderView::draw()
 		closeAutoOpenedFolders();
 	}
 
-	if (mSearchTimer.getElapsedTimeF32() > LLUI::sSettingGroups["config"]->getF32("TypeAheadTimeout") || !mSearchString.size())
+	if (mSearchTimer.getElapsedTimeF32() > LLUI::getInstance()->mSettingGroups["config"]->getF32("TypeAheadTimeout") || !mSearchString.size())
 	{
 		mSearchString.clear();
 	}
@@ -733,7 +733,7 @@ void LLFolderView::closeRenamer( void )
 	if (mRenamer && mRenamer->getVisible())
 	{
 		// Triggers onRenamerLost() that actually closes the renamer.
-		LLUI::removePopup(mRenamer);
+		LLUI::getInstance()->removePopup(mRenamer);
 	}
 }
 
@@ -1064,7 +1064,7 @@ void LLFolderView::startRenamingSelectedItem( void )
 		// set focus will fail unless item is visible
 		mRenamer->setFocus( TRUE );
 		mRenamer->setTopLostCallback(boost::bind(&LLFolderView::onRenamerLost, this));
-		LLUI::addPopup(mRenamer);
+		LLUI::getInstance()->addPopup(mRenamer);
 	}
 }
 
@@ -1321,7 +1321,7 @@ BOOL LLFolderView::handleUnicodeCharHere(llwchar uni_char)
 		}
 
 		//do text search
-		if (mSearchTimer.getElapsedTimeF32() > LLUI::sSettingGroups["config"]->getF32("TypeAheadTimeout"))
+		if (mSearchTimer.getElapsedTimeF32() > LLUI::getInstance()->mSettingGroups["config"]->getF32("TypeAheadTimeout"))
 		{
 			mSearchString.clear();
 		}
@@ -1803,7 +1803,7 @@ void LLFolderView::updateRenamerPosition()
 		screenPointToLocal( x, y, &x, &y );
 		mRenamer->setOrigin( x, y );
 
-		LLRect scroller_rect(0, 0, (S32)LLUI::getWindowSize().mV[VX], 0);
+		LLRect scroller_rect(0, 0, (S32)LLUI::getInstance()->getWindowSize().mV[VX], 0);
 		if (mScrollContainer)
 		{
 			scroller_rect = mScrollContainer->getContentWindowRect();
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 0510e472c53da52dc8101da82ce3ecea17e01618..2de47f1a19152f0417b4b35f4ab6713ccaca55ec 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -548,7 +548,7 @@ BOOL LLFolderViewItem::handleMouseDown( S32 x, S32 y, MASK mask )
 
 BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask )
 {
-	static LLCachedControl<S32> drag_and_drop_threshold(*LLUI::sSettingGroups["config"],"DragAndDropDistanceThreshold", 3);
+	static LLCachedControl<S32> drag_and_drop_threshold(*LLUI::getInstance()->mSettingGroups["config"],"DragAndDropDistanceThreshold", 3);
 
 	mIsMouseOverTitle = (y > (getRect().getHeight() - mItemHeight));
 
diff --git a/indra/llui/llfolderviewmodel.cpp b/indra/llui/llfolderviewmodel.cpp
index 3363dc531652b54c66fb332efea086d20f928450..3b45fb53a2183ebfa99ea982aeae816e929dbe8e 100644
--- a/indra/llui/llfolderviewmodel.cpp
+++ b/indra/llui/llfolderviewmodel.cpp
@@ -48,7 +48,7 @@ std::string LLFolderViewModelCommon::getStatusText()
 
 void LLFolderViewModelCommon::filter()
 {
-    getFilter().resetTime(llclamp(LLUI::sSettingGroups["config"]->getS32("FilterItemsMaxTimePerFrameVisible"), 1, 100));
+    getFilter().resetTime(llclamp(LLUI::getInstance()->mSettingGroups["config"]->getS32("FilterItemsMaxTimePerFrameVisible"), 1, 100));
 	mFolderView->getViewModelItem()->filter(getFilter());
 }
 
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 955e7089f464d5b9ef43eab2dfcc9d58cb5e87d8..4a464b3507ccbd79c1b9cbf6099200ed5a7aa344 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -209,7 +209,7 @@ LLLayoutStack::Params::Params()
 	open_time_constant("open_time_constant", 0.02f),
 	close_time_constant("close_time_constant", 0.03f),
 	resize_bar_overlap("resize_bar_overlap", 1),
-	border_size("border_size", LLCachedControl<S32>(*LLUI::sSettingGroups["config"], "UIResizeBarHeight", 0)),
+	border_size("border_size", LLCachedControl<S32>(*LLUI::getInstance()->mSettingGroups["config"], "UIResizeBarHeight", 0)),
 	show_drag_handle("show_drag_handle", false),
 	drag_handle_first_indent("drag_handle_first_indent", 0),
 	drag_handle_second_indent("drag_handle_second_indent", 0),
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index ff8bf3031900bd5b646b4f2bfb9b68f1291b307c..3ad504d68da3b88647774489ca83a45b83fbaae0 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -941,7 +941,7 @@ void LLLineEditor::removeChar()
 	}
 	else
 	{
-		LLUI::reportBadKeystroke();
+		LLUI::getInstance()->reportBadKeystroke();
 	}
 }
 
@@ -992,7 +992,7 @@ void LLLineEditor::addChar(const llwchar uni_char)
 	}
 	else
 	{
-		LLUI::reportBadKeystroke();
+		LLUI::getInstance()->reportBadKeystroke();
 	}
 
 	getWindow()->hideCursorUntilMouseMove();
@@ -1088,7 +1088,7 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			break;
 
@@ -1104,7 +1104,7 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			break;
 
@@ -1184,7 +1184,7 @@ void LLLineEditor::cut()
 		if( need_to_rollback )
 		{
 			rollback.doRollback( this );
-			LLUI::reportBadKeystroke();
+			LLUI::getInstance()->reportBadKeystroke();
 		}
 		else
 		{
@@ -1288,7 +1288,7 @@ void LLLineEditor::pasteHelper(bool is_primary)
 				}
 				// Truncate the clean string at the limit of what will fit
 				clean_string = clean_string.substr(0, wchars_that_fit);
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 
 			if (mMaxLengthChars)
@@ -1300,7 +1300,7 @@ void LLLineEditor::pasteHelper(bool is_primary)
 					clean_string = clean_string.substr(0, available_chars);
 				}
 
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 
 			mText.insert(getCursor(), clean_string);
@@ -1312,7 +1312,7 @@ void LLLineEditor::pasteHelper(bool is_primary)
 			if( need_to_rollback )
 			{
 				rollback.doRollback( this );
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			else
 			{
@@ -1376,7 +1376,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 		}
 		handled = TRUE;
@@ -1425,7 +1425,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			handled = TRUE;
 		}
@@ -1452,7 +1452,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			handled = TRUE;
 		}
@@ -1469,7 +1469,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			handled = TRUE;
 		}
@@ -1486,7 +1486,7 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
 			}
 			else
 			{
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 			handled = TRUE;
 		}
@@ -1567,7 +1567,7 @@ BOOL LLLineEditor::handleKeyHere(KEY key, MASK mask )
 			{
 				rollback.doRollback(this);
 
-				LLUI::reportBadKeystroke();
+				LLUI::getInstance()->reportBadKeystroke();
 			}
 
 			// Notify owner if requested
@@ -1623,7 +1623,7 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char)
 		{
 			rollback.doRollback( this );
 
-			LLUI::reportBadKeystroke();
+			LLUI::getInstance()->reportBadKeystroke();
 		}
 
 		// Notify owner if requested
@@ -1674,7 +1674,7 @@ void LLLineEditor::doDelete()
 		if( need_to_rollback )
 		{
 			rollback.doRollback( this );
-			LLUI::reportBadKeystroke();
+			LLUI::getInstance()->reportBadKeystroke();
 		}
 		else
 		{
@@ -2478,7 +2478,7 @@ BOOL LLLineEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
 	{
 		LLRect control_rect_screen;
 		localRectToScreen(getRect(), &control_rect_screen);
-		LLUI::screenRectToGL(control_rect_screen, control);
+		LLUI::getInstance()->screenRectToGL(control_rect_screen, control);
 	}
 
 	S32 preedit_left_column, preedit_right_column;
@@ -2508,7 +2508,7 @@ BOOL LLLineEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
 		S32 query_local = findPixelNearestPos(query - getCursor());
 		S32 query_screen_x, query_screen_y;
 		localPointToScreen(query_local, getRect().getHeight() / 2, &query_screen_x, &query_screen_y);
-		LLUI::screenPointToGL(query_screen_x, query_screen_y, &coord->mX, &coord->mY);
+		LLUI::getInstance()->screenPointToGL(query_screen_x, query_screen_y, &coord->mX, &coord->mY);
 	}
 
 	if (bounds)
@@ -2524,7 +2524,7 @@ BOOL LLLineEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
 		LLRect preedit_rect_local(preedit_left_local, getRect().getHeight(), preedit_right_local, 0);
 		LLRect preedit_rect_screen;
 		localRectToScreen(preedit_rect_local, &preedit_rect_screen);
-		LLUI::screenRectToGL(preedit_rect_screen, bounds);
+		LLUI::getInstance()->screenRectToGL(preedit_rect_screen, bounds);
 	}
 
 	return TRUE;
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 676c94468f44aa906cf79c74e66607c0b30f2c64..732fa9feb1c103b2623142531049a6891e99fc9f 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -3269,7 +3269,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
 	menu->needsArrange();
 	menu->arrangeAndClear();
 
-	LLUI::getMousePositionLocal(menu->getParent(), &mouse_x, &mouse_y);
+	LLUI::getInstance()->getMousePositionLocal(menu->getParent(), &mouse_x, &mouse_y);
 	LLMenuHolderGL::sContextMenuSpawnPos.set(mouse_x,mouse_y);
 
 	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getRect();
diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp
index 8cf88ad5ebceba80d90c123bdb081925a4b7e2eb..5cfa8ea9738cbe7ac36678a57fd8edbca6946685 100644
--- a/indra/llui/llmodaldialog.cpp
+++ b/indra/llui/llmodaldialog.cpp
@@ -105,7 +105,7 @@ void LLModalDialog::onOpen(const LLSD& key)
 	
 		// This is a modal dialog.  It sucks up all mouse and keyboard operations.
 		gFocusMgr.setMouseCapture( this );
-		LLUI::addPopup(this);
+		LLUI::getInstance()->addPopup(this);
 		setFocus(TRUE);
 
 		sModalStack.push_front( this );
@@ -147,7 +147,7 @@ void LLModalDialog::setVisible( BOOL visible )
 			gFocusMgr.setMouseCapture( this );
 
 			// The dialog view is a root view
-			LLUI::addPopup(this);
+			LLUI::getInstance()->addPopup(this);
 			setFocus( TRUE );
 		}
 		else
@@ -165,7 +165,7 @@ BOOL LLModalDialog::handleMouseDown(S32 x, S32 y, MASK mask)
 	if (popup_menu != NULL)
 	{
 		S32 mx, my;
-		LLUI::getMousePositionScreen(&mx, &my);
+		LLUI::getInstance()->getMousePositionScreen(&mx, &my);
 		LLRect menu_screen_rc = popup_menu->calcScreenRect();
 		if(!menu_screen_rc.pointInRect(mx, my))
 		{
@@ -202,7 +202,7 @@ BOOL LLModalDialog::handleHover(S32 x, S32 y, MASK mask)
 	if (popup_menu != NULL)
 	{
 		S32 mx, my;
-		LLUI::getMousePositionScreen(&mx, &my);
+		LLUI::getInstance()->getMousePositionScreen(&mx, &my);
 		LLRect menu_screen_rc = popup_menu->calcScreenRect();
 		if(menu_screen_rc.pointInRect(mx, my))
 		{
@@ -286,7 +286,7 @@ void LLModalDialog::draw()
 
 void LLModalDialog::centerOnScreen()
 {
-	LLVector2 window_size = LLUI::getWindowSize();
+	LLVector2 window_size = LLUI::getInstance()->getWindowSize();
 	centerWithin(LLRect(0, 0, ll_round(window_size.mV[VX]), ll_round(window_size.mV[VY])));
 }
 
@@ -316,7 +316,7 @@ void LLModalDialog::onAppFocusGained()
 		// This is a modal dialog.  It sucks up all mouse and keyboard operations.
 		gFocusMgr.setMouseCapture( instance );
 		instance->setFocus(TRUE);
-		LLUI::addPopup(instance);
+		LLUI::getInstance()->addPopup(instance);
 
 		instance->centerOnScreen();
 	}
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index 2e6dc6731b700992203c2022d0e94bae3176792c..6a7075301bea873a472c71d21fb0538d79ae1d49 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -131,7 +131,7 @@ bool handleIgnoredNotification(const LLSD& payload)
 			response = pNotif->getResponseTemplate(LLNotification::WITH_DEFAULT_BUTTON);
 			break;
 		case LLNotificationForm::IGNORE_WITH_LAST_RESPONSE:
-			response = LLUI::sSettingGroups["ignores"]->getLLSD("Default" + pNotif->getName());
+			response = LLUI::getInstance()->mSettingGroups["ignores"]->getLLSD("Default" + pNotif->getName());
 			break;
 		case LLNotificationForm::IGNORE_SHOW_AGAIN:
 			break;
@@ -199,6 +199,7 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotifica
 		// For all cases but IGNORE_CHECKBOX_ONLY this is name for use in preferences
 		mIgnoreMsg = p.ignore.text;
 
+		LLUI *ui_inst = LLUI::getInstance();
 		if (p.ignore.checkbox_only)
 		{
 			mIgnore = IGNORE_CHECKBOX_ONLY;
@@ -211,19 +212,19 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotifica
 		{
 			// remember last option chosen by user and automatically respond with that in the future
 			mIgnore = IGNORE_WITH_LAST_RESPONSE;
-			LLUI::sSettingGroups["ignores"]->declareLLSD(std::string("Default") + name, "", std::string("Default response for notification " + name));
+			ui_inst->mSettingGroups["ignores"]->declareLLSD(std::string("Default") + name, "", std::string("Default response for notification " + name));
 		}
 
 		BOOL show_notification = TRUE;
 		if (p.ignore.control.isProvided())
 		{
-			mIgnoreSetting = LLUI::sSettingGroups["config"]->getControl(p.ignore.control);
+			mIgnoreSetting = ui_inst->mSettingGroups["config"]->getControl(p.ignore.control);
 			mInvertSetting = p.ignore.invert_control;
 		}
 		else if (mIgnore > IGNORE_NO)
 		{
-			LLUI::sSettingGroups["ignores"]->declareBOOL(name, show_notification, "Show notification with this name", LLControlVariable::PERSIST_NONDFT);
-			mIgnoreSetting = LLUI::sSettingGroups["ignores"]->getControl(name);
+			ui_inst->mSettingGroups["ignores"]->declareBOOL(name, show_notification, "Show notification with this name", LLControlVariable::PERSIST_NONDFT);
+			mIgnoreSetting = ui_inst->mSettingGroups["ignores"]->getControl(name);
 		}
 	}
 
@@ -437,7 +438,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
     mSoundName("")
 {
 	if (p.sound.isProvided()
-		&& LLUI::sSettingGroups["config"]->controlExists(p.sound))
+		&& LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound))
 	{
 		mSoundName = p.sound;
 	}
@@ -705,7 +706,7 @@ void LLNotification::respond(const LLSD& response)
 		mForm->setIgnored(mIgnored);
 		if (mIgnored && mForm->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
 		{
-			LLUI::sSettingGroups["ignores"]->setLLSD("Default" + getName(), response);
+			LLUI::getInstance()->mSettingGroups["ignores"]->setLLSD("Default" + getName(), response);
 		}
 	}
 
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index ee905741617a9b7c95138b2971a97916e223664a..00da0f5fec5075786163aecff9bffa7b0066fdbc 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -609,7 +609,7 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form
 		return formatted_string.getString();
 	}
 	std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate
-	if(LLUI::sSettingGroups["config"]->getBOOL("QAMode"))
+	if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode"))
 	{
 		LL_ERRS() << err_str << LL_ENDL;
 	}
@@ -628,7 +628,7 @@ std::string LLPanel::getString(const std::string& name) const
 		return found_it->second;
 	}
 	std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate
-	if(LLUI::sSettingGroups["config"]->getBOOL("QAMode"))
+	if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode"))
 	{
 		LL_ERRS() << err_str << LL_ENDL;
 	}
diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp
index 25daf9db8bea398cf66ecb4f00c5675ce8e446ab..fde6de49219bc6acc031d1293bf462ac054651fd 100644
--- a/indra/llui/llscrollbar.cpp
+++ b/indra/llui/llscrollbar.cpp
@@ -84,7 +84,7 @@ LLScrollbar::LLScrollbar(const Params & p)
 		mThumbImageH(p.thumb_image_horizontal),
 		mTrackImageV(p.track_image_vertical),
 		mTrackImageH(p.track_image_horizontal),
-		mThickness(p.thickness.isProvided() ? p.thickness : LLUI::sSettingGroups["config"]->getS32("UIScrollbarSize")),
+		mThickness(p.thickness.isProvided() ? p.thickness : LLUI::getInstance()->mSettingGroups["config"]->getS32("UIScrollbarSize")),
 		mBGVisible(p.bg_visible),
 		mBGColor(p.bg_color)
 {
@@ -498,7 +498,7 @@ void LLScrollbar::draw()
 
 	S32 local_mouse_x;
 	S32 local_mouse_y;
-	LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
+	LLUI::getInstance()->getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
 	BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this;
 	BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y));
 	if (hovered)
@@ -655,5 +655,5 @@ void LLScrollbar::onLineDownBtnPressed( const LLSD& data )
 
 void LLScrollbar::setThickness(S32 thickness)
 {
-	mThickness = thickness < 0 ? LLUI::sSettingGroups["config"]->getS32("UIScrollbarSize") : thickness;
+	mThickness = thickness < 0 ? LLUI::getInstance()->mSettingGroups["config"]->getS32("UIScrollbarSize") : thickness;
 }
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp
index 7f64743e99070cd5d8f461d7b50ba4f6dffa96f1..296ea0907931d230e428c7e1355c578413855cc1 100644
--- a/indra/llui/llspellcheck.cpp
+++ b/indra/llui/llspellcheck.cpp
@@ -44,7 +44,6 @@ static const std::string DICT_FILE_IGNORE = "user_ignore.dic";
 static const std::string DICT_FILE_MAIN = "dictionaries.xml";
 static const std::string DICT_FILE_USER = "user_dictionaries.xml";
 
-LLSD LLSpellChecker::sDictMap;
 LLSpellChecker::settings_change_signal_t LLSpellChecker::sSettingsChangeSignal;
 
 LLSpellChecker::LLSpellChecker()
@@ -94,10 +93,9 @@ S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector<std::str
 	return suggestions.size();
 }
 
-// static
 const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_language)
 {
-	for (LLSD::array_const_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
+	for (LLSD::array_const_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it)
 	{
 		const LLSD& dict_entry = *it;
 		if (dict_language == dict_entry["language"].asString())
@@ -108,14 +106,12 @@ const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_language)
 	return LLSD();
 }
 
-// static
 bool LLSpellChecker::hasDictionary(const std::string& dict_language, bool check_installed)
 {
 	const LLSD dict_info = getDictionaryData(dict_language);
 	return dict_info.has("language") && ( (!check_installed) || (dict_info["installed"].asBoolean()) );
 }
 
-// static
 void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
 {
 	const std::string dict_language = dict_info["language"].asString();
@@ -124,7 +120,7 @@ void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
 		return;
 	}
 
-	for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
+	for (LLSD::array_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it)
 	{
 		LLSD& dict_entry = *it;
 		if (dict_language == dict_entry["language"].asString())
@@ -133,7 +129,7 @@ void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
 			return;
 		}
 	}
-	sDictMap.append(dict_info);
+	mDictMap.append(dict_info);
 	return;
 }
 
@@ -147,14 +143,14 @@ void LLSpellChecker::refreshDictionaryMap()
     std::string user_filename(user_path + DICT_FILE_MAIN);
 	llifstream user_file(user_filename.c_str(), std::ios::binary);
 	if ( (!user_file.is_open()) 
-		|| (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(sDictMap, user_file)) 
-		|| (0 == sDictMap.size()) )
+		|| (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(mDictMap, user_file)) 
+		|| (0 == mDictMap.size()) )
 	{
         std::string app_filename(app_path + DICT_FILE_MAIN);
 		llifstream app_file(app_filename.c_str(), std::ios::binary);
 		if ( (!app_file.is_open()) 
-			|| (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(sDictMap, app_file)) 
-			|| (0 == sDictMap.size()) )
+			|| (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(mDictMap, app_file)) 
+			|| (0 == mDictMap.size()) )
 		{
 			return;
 		}
@@ -178,7 +174,7 @@ void LLSpellChecker::refreshDictionaryMap()
 
 	// Look for installed dictionaries
 	std::string tmp_app_path, tmp_user_path;
-	for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
+	for (LLSD::array_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it)
 	{
 		LLSD& sdDict = *it;
 		tmp_app_path = (sdDict.has("name")) ? app_path + sdDict["name"].asString() : LLStringUtil::null;
@@ -416,7 +412,6 @@ bool LLSpellChecker::getUseSpellCheck()
 	return (LLSpellChecker::instanceExists()) && (LLSpellChecker::instance().mHunspell);
 }
 
-// static
 bool LLSpellChecker::canRemoveDictionary(const std::string& dict_language)
 {
 	// Only user-installed inactive dictionaries can be removed
@@ -426,7 +421,6 @@ bool LLSpellChecker::canRemoveDictionary(const std::string& dict_language)
 		( (!getUseSpellCheck()) || (!LLSpellChecker::instance().isActiveDictionary(dict_language)) );
 }
 
-// static
 void LLSpellChecker::removeDictionary(const std::string& dict_language)
 {
 	if (!canRemoveDictionary(dict_language))
@@ -499,12 +493,3 @@ void LLSpellChecker::setUseSpellCheck(const std::string& dict_language)
 		LLSpellChecker::instance().initHunspell(dict_language);
 	}
 }
-
-// static
-void LLSpellChecker::initClass()
-{
-	if (sDictMap.isUndefined())
-	{
-		refreshDictionaryMap();
-	}
-}
diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h
index acac589e433dd8d33c452641c1638bb751199559..f1964cc091940f6e03513f9143c79b22b5fc5e23 100644
--- a/indra/llui/llspellcheck.h
+++ b/indra/llui/llspellcheck.h
@@ -34,10 +34,9 @@
 
 class Hunspell;
 
-class LLSpellChecker : public LLSingleton<LLSpellChecker>, public LLInitClass<LLSpellChecker>
+class LLSpellChecker : public LLSingleton<LLSpellChecker>
 {
 	LLSINGLETON(LLSpellChecker);
-	friend class LLInitClass<LLSpellChecker>;
 	~LLSpellChecker();
 
 public:
@@ -57,26 +56,24 @@ class LLSpellChecker : public LLSingleton<LLSpellChecker>, public LLInitClass<LL
 	bool				isActiveDictionary(const std::string& dict_language) const;
 	void				setSecondaryDictionaries(dict_list_t dict_list);
 
-	static bool				 canRemoveDictionary(const std::string& dict_language);
+	bool					 canRemoveDictionary(const std::string& dict_language);
 	static const std::string getDictionaryAppPath();
 	static const std::string getDictionaryUserPath();
-	static const LLSD		 getDictionaryData(const std::string& dict_language);
-	static const LLSD&		 getDictionaryMap() { return sDictMap; }
+	const LLSD				 getDictionaryData(const std::string& dict_language);
+	const LLSD&				 getDictionaryMap() { return mDictMap; }
 	static bool				 getUseSpellCheck();
-	static bool				 hasDictionary(const std::string& dict_language, bool check_installed = false);
-	static void				 refreshDictionaryMap();
-	static void				 removeDictionary(const std::string& dict_language);
+	bool					 hasDictionary(const std::string& dict_language, bool check_installed = false);
+	void					 refreshDictionaryMap();
+	void					 removeDictionary(const std::string& dict_language);
 	static void				 setUseSpellCheck(const std::string& dict_language);
 protected:
 	static LLSD				 loadUserDictionaryMap();
-	static void				 setDictionaryData(const LLSD& dict_info);
+	void					 setDictionaryData(const LLSD& dict_info);
 	static void				 saveUserDictionaryMap(const LLSD& dict_map);
 
 public:
 	typedef boost::signals2::signal<void()> settings_change_signal_t;
 	static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb);
-protected:
-	static void initClass();
 
 protected:
 	Hunspell*	mHunspell;
@@ -84,8 +81,8 @@ class LLSpellChecker : public LLSingleton<LLSpellChecker>, public LLInitClass<LL
 	std::string	mDictFile;
 	dict_list_t	mDictSecondary;
 	std::vector<std::string> mIgnoreList;
+	LLSD mDictMap;
 
-	static LLSD						sDictMap;
 	static settings_change_signal_t	sSettingsChangeSignal;
 };
 
diff --git a/indra/llui/llstatview.cpp b/indra/llui/llstatview.cpp
index eda2d6047f4c755686eaf954801692fd1a5bd35e..bb4969c81f1d74c2f86c206b909f6fc6872225d7 100644
--- a/indra/llui/llstatview.cpp
+++ b/indra/llui/llstatview.cpp
@@ -43,7 +43,7 @@ LLStatView::LLStatView(const LLStatView::Params& p)
 	BOOL isopen = getDisplayChildren();
 	if (mSetting.length() > 0)
 	{
-		isopen = LLUI::sSettingGroups["config"]->getBOOL(mSetting);
+		isopen = LLUI::getInstance()->mSettingGroups["config"]->getBOOL(mSetting);
 	}
 	setDisplayChildren(isopen);
 }
@@ -54,7 +54,7 @@ LLStatView::~LLStatView()
 	if (mSetting.length() > 0)
 	{
 		BOOL isopen = getDisplayChildren();
-		LLUI::sSettingGroups["config"]->setBOOL(mSetting, isopen);
+		LLUI::getInstance()->mSettingGroups["config"]->setBOOL(mSetting, isopen);
 	}
 }
 
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 00443a16b2ea322aa4aaa9b82f15f2197faa6b51..e64078828b813e8a6fa0ddc3f9ecc65a2da1b9f3 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -3247,7 +3247,7 @@ BOOL LLNormalTextSegment::handleHover(S32 x, S32 y, MASK mask)
 		// Only process the click if it's actually in this segment, not to the right of the end-of-line.
 		if(mEditor.getSegmentAtLocalPos(x, y, false) == this)
 		{
-			LLUI::getWindow()->setCursor(UI_CURSOR_HAND);
+			LLUI::getInstance()->getWindow()->setCursor(UI_CURSOR_HAND);
 			return TRUE;
 		}
 	}
diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp
index 9faff1278de8ffcfb3d1f3786b8d84f7034dbb73..0afd32f33279bde6fbbe67ea9d2e21e39951eaec 100644
--- a/indra/llui/lltextbox.cpp
+++ b/indra/llui/lltextbox.cpp
@@ -107,7 +107,7 @@ BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask)
 	if (!handled && mClickedCallback && mShowCursorHand)
 	{
 		// Clickable text boxes change the cursor to a hand
-		LLUI::getWindow()->setCursor(UI_CURSOR_HAND);
+		LLUI::getInstance()->getWindow()->setCursor(UI_CURSOR_HAND);
 		return TRUE;
 	}
 	return handled;
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 137167db2adcdc75db2cf7a1f5b3f3cc769b5fe5..b1f8b00cab18a9f09d7b634239bc87f6111c73c2 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -1045,7 +1045,7 @@ void LLTextEditor::removeCharOrTab()
 	}
 	else
 	{
-		LLUI::reportBadKeystroke();
+		LLUI::getInstance()->reportBadKeystroke();
 	}
 }
 
@@ -1068,7 +1068,7 @@ void LLTextEditor::removeChar()
 	}
 	else
 	{
-		LLUI::reportBadKeystroke();
+		LLUI::getInstance()->reportBadKeystroke();
 	}
 }
 
@@ -1315,7 +1315,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask)
 				}
 				else
 				{
-					LLUI::reportBadKeystroke();
+					LLUI::getInstance()->reportBadKeystroke();
 				}
 			}
 			break;
@@ -1333,7 +1333,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask)
 				}
 				else
 				{
-					LLUI::reportBadKeystroke();
+					LLUI::getInstance()->reportBadKeystroke();
 				}
 			}	
 			break;
@@ -1665,7 +1665,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask)
 		}
 		else
 		{
-			LLUI::reportBadKeystroke();
+			LLUI::getInstance()->reportBadKeystroke();
 		}
 		break;
 
@@ -2750,7 +2750,7 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
 	{
 		LLRect control_rect_screen;
 		localRectToScreen(mVisibleTextRect, &control_rect_screen);
-		LLUI::screenRectToGL(control_rect_screen, control);
+		LLUI::getInstance()->screenRectToGL(control_rect_screen, control);
 	}
 
 	S32 preedit_left_position, preedit_right_position;
@@ -2804,7 +2804,7 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
 		const S32 query_y = mVisibleTextRect.mTop - (current_line - first_visible_line) * line_height - line_height / 2;
 		S32 query_screen_x, query_screen_y;
 		localPointToScreen(query_x, query_y, &query_screen_x, &query_screen_y);
-		LLUI::screenPointToGL(query_screen_x, query_screen_y, &coord->mX, &coord->mY);
+		LLUI::getInstance()->screenPointToGL(query_screen_x, query_screen_y, &coord->mX, &coord->mY);
 	}
 
 	if (bounds)
@@ -2831,7 +2831,7 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
 		const LLRect preedit_rect_local(preedit_left, preedit_top, preedit_right, preedit_bottom);
 		LLRect preedit_rect_screen;
 		localRectToScreen(preedit_rect_local, &preedit_rect_screen);
-		LLUI::screenRectToGL(preedit_rect_screen, bounds);
+		LLUI::getInstance()->screenRectToGL(preedit_rect_screen, bounds);
 	}
 
 	return TRUE;
diff --git a/indra/llui/lltextutil.cpp b/indra/llui/lltextutil.cpp
index f6b2ee1dc0942676a7aff18d3ca8037021f6913e..538508b856d98dcd29c7b8288d83f9935a117665 100644
--- a/indra/llui/lltextutil.cpp
+++ b/indra/llui/lltextutil.cpp
@@ -78,7 +78,7 @@ void LLTextUtil::textboxSetGreyedVal(LLTextBox *txtbox, const LLStyle::Params& n
 
 const std::string& LLTextUtil::formatPhoneNumber(const std::string& phone_str)
 {
-	static const std::string PHONE_SEPARATOR = LLUI::sSettingGroups["config"]->getString("AvalinePhoneSeparator");
+	static const std::string PHONE_SEPARATOR = LLUI::getInstance()->mSettingGroups["config"]->getString("AvalinePhoneSeparator");
 	static const S32 PHONE_PART_LEN = 2;
 
 	static std::string formatted_phone_str;
diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp
index ccb92ffbb2a6a944660b7cb8b52f0b949df25bba..3e56e0a589c7b7a27ae419e01ea820d2ff1080e3 100644
--- a/indra/llui/lltoggleablemenu.cpp
+++ b/indra/llui/lltoggleablemenu.cpp
@@ -55,7 +55,7 @@ boost::signals2::connection LLToggleableMenu::setVisibilityChangeCallback(const
 void LLToggleableMenu::onVisibilityChange (BOOL curVisibilityIn)
 {
 	S32 x,y;
-	LLUI::getMousePositionLocal(LLUI::getRootView(), &x, &y);
+	LLUI::getInstance()->getMousePositionLocal(LLUI::getInstance()->getRootView(), &x, &y);
 
 	// STORM-1879: also check MouseCapture to see if the button was really
         // clicked (otherwise the VisibilityChange was triggered via keyboard shortcut)
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index abc2b6e9cac2025efa9983566c81e7d9a81d99d1..e6f466ec784b9f1c5dbf90ede4a64d17dfd6f820 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -1125,7 +1125,7 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask)
 	BOOL handled = FALSE;
 		
 	S32 mouse_distance_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY);
-	S32 drag_threshold = LLUI::sSettingGroups["config"]->getS32("DragAndDropDistanceThreshold");
+	S32 drag_threshold = LLUI::getInstance()->mSettingGroups["config"]->getS32("DragAndDropDistanceThreshold");
 	if (mouse_distance_squared > drag_threshold * drag_threshold
 		&& hasMouseCapture() && 
 		mStartDragItemCallback && mHandleDragItemCallback)
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index 698b128d45d079c8d7633bd38977c480000835a2..422534b781125bb4dbc0abd3b26e497c4d212476 100644
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -145,10 +145,10 @@ LLToolTip::Params::Params()
 	wrap("wrap", true),
 	pos("pos"),
 	message("message"),
-	delay_time("delay_time", LLUI::sSettingGroups["config"]->getF32( "ToolTipDelay" )),
-	visible_time_over("visible_time_over", LLUI::sSettingGroups["config"]->getF32( "ToolTipVisibleTimeOver" )),
-	visible_time_near("visible_time_near", LLUI::sSettingGroups["config"]->getF32( "ToolTipVisibleTimeNear" )),
-	visible_time_far("visible_time_far", LLUI::sSettingGroups["config"]->getF32( "ToolTipVisibleTimeFar" )),
+	delay_time("delay_time", LLUI::getInstance()->mSettingGroups["config"]->getF32( "ToolTipDelay" )),
+	visible_time_over("visible_time_over", LLUI::getInstance()->mSettingGroups["config"]->getF32( "ToolTipVisibleTimeOver" )),
+	visible_time_near("visible_time_near", LLUI::getInstance()->mSettingGroups["config"]->getF32( "ToolTipVisibleTimeNear" )),
+	visible_time_far("visible_time_far", LLUI::getInstance()->mSettingGroups["config"]->getF32( "ToolTipVisibleTimeFar" )),
 	sticky_rect("sticky_rect"),
 	image("image"),
 	text_color("text_color"),
@@ -358,7 +358,7 @@ void LLToolTip::draw()
 
 	if (mFadeTimer.getStarted())
 	{
-		F32 tool_tip_fade_time = LLUI::sSettingGroups["config"]->getF32("ToolTipFadeTime");
+		F32 tool_tip_fade_time = LLUI::getInstance()->mSettingGroups["config"]->getF32("ToolTipFadeTime");
 		alpha = clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, tool_tip_fade_time, 1.f, 0.f);
 		if (alpha == 0.f)
 		{
@@ -436,12 +436,12 @@ void LLToolTipMgr::createToolTip(const LLToolTip::Params& params)
 	{
 		LLCoordGL pos = params.pos;
 		// try to spawn at requested position
-		LLUI::positionViewNearMouse(mToolTip, pos.mX, pos.mY);
+		LLUI::getInstance()->positionViewNearMouse(mToolTip, pos.mX, pos.mY);
 	}
 	else
 	{
 		// just spawn at mouse location
-		LLUI::positionViewNearMouse(mToolTip);
+		LLUI::getInstance()->positionViewNearMouse(mToolTip);
 	}
 
 	//...update "sticky" rect and tooltip position
@@ -453,7 +453,7 @@ void LLToolTipMgr::createToolTip(const LLToolTip::Params& params)
 	{
 		S32 mouse_x;
 		S32 mouse_y;
-		LLUI::getMousePositionLocal(gToolTipView->getParent(), &mouse_x, &mouse_y);
+		LLUI::getInstance()->getMousePositionLocal(gToolTipView->getParent(), &mouse_x, &mouse_y);
 
 		// allow mouse a little bit of slop before changing tooltips
 		mMouseNearRect.setCenterAndSize(mouse_x, mouse_y, 3, 3);
@@ -491,7 +491,7 @@ void LLToolTipMgr::show(const LLToolTip::Params& params)
 	
 	// are we ready to show the tooltip?
 	if (!mToolTipsBlocked									// we haven't hit a key, moved the mouse, etc.
-		&& LLUI::getMouseIdleTime() > params_with_defaults.delay_time)	// the mouse has been still long enough
+		&& LLUI::getInstance()->getMouseIdleTime() > params_with_defaults.delay_time)	// the mouse has been still long enough
 	{
 		bool tooltip_changed = mLastToolTipParams.message() != params_with_defaults.message()
 								|| mLastToolTipParams.pos() != params_with_defaults.pos()
@@ -563,7 +563,7 @@ void LLToolTipMgr::updateToolTipVisibility()
 	}
 
 	// hide tooltips when mouse cursor is hidden
-	if (LLUI::getWindow()->isCursorHidden())
+	if (LLUI::getInstance()->getWindow()->isCursorHidden())
 	{
 		blockToolTips();
 		return;
@@ -574,7 +574,7 @@ void LLToolTipMgr::updateToolTipVisibility()
 	if (toolTipVisible())
 	{
 		S32 mouse_x, mouse_y;
-		LLUI::getMousePositionLocal(gToolTipView, &mouse_x, &mouse_y);
+		LLUI::getInstance()->getMousePositionLocal(gToolTipView, &mouse_x, &mouse_y);
 		
 		// mouse far away from tooltip
 		tooltip_timeout = mLastToolTipParams.visible_time_far;
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 52190a1473075551889137246b77aba583448583..656b69d3ed50ba0d3d9876a23afff9d3fbe94431 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -75,19 +75,6 @@
 // Language for UI construction
 std::map<std::string, std::string> gTranslation;
 std::list<std::string> gUntranslated;
-/*static*/ LLUI::settings_map_t LLUI::sSettingGroups;
-/*static*/ LLUIAudioCallback LLUI::sAudioCallback = NULL;
-/*static*/ LLUIAudioCallback LLUI::sDeferredAudioCallback = NULL;
-/*static*/ LLWindow*		LLUI::sWindow = NULL;
-/*static*/ LLView*			LLUI::sRootView = NULL;
-/*static*/ BOOL                         LLUI::sDirty = FALSE;
-/*static*/ LLRect                       LLUI::sDirtyRect;
-/*static*/ LLHelp*			LLUI::sHelpImpl = NULL;
-/*static*/ std::vector<std::string> LLUI::sXUIPaths;
-/*static*/ LLFrameTimer		LLUI::sMouseIdleTimer;
-/*static*/ LLUI::add_popup_t	LLUI::sAddPopupFunc;
-/*static*/ LLUI::remove_popup_t	LLUI::sRemovePopupFunc;
-/*static*/ LLUI::clear_popups_t	LLUI::sClearPopupsFunc;
 
 // register filter editor here
 static LLDefaultChildRegistry::Register<LLFilterEditor> register_filter_editor("filter_editor");
@@ -106,18 +93,19 @@ LLUUID find_ui_sound(const char * namep)
 {
 	std::string name = ll_safe_string(namep);
 	LLUUID uuid = LLUUID(NULL);
-	if (!LLUI::sSettingGroups["config"]->controlExists(name))
+	LLUI *ui_inst = LLUI::getInstance();
+	if (!ui_inst->mSettingGroups["config"]->controlExists(name))
 	{
 		LL_WARNS() << "tried to make UI sound for unknown sound name: " << name << LL_ENDL;	
 	}
 	else
 	{
-		uuid = LLUUID(LLUI::sSettingGroups["config"]->getString(name));
+		uuid = LLUUID(ui_inst->mSettingGroups["config"]->getString(name));
 		if (uuid.isNull())
 		{
-			if (LLUI::sSettingGroups["config"]->getString(name) == LLUUID::null.asString())
+			if (ui_inst->mSettingGroups["config"]->getString(name) == LLUUID::null.asString())
 			{
-				if (LLUI::sSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
+				if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
 				{
 					LL_INFOS() << "UI sound name: " << name << " triggered but silent (null uuid)" << LL_ENDL;	
 				}				
@@ -127,9 +115,9 @@ LLUUID find_ui_sound(const char * namep)
 				LL_WARNS() << "UI sound named: " << name << " does not translate to a valid uuid" << LL_ENDL;	
 			}
 		}
-		else if (LLUI::sAudioCallback != NULL)
+		else if (ui_inst->mAudioCallback != NULL)
 		{
-			if (LLUI::sSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
+			if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
 			{
 				LL_INFOS() << "UI sound name: " << name << LL_ENDL;	
 			}
@@ -144,7 +132,7 @@ void make_ui_sound(const char* namep)
 	LLUUID soundUUID = find_ui_sound(namep);
 	if(soundUUID.notNull())
 	{
-		LLUI::sAudioCallback(soundUUID);
+		LLUI::getInstance()->mAudioCallback(soundUUID);
 	}
 }
 
@@ -153,30 +141,31 @@ void make_ui_sound_deferred(const char* namep)
 	LLUUID soundUUID = find_ui_sound(namep);
 	if(soundUUID.notNull())
 	{
-		LLUI::sDeferredAudioCallback(soundUUID);
+		LLUI::getInstance()->mDeferredAudioCallback(soundUUID);
 	}
 }
 
-void LLUI::initClass(const settings_map_t& settings,
-					 LLImageProviderInterface* image_provider,
-					 LLUIAudioCallback audio_callback,
-					 LLUIAudioCallback deferred_audio_callback,
-					 const LLVector2* scale_factor,
-					 const std::string& language)
+LLUI::LLUI(const settings_map_t& settings,
+				 LLImageProviderInterface* image_provider,
+				 LLUIAudioCallback audio_callback,
+				 LLUIAudioCallback deferred_audio_callback)
+: mSettingGroups(settings),
+mAudioCallback(audio_callback),
+mDeferredAudioCallback(deferred_audio_callback),
+mWindow(NULL), // set later in startup
+mRootView(NULL),
+mDirty(FALSE),
+mHelpImpl(NULL)
 {
-	LLRender2D::initClass(image_provider,scale_factor);
-	sSettingGroups = settings;
+	LLRender2D::initParamSingleton(image_provider);
 
-	if ((get_ptr_in_map(sSettingGroups, std::string("config")) == NULL) ||
-		(get_ptr_in_map(sSettingGroups, std::string("floater")) == NULL) ||
-		(get_ptr_in_map(sSettingGroups, std::string("ignores")) == NULL))
+	if ((get_ptr_in_map(mSettingGroups, std::string("config")) == NULL) ||
+		(get_ptr_in_map(mSettingGroups, std::string("floater")) == NULL) ||
+		(get_ptr_in_map(mSettingGroups, std::string("ignores")) == NULL))
 	{
 		LL_ERRS() << "Failure to initialize configuration groups" << LL_ENDL;
 	}
 
-	sAudioCallback = audio_callback;
-	sDeferredAudioCallback = deferred_audio_callback;
-	sWindow = NULL; // set later in startup
 	LLFontGL::sShadowColor = LLUIColorTable::instance().getColor("ColorDropShadow");
 
 	LLUICtrl::CommitCallbackRegistry::Registrar& reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar();
@@ -207,33 +196,26 @@ void LLUI::initClass(const settings_map_t& settings,
 	LLCommandManager::load();
 }
 
-void LLUI::cleanupClass()
-{
-	SUBSYSTEM_CLEANUP(LLRender2D);
-}
-
 void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& remove_popup,  const clear_popups_t& clear_popups)
 {
-	sAddPopupFunc = add_popup;
-	sRemovePopupFunc = remove_popup;
-	sClearPopupsFunc = clear_popups;
+	mAddPopupFunc = add_popup;
+	mRemovePopupFunc = remove_popup;
+	mClearPopupsFunc = clear_popups;
 }
 
-//static
 void LLUI::dirtyRect(LLRect rect)
 {
-	if (!sDirty)
+	if (!mDirty)
 	{
-		sDirtyRect = rect;
-		sDirty = TRUE;
+		mDirtyRect = rect;
+		mDirty = TRUE;
 	}
 	else
 	{
-		sDirtyRect.unionWith(rect);
-	}		
+		mDirtyRect.unionWith(rect);
+	}
 }
- 
-//static 
+
 void LLUI::setMousePositionScreen(S32 x, S32 y)
 {
 #if defined(LL_DARWIN)
@@ -247,7 +229,6 @@ void LLUI::setMousePositionScreen(S32 x, S32 y)
 	LLView::getWindow()->setCursorPosition(LLCoordGL(screen_x, screen_y).convert());
 }
 
-//static 
 void LLUI::getMousePositionScreen(S32 *x, S32 *y)
 {
 	LLCoordWindow cursor_pos_window;
@@ -257,7 +238,6 @@ void LLUI::getMousePositionScreen(S32 *x, S32 *y)
 	*y = ll_round((F32)cursor_pos_gl.mY / getScaleFactor().mV[VY]);
 }
 
-//static 
 void LLUI::setMousePositionLocal(const LLView* viewp, S32 x, S32 y)
 {
 	S32 screen_x, screen_y;
@@ -266,7 +246,6 @@ void LLUI::setMousePositionLocal(const LLView* viewp, S32 x, S32 y)
 	setMousePositionScreen(screen_x, screen_y);
 }
 
-//static 
 void LLUI::getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y)
 {
 	S32 screen_x, screen_y;
@@ -280,20 +259,19 @@ void LLUI::getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y)
 // or on Windows if the SecondLife.exe executable is run directly, the 
 // language follows the OS language.  In all cases the user can override
 // the language manually in preferences. JC
-// static
-std::string LLUI::getLanguage()
+std::string LLUI::getUILanguage()
 {
 	std::string language = "en";
-	if (sSettingGroups["config"])
+	if (mSettingGroups["config"])
 	{
-		language = sSettingGroups["config"]->getString("Language");
+		language = mSettingGroups["config"]->getString("Language");
 		if (language.empty() || language == "default")
 		{
-			language = sSettingGroups["config"]->getString("InstallLanguage");
+			language = mSettingGroups["config"]->getString("InstallLanguage");
 		}
 		if (language.empty() || language == "default")
 		{
-			language = sSettingGroups["config"]->getString("SystemLanguage");
+			language = mSettingGroups["config"]->getString("SystemLanguage");
 		}
 		if (language.empty() || language == "default")
 		{
@@ -303,6 +281,13 @@ std::string LLUI::getLanguage()
 	return language;
 }
 
+// static
+std::string LLUI::getLanguage()
+{
+    // Note: lldateutil_test redefines this function
+    return LLUI::getInstance()->getUILanguage();
+}
+
 struct SubDir : public LLInitParam::Block<SubDir>
 {
 	Mandatory<std::string> value;
@@ -362,37 +347,32 @@ std::string LLUI::locateSkin(const std::string& filename)
 	return "";
 }
 
-//static
 LLVector2 LLUI::getWindowSize()
 {
 	LLCoordWindow window_rect;
-	sWindow->getSize(&window_rect);
+	mWindow->getSize(&window_rect);
 
 	return LLVector2(window_rect.mX / getScaleFactor().mV[VX], window_rect.mY / getScaleFactor().mV[VY]);
 }
 
-//static
 void LLUI::screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y)
 {
 	*gl_x = ll_round((F32)screen_x * getScaleFactor().mV[VX]);
 	*gl_y = ll_round((F32)screen_y * getScaleFactor().mV[VY]);
 }
 
-//static
 void LLUI::glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y)
 {
 	*screen_x = ll_round((F32)gl_x / getScaleFactor().mV[VX]);
 	*screen_y = ll_round((F32)gl_y / getScaleFactor().mV[VY]);
 }
 
-//static
 void LLUI::screenRectToGL(const LLRect& screen, LLRect *gl)
 {
 	screenPointToGL(screen.mLeft, screen.mTop, &gl->mLeft, &gl->mTop);
 	screenPointToGL(screen.mRight, screen.mBottom, &gl->mRight, &gl->mBottom);
 }
 
-//static
 void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen)
 {
 	glPointToScreen(gl.mLeft, gl.mTop, &screen->mLeft, &screen->mTop);
@@ -402,8 +382,8 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen)
 
 LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname)
 {
-	for (settings_map_t::iterator itor = sSettingGroups.begin();
-		 itor != sSettingGroups.end(); ++itor)
+	for (settings_map_t::iterator itor = mSettingGroups.begin();
+		 itor != mSettingGroups.end(); ++itor)
 	{
 		LLControlGroup* control_group = itor->second;
 		if(control_group != NULL)
@@ -413,43 +393,38 @@ LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname)
 		}
 	}
 
-	return *sSettingGroups["config"]; // default group
+	return *mSettingGroups["config"]; // default group
 }
 
-//static 
 void LLUI::addPopup(LLView* viewp)
 {
-	if (sAddPopupFunc)
+	if (mAddPopupFunc)
 	{
-		sAddPopupFunc(viewp);
+		mAddPopupFunc(viewp);
 	}
 }
 
-//static 
 void LLUI::removePopup(LLView* viewp)
 {
-	if (sRemovePopupFunc)
+	if (mRemovePopupFunc)
 	{
-		sRemovePopupFunc(viewp);
+		mRemovePopupFunc(viewp);
 	}
 }
 
-//static
 void LLUI::clearPopups()
 {
-	if (sClearPopupsFunc)
+	if (mClearPopupsFunc)
 	{
-		sClearPopupsFunc();
+		mClearPopupsFunc();
 	}
 }
 
-//static
 void LLUI::reportBadKeystroke()
 {
 	make_ui_sound("UISndBadKeystroke");
 }
-	
-//static
+
 // spawn_x and spawn_y are top left corner of view in screen GL coordinates
 void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y)
 {
@@ -460,7 +435,7 @@ void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y)
 
 	S32 mouse_x;
 	S32 mouse_y;
-	LLUI::getMousePositionScreen(&mouse_x, &mouse_y);
+	getMousePositionScreen(&mouse_x, &mouse_y);
 
 	// If no spawn location provided, use mouse position
 	if (spawn_x == S32_MAX || spawn_y == S32_MAX)
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index d7151dbee9939fd0ecf9af5d65e5646394e00833..e1c51deba9aa0897afff8bc72dccd02c888ed1cf 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -109,8 +109,16 @@ class LLImageProviderInterface;
 
 typedef	void (*LLUIAudioCallback)(const LLUUID& uuid);
 
-class LLUI
+class LLUI : public LLParamSingleton<LLUI>
 {
+public:
+	typedef std::map<std::string, LLControlGroup*> settings_map_t;
+
+private:
+	LLSINGLETON(LLUI , const settings_map_t &settings,
+						   LLImageProviderInterface* image_provider,
+						   LLUIAudioCallback audio_callback,
+						   LLUIAudioCallback deferred_audio_callback);
 	LOG_CLASS(LLUI);
 public:
 	//
@@ -232,36 +240,24 @@ class LLUI
 	//
 	// Methods
 	//
-	typedef std::map<std::string, LLControlGroup*> settings_map_t;
 	typedef boost::function<void(LLView*)> add_popup_t;
 	typedef boost::function<void(LLView*)> remove_popup_t;
 	typedef boost::function<void(void)> clear_popups_t;
 
-	static void initClass(const settings_map_t& settings,
-						  LLImageProviderInterface* image_provider,
-						  LLUIAudioCallback audio_callback = NULL,
-						  LLUIAudioCallback deferred_audio_callback = NULL,
-						  const LLVector2 *scale_factor = NULL,
-						  const std::string& language = LLStringUtil::null);
-	static void cleanupClass();
-	static void setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t&, const clear_popups_t& );
-
-	static void pushMatrix() { LLRender2D::pushMatrix(); }
-	static void popMatrix() { LLRender2D::popMatrix(); }
-	static void loadIdentity() { LLRender2D::loadIdentity(); }
-	static void translate(F32 x, F32 y, F32 z = 0.0f) { LLRender2D::translate(x, y, z); }
+	void setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t&, const clear_popups_t& );
 
-	static LLRect	sDirtyRect;
-	static BOOL		sDirty;
-	static void		dirtyRect(LLRect rect);
+	LLRect	mDirtyRect;
+	BOOL		mDirty;
+	void		dirtyRect(LLRect rect);
 
 	// Return the ISO639 language name ("en", "ko", etc.) for the viewer UI.
 	// http://www.loc.gov/standards/iso639-2/php/code_list.php
-	static std::string getLanguage();
+	std::string getUILanguage();
+	static std::string getLanguage(); // static for lldateutil_test compatibility
 
 	//helper functions (should probably move free standing rendering helper functions here)
-	static LLView* getRootView() { return sRootView; }
-	static void setRootView(LLView* view) { sRootView = view; }
+	LLView* getRootView() { return mRootView; }
+	void setRootView(LLView* view) { mRootView = view; }
 	/**
 	 * Walk the LLView tree to resolve a path
 	 * Paths can be discovered using Develop > XUI > Show XUI Paths
@@ -287,58 +283,65 @@ class LLUI
 	 *      tree, the first "bar" anywhere under it, and "baz"
 	 *      as a direct child of that
 	 */
-	static const LLView* resolvePath(const LLView* context, const std::string& path);
-	static LLView* resolvePath(LLView* context, const std::string& path);
+	const LLView* resolvePath(const LLView* context, const std::string& path);
+	LLView* resolvePath(LLView* context, const std::string& path);
 	static std::string locateSkin(const std::string& filename);
-	static void setMousePositionScreen(S32 x, S32 y);
-	static void getMousePositionScreen(S32 *x, S32 *y);
-	static void setMousePositionLocal(const LLView* viewp, S32 x, S32 y);
-	static void getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y);
-	static LLVector2& getScaleFactor() { return LLRender2D::sGLScaleFactor; }
-	static void setScaleFactor(const LLVector2& scale_factor) { LLRender2D::setScaleFactor(scale_factor); }
-	static void setLineWidth(F32 width) { LLRender2D::setLineWidth(width); }
-	static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0)
-		{ return LLRender2D::getUIImageByID(image_id, priority); }
-	static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0)
-		{ return LLRender2D::getUIImage(name, priority); }
-	static LLVector2 getWindowSize();
-	static void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y);
-	static void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y);
-	static void screenRectToGL(const LLRect& screen, LLRect *gl);
-	static void glRectToScreen(const LLRect& gl, LLRect *screen);
+	void setMousePositionScreen(S32 x, S32 y);
+	void getMousePositionScreen(S32 *x, S32 *y);
+	void setMousePositionLocal(const LLView* viewp, S32 x, S32 y);
+	void getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y);
+	LLVector2 getWindowSize();
+	void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y);
+	void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y);
+	void screenRectToGL(const LLRect& screen, LLRect *gl);
+	void glRectToScreen(const LLRect& gl, LLRect *screen);
 	// Returns the control group containing the control name, or the default group
-	static LLControlGroup& getControlControlGroup (const std::string& controlname);
-	static F32 getMouseIdleTime() { return sMouseIdleTimer.getElapsedTimeF32(); }
-	static void resetMouseIdleTimer() { sMouseIdleTimer.reset(); }
-	static LLWindow* getWindow() { return sWindow; }
+	LLControlGroup& getControlControlGroup (const std::string& controlname);
+	F32 getMouseIdleTime() { return mMouseIdleTimer.getElapsedTimeF32(); }
+	void resetMouseIdleTimer() { mMouseIdleTimer.reset(); }
+	LLWindow* getWindow() { return mWindow; }
 
-	static void addPopup(LLView*);
-	static void removePopup(LLView*);
-	static void clearPopups();
+	void addPopup(LLView*);
+	void removePopup(LLView*);
+	void clearPopups();
 
-	static void reportBadKeystroke();
+	void reportBadKeystroke();
 
 	// Ensures view does not overlap mouse cursor, but is inside
 	// the view's parent rectangle.  Used for tooltips, inspectors.
 	// Optionally override the view's default X/Y, which are relative to the
 	// view's parent.
-	static void positionViewNearMouse(LLView* view,	S32 spawn_x = S32_MAX, S32 spawn_y = S32_MAX);
+	void positionViewNearMouse(LLView* view,	S32 spawn_x = S32_MAX, S32 spawn_y = S32_MAX);
+
+	// LLRender2D wrappers
+	static void pushMatrix() { LLRender2D::getInstance()->pushMatrix(); }
+	static void popMatrix() { LLRender2D::getInstance()->popMatrix(); }
+	static void loadIdentity() { LLRender2D::getInstance()->loadIdentity(); }
+	static void translate(F32 x, F32 y, F32 z = 0.0f) { LLRender2D::getInstance()->translate(x, y, z); }
+
+	static LLVector2& getScaleFactor() { return LLRender2D::getInstance()->mGLScaleFactor; }
+	static void setScaleFactor(const LLVector2& scale_factor) { LLRender2D::getInstance()->setScaleFactor(scale_factor); }
+	static void setLineWidth(F32 width) { LLRender2D::getInstance()->setLineWidth(width); }
+	static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0)
+		{ return LLRender2D::getInstance()->getUIImageByID(image_id, priority); }
+	static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0)
+		{ return LLRender2D::getInstance()->getUIImage(name, priority); }
 
 	//
 	// Data
 	//
-	static settings_map_t sSettingGroups;
-	static LLUIAudioCallback sAudioCallback;
-	static LLUIAudioCallback sDeferredAudioCallback;
-	static LLWindow*		sWindow;
-	static LLView*			sRootView;
-	static LLHelp*			sHelpImpl;
+	settings_map_t mSettingGroups;
+	LLUIAudioCallback mAudioCallback;
+	LLUIAudioCallback mDeferredAudioCallback;
+	LLWindow*		mWindow;
+	LLView*			mRootView;
+	LLHelp*			mHelpImpl;
 private:
-	static std::vector<std::string> sXUIPaths;
-	static LLFrameTimer		sMouseIdleTimer;
-	static add_popup_t		sAddPopupFunc;
-	static remove_popup_t	sRemovePopupFunc;
-	static clear_popups_t	sClearPopupsFunc;
+	std::vector<std::string> mXUIPaths;
+	LLFrameTimer		mMouseIdleTimer;
+	add_popup_t		mAddPopupFunc;
+	remove_popup_t	mRemovePopupFunc;
+	clear_popups_t	mClearPopupsFunc;
 };
 
 
@@ -363,7 +366,7 @@ class LLUICachedControl : public LLCachedControl<T>
 	LLUICachedControl(const std::string& name,
 					  const T& default_value,
 					  const std::string& comment = "Declared In Code")
-	:	LLCachedControl<T>(LLUI::getControlControlGroup(name), name, default_value, comment)
+	:	LLCachedControl<T>(LLUI::getInstance()->getControlControlGroup(name), name, default_value, comment)
 	{}
 };
 
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 0dbd7ceb25208e6a9b98ca0684febac1789e4d53..333d03f208da6ee44e86357946d133f40c534163 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -176,7 +176,7 @@ void LLUrlEntryBase::callObservers(const std::string &id,
 bool LLUrlEntryBase::isLinkDisabled() const
 {
 	// this allows us to have a global setting to turn off text hyperlink highlighting/action
-	bool globally_disabled = LLUI::sSettingGroups["config"]->getBOOL("DisableTextHyperlinkActions");
+	bool globally_disabled = LLUI::getInstance()->mSettingGroups["config"]->getBOOL("DisableTextHyperlinkActions");
 
 	return globally_disabled;
 }
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index b0e346f513a61b66a1cb7016d12fcb48f3ff0ff3..593c8b12fc8a7c328de2e52eabba3a4ed8340c6b 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -816,7 +816,7 @@ LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask)
 		}
 
 		// This call differentiates this method from childrenHandleMouseEvent().
-		LLUI::sWindow->setCursor(viewp->getHoverCursor());
+		LLUI::getInstance()->mWindow->setCursor(viewp->getHoverCursor());
 
 		if (viewp->handleHover(local_x, local_y, mask)
 			|| viewp->blockMouseEvent(local_x, local_y))
@@ -873,11 +873,11 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)
 		// allow "scrubbing" over ui by showing next tooltip immediately
 		// if previous one was still visible
 		F32 timeout = LLToolTipMgr::instance().toolTipVisible() 
-		              ? LLUI::sSettingGroups["config"]->getF32( "ToolTipFastDelay" )
-		              : LLUI::sSettingGroups["config"]->getF32( "ToolTipDelay" );
+		              ? LLUI::getInstance()->mSettingGroups["config"]->getF32( "ToolTipFastDelay" )
+		              : LLUI::getInstance()->mSettingGroups["config"]->getF32( "ToolTipDelay" );
 
 		// Even if we don't show tooltips, consume the event, nothing below should show tooltip
-		bool allow_ui_tooltips = LLUI::sSettingGroups["config"]->getBOOL( "BasicUITooltips" );
+		bool allow_ui_tooltips = LLUI::getInstance()->mSettingGroups["config"]->getBOOL("BasicUITooltips");
 		if (allow_ui_tooltips)
 		{
 			LLToolTipMgr::instance().show(LLToolTip::Params()
@@ -1158,7 +1158,7 @@ void LLView::drawChildren()
 {
 	if (!mChildList.empty())
 	{
-		LLView* rootp = LLUI::getRootView();		
+		LLView* rootp = LLUI::getInstance()->getRootView();		
 		++sDepth;
 
 		for (child_list_reverse_iter_t child_iter = mChildList.rbegin(); child_iter != mChildList.rend();)  // ++child_iter)
@@ -1174,7 +1174,7 @@ void LLView::drawChildren()
 			if (viewp->getVisible() && viewp->getRect().isValid())
 			{
 				LLRect screen_rect = viewp->calcScreenRect();
-				if ( rootp->getLocalRect().overlaps(screen_rect)  && LLUI::sDirtyRect.overlaps(screen_rect))
+				if ( rootp->getLocalRect().overlaps(screen_rect)  && LLUI::getInstance()->mDirtyRect.overlaps(screen_rect))
 				{
 					LLUI::pushMatrix();
 					{
@@ -1216,7 +1216,7 @@ void LLView::dirtyRect()
 		parent = parent->getParent();
 	}
 
-	LLUI::dirtyRect(cur->calcScreenRect());
+	LLUI::getInstance()->dirtyRect(cur->calcScreenRect());
 }
 
 //Draw a box for debugging.
@@ -2239,9 +2239,9 @@ LLControlVariable *LLView::findControl(const std::string& name)
 		std::string control_group_key = name.substr(0, key_pos);
 		LLControlVariable* control;
 		// check if it's in the control group that name indicated
-		if(LLUI::sSettingGroups[control_group_key])
+		if(LLUI::getInstance()->mSettingGroups[control_group_key])
 		{
-			control = LLUI::sSettingGroups[control_group_key]->getControl(name);
+			control = LLUI::getInstance()->mSettingGroups[control_group_key]->getControl(name);
 			if (control)
 			{
 				return control;
@@ -2249,7 +2249,7 @@ LLControlVariable *LLView::findControl(const std::string& name)
 		}
 	}
 	
-	LLControlGroup& control_group = LLUI::getControlControlGroup(name);
+	LLControlGroup& control_group = LLUI::getInstance()->getControlControlGroup(name);
 	return control_group.getControl(name);	
 }
 
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index b448cc8397ece9181d405bfdf5d23ebd0fb33664..db81900aaff267e0d149d76ab712159bd3edc704 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -499,7 +499,7 @@ class LLView
 	// return query for iterating over focus roots in tab order
 	static const LLViewQuery & getFocusRootsQuery();
 
-	static LLWindow*	getWindow(void) { return LLUI::sWindow; }
+	static LLWindow*	getWindow(void) { return LLUI::getInstance()->mWindow; }
 
 	// Set up params after XML load before calling new(),
 	// usually to adjust layout.
diff --git a/indra/llui/llviewereventrecorder.cpp b/indra/llui/llviewereventrecorder.cpp
index 8754cfebbb466a7b193e956eb88417c87c908ad5..cb000aef74fd8166189431f35a18e0231c69e0bf 100644
--- a/indra/llui/llviewereventrecorder.cpp
+++ b/indra/llui/llviewereventrecorder.cpp
@@ -44,7 +44,7 @@ LLViewerEventRecorder::LLViewerEventRecorder() {
 
 
 bool LLViewerEventRecorder::displayViewerEventRecorderMenuItems() {
-  return LLUI::sSettingGroups["config"]->getBOOL("ShowEventRecorderMenuItems");
+  return LLUI::getInstance()->mSettingGroups["config"]->getBOOL("ShowEventRecorderMenuItems");
 }
 
 
@@ -99,7 +99,7 @@ void LLViewerEventRecorder::setMouseGlobalCoords(S32 x, S32 y) {
 
 void LLViewerEventRecorder::updateMouseEventInfo(S32 local_x, S32 local_y, S32 global_x, S32 global_y, std::string mName) {
 
-  LLView * target_view = LLUI::resolvePath(LLUI::getRootView(), xui);
+  LLView * target_view = LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), xui);
   if (! target_view) {
     LL_DEBUGS() << "LLViewerEventRecorder::updateMouseEventInfo - xui path on file at moment is NOT valid - so DO NOT record these local coords" << LL_ENDL;
     return;
@@ -216,7 +216,7 @@ void LLViewerEventRecorder::playbackRecording() {
   LLSD LeapCommand;
 
   // ivita sets this on startup, it also sends commands to the viewer to make start, stop, and playback menu items visible in viewer
-  LeapCommand =LLUI::sSettingGroups["config"]->getLLSD("LeapPlaybackEventsCommand");
+  LeapCommand =LLUI::getInstance()->mSettingGroups["config"]->getLLSD("LeapPlaybackEventsCommand");
   
   LL_DEBUGS() << "[VITA] launching playback - leap command is: " << LLSDXMLStreamer(LeapCommand) << LL_ENDL;
   LLLeap::create("", LeapCommand, false); // exception=false
diff --git a/indra/llui/llviewinject.h b/indra/llui/llviewinject.h
index 0de3d155c41ba819b491ac4d93e1ed894e587c04..7f18ec6fbe8fce6fbc9ecb2d92992f59bf3625fe 100644
--- a/indra/llui/llviewinject.h
+++ b/indra/llui/llviewinject.h
@@ -32,7 +32,7 @@ namespace llview
     public:
         /**
          * Construct TargetEvent with the desired target LLView*. (See
-         * LLUI::resolvePath() to obtain an LLView* given a string pathname.)
+         * LLUI::getInstance()->resolvePath() to obtain an LLView* given a string pathname.)
          * This sets up for operator().
          */
         TargetEvent(LLView* view);
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 6089162190721a347f397db9df5d2ddc3476e34e..cf8f99ed2516170859236d5435258630be4d5bd3 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -208,7 +208,6 @@ set(viewer_SOURCE_FILES
     llfilteredwearablelist.cpp
     llfirstuse.cpp
     llflexibleobject.cpp
-    llflickrconnect.cpp
     llfloaterabout.cpp
     llfloaterbvhpreview.cpp
     llfloaterauction.cpp
@@ -244,7 +243,6 @@ set(viewer_SOURCE_FILES
     llfloaterexperiencepicker.cpp
     llfloaterexperienceprofile.cpp
     llfloaterexperiences.cpp
-    llfloaterflickr.cpp
     llfloaterfonttest.cpp
     llfloaterforgetuser.cpp
     llfloatergesture.cpp
@@ -318,7 +316,6 @@ set(viewer_SOURCE_FILES
     llfloatertos.cpp
     llfloatertoybox.cpp
     llfloatertranslationsettings.cpp
-    llfloatertwitter.cpp
     llfloateruipreview.cpp
     llfloaterurlentry.cpp
     llfloatervoiceeffect.cpp
@@ -616,7 +613,6 @@ set(viewer_SOURCE_FILES
     lltransientdockablefloater.cpp
     lltransientfloatermgr.cpp
     lltranslate.cpp
-    lltwitterconnect.cpp
     lluiavatar.cpp
     lluilistener.cpp
     lluploaddialog.cpp
@@ -835,7 +831,6 @@ set(viewer_HEADER_FILES
     llfilteredwearablelist.h
     llfirstuse.h
     llflexibleobject.h
-    llflickrconnect.h
     llfloaterabout.h
     llfloaterbvhpreview.h
     llfloaterauction.h
@@ -871,7 +866,6 @@ set(viewer_HEADER_FILES
     llfloaterexperiencepicker.h
     llfloaterexperienceprofile.h
     llfloaterexperiences.h
-    llfloaterflickr.h
     llfloaterfonttest.h
     llfloaterforgetuser.h
     llfloatergesture.h
@@ -948,7 +942,6 @@ set(viewer_HEADER_FILES
     llfloatertos.h
     llfloatertoybox.h
     llfloatertranslationsettings.h
-    llfloatertwitter.h
     llfloateruipreview.h
     llfloaterurlentry.h
     llfloatervoiceeffect.h
@@ -1236,7 +1229,6 @@ set(viewer_HEADER_FILES
     lltransientdockablefloater.h
     lltransientfloatermgr.h
     lltranslate.h
-    lltwitterconnect.h
     lluiconstants.h
     lluiavatar.h
     lluilistener.h
diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt
index 8ac3c4451161d5c0895e8d74528038011cb030ed..b98d1d3fa746f67079f0a6fc24649c7aff21ddea 100644
--- a/indra/newview/VIEWER_VERSION.txt
+++ b/indra/newview/VIEWER_VERSION.txt
@@ -1 +1 @@
-6.3.4
+6.3.5
diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml
index dae397a3b6c74ed90134f34afa4bcaf0bc75813b..98143bbce61353b4275cec36ad8a5121e5af5c30 100644
--- a/indra/newview/app_settings/commands.xml
+++ b/indra/newview/app_settings/commands.xml
@@ -218,26 +218,6 @@
            is_running_function="Floater.IsOpen"
            is_running_parameters="snapshot"
            />
-  <command name="flickr"
-           available_in_toybox="true"
-           icon="Command_Flickr_Icon"
-           label_ref="Command_Flickr_Label"
-           tooltip_ref="Command_Flickr_Tooltip"
-           execute_function="Floater.ToggleOrBringToFront"
-           execute_parameters="flickr"
-           is_running_function="Floater.IsOpen"
-           is_running_parameters="flickr"
-           />
-  <command name="twitter"
-           available_in_toybox="true"
-           icon="Command_Twitter_Icon"
-           label_ref="Command_Twitter_Label"
-           tooltip_ref="Command_Twitter_Tooltip"
-           execute_function="Floater.ToggleOrBringToFront"
-           execute_parameters="twitter"
-           is_running_function="Floater.IsOpen"
-           is_running_parameters="twitter"
-           />
   <command name="speak"
            available_in_toybox="true"
            icon="Command_Speak_Icon"
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index c9074d1a952b40011120002ccaadb6787237b33e..85b7d7b06f3594e750cdb6e73303ac2c57a988a2 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1151,7 +1151,7 @@ void LLAgentCamera::updateCamera()
 		mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
 	}
 
-	if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getActiveFollowCamParams())
+	if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getInstance()->getActiveFollowCamParams())
 	{
 		mAllowChangeToFollow = FALSE;
 		mFocusOnAvatar = TRUE;
@@ -1251,7 +1251,7 @@ void LLAgentCamera::updateCamera()
 			// *TODO: use combined rotation of frameagent and sit object
 			LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
 
-			LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
+			LLFollowCamParams* current_cam = LLFollowCamMgr::getInstance()->getActiveFollowCamParams();
 			if (current_cam)
 			{
 				mFollowCam.copyParams(*current_cam);
@@ -1460,7 +1460,7 @@ void LLAgentCamera::updateCamera()
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				LLViewerObject *attached_object = (*attachment_iter);
+				LLViewerObject *attached_object = attachment_iter->get();
 				if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull())
 				{
 					// clear any existing "early" movements of attachment
@@ -2057,7 +2057,7 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 
 	// Menus should not remain open on switching to mouselook...
 	LLMenuGL::sMenuContainer->hideMenus();
-	LLUI::clearPopups();
+	LLUI::getInstance()->clearPopups();
 
 	// unpause avatar animation
 	gAgent.unpauseAnimation();
@@ -2111,7 +2111,7 @@ void LLAgentCamera::changeCameraToDefault()
 		return;
 	}
 
-	if (LLFollowCamMgr::getActiveFollowCamParams())
+	if (LLFollowCamMgr::getInstance()->getActiveFollowCamParams())
 	{
 		changeCameraToFollow();
 	}
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 15e4de8f6909f4e64d4c61043a595594f9a64d5a..013c40f557d8fd2a71e03102a917e44c6f4a414a 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -1323,7 +1323,7 @@ void LLAgentWearables::findAttachmentsAddRemoveInfo(LLInventoryModel::item_array
 			 attachment_iter != attachment->mAttachedObjects.end();
 			 ++attachment_iter)
 		{
-			LLViewerObject *objectp = (*attachment_iter);
+			LLViewerObject *objectp = attachment_iter->get();
 			if (objectp)
 			{
 				LLUUID object_item_id = objectp->getAttachmentItemID();
@@ -1387,7 +1387,7 @@ std::vector<LLViewerObject*> LLAgentWearables::getTempAttachments()
 				attachment_iter != attachment->mAttachedObjects.end();
 				++attachment_iter)
 			{
-				LLViewerObject *objectp = (*attachment_iter);
+				LLViewerObject *objectp = attachment_iter->get();
 				if (objectp && objectp->isTempAttachment())
 				{
 					temp_attachs.push_back(objectp);
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 18c0cedba83303c5f319ca6984304942b251144f..3c3dda1765633a801b8425d9d6fd43ea051e67fb 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -148,7 +148,7 @@ class LLAppearanceHandler : public LLCommandHandler
 	{
 		// support secondlife:///app/appearance/show, but for now we just
 		// make all secondlife:///app/appearance SLapps behave this way
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAppearance"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableAppearance"))
 		{
 			LLNotificationsUtil::add("NoAppearance", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
@@ -2929,7 +2929,7 @@ void LLAppearanceMgr::removeAllAttachmentsFromAvatar()
 			 attachment_iter != attachment->mAttachedObjects.end();
 			 ++attachment_iter)
 		{
-			LLViewerObject *attached_object = (*attachment_iter);
+			LLViewerObject *attached_object = attachment_iter->get();
 			if (attached_object)
 			{
 				objects_to_remove.push_back(attached_object);
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index d3067456fa73fd3076bf4ef784f05f7985ae4bcc..bf6ba38de25a91eecdb041f48779889dd37abfc5 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -103,7 +103,6 @@
 #include "llscenemonitor.h"
 #include "llavatarrenderinfoaccountant.h"
 #include "lllocalbitmaps.h"
-#include "llskinningutil.h"
 
 // Linden library includes
 #include "llavatarnamecache.h"
@@ -777,7 +776,7 @@ bool LLAppViewer::init()
 
 	// initialize LLWearableType translation bridge.
 	// Memory will be cleaned up in ::cleanupClass()
-	LLWearableType::initClass(new LLUITranslationBridge());
+	LLWearableType::initParamSingleton(new LLUITranslationBridge());
 
 	// initialize SSE options
 	LLVector4a::initClass();
@@ -801,9 +800,6 @@ bool LLAppViewer::init()
 
 	LL_INFOS("InitInfo") << "Configuration initialized." << LL_ENDL ;
 
-	// initialize skinning util
-	LLSkinningUtil::initClass();
-
 	//set the max heap size.
 	initMaxHeapSize() ;
 	LLCoros::instance().setStackSize(gSavedSettings.getS32("CoroutineStackSize"));
@@ -851,11 +847,10 @@ bool LLAppViewer::init()
 	settings_map["floater"] = &gSavedSettings; // *TODO: New settings file
 	settings_map["account"] = &gSavedPerAccountSettings;
 
-	LLUI::initClass(settings_map,
+	LLUI::initParamSingleton(settings_map,
 		LLUIImageList::getInstance(),
 		ui_audio_callback,
-		deferred_ui_audio_callback,
-		&LLUI::getScaleFactor());
+		deferred_ui_audio_callback);
 	LL_INFOS("InitInfo") << "UI initialized." << LL_ENDL ;
 
 	// NOW LLUI::getLanguage() should work. gDirUtilp must know the language
@@ -899,8 +894,6 @@ bool LLAppViewer::init()
 	// LLKeyboard relies on LLUI to know what some accelerator keys are called.
 	LLKeyboard::setStringTranslatorFunc( LLTrans::getKeyboardString );
 
-	LLWeb::initClass();			  // do this after LLUI
-
 	// Provide the text fields with callbacks for opening Urls
 	LLUrlAction::setOpenURLCallback(boost::bind(&LLWeb::loadURL, _1, LLStringUtil::null, LLStringUtil::null));
 	LLUrlAction::setOpenURLInternalCallback(boost::bind(&LLWeb::loadURLInternal, _1, LLStringUtil::null, LLStringUtil::null, false));
@@ -908,7 +901,7 @@ bool LLAppViewer::init()
 	LLUrlAction::setExecuteSLURLCallback(&LLURLDispatcher::dispatchFromTextEditor);
 
 	// Let code in llui access the viewer help floater
-	LLUI::sHelpImpl = LLViewerHelp::getInstance();
+	LLUI::getInstance()->mHelpImpl = LLViewerHelp::getInstance();
 
 	LL_INFOS("InitInfo") << "UI initialization is done." << LL_ENDL ;
 
@@ -1214,9 +1207,6 @@ bool LLAppViewer::init()
 							 << LL_ENDL;
 	}
 
-	LLViewerMedia::initClass();
-	LL_INFOS("InitInfo") << "Viewer media initialized." << LL_ENDL ;
-
 	LLTextUtil::TextHelpers::iconCallbackCreationFunction = create_text_segment_icon_from_url_match;
 
 	//EXT-7013 - On windows for some locale (Japanese) standard
@@ -1256,7 +1246,7 @@ bool LLAppViewer::init()
 	// Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be instantiated.
 
 	LLVoiceChannel::initClass();
-	LLVoiceClient::getInstance()->init(gServicePump);
+	LLVoiceClient::initParamSingleton(gServicePump);
 	LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&LLFloaterIMContainer::onCurrentChannelChanged, _1), true);
 
 	joystick = LLViewerJoystick::getInstance();
@@ -1758,8 +1748,6 @@ bool LLAppViewer::cleanup()
 	gTransferManager.cleanup();
 #endif
 
-	SUBSYSTEM_CLEANUP(LLLocalBitmapMgr);
-
 	// Note: this is where gWorldMap used to be deleted.
 
 	// Note: this is where gHUDManager used to be deleted.
@@ -1902,12 +1890,9 @@ bool LLAppViewer::cleanup()
 
  	//end_messaging_system();
 
-	SUBSYSTEM_CLEANUP(LLFollowCamMgr);
-	//SUBSYSTEM_CLEANUP(LLVolumeMgr);
 	LLPrimitive::cleanupVolumeManager();
 	SUBSYSTEM_CLEANUP(LLWorldMapView);
 	SUBSYSTEM_CLEANUP(LLFolderViewItem);
-	SUBSYSTEM_CLEANUP(LLUI);
 
 	//
 	// Shut down the VFS's AFTER the decode manager cleans up (since it cleans up vfiles).
@@ -2062,13 +2047,10 @@ bool LLAppViewer::cleanup()
 	//Note:
 	//SUBSYSTEM_CLEANUP(LLViewerMedia) has to be put before gTextureList.shutdown()
 	//because some new image might be generated during cleaning up media. --bao
-	SUBSYSTEM_CLEANUP(LLViewerMedia);
-	SUBSYSTEM_CLEANUP(LLViewerParcelMedia);
 	gTextureList.shutdown(); // shutdown again in case a callback added something
 	LLUIImageList::getInstance()->cleanUp();
 
 	// This should eventually be done in LLAppViewer
-	SUBSYSTEM_CLEANUP(LLImage);
 	SUBSYSTEM_CLEANUP(LLVFSThread);
 	SUBSYSTEM_CLEANUP(LLLFSThread);
 
@@ -2116,8 +2098,6 @@ bool LLAppViewer::cleanup()
 	SUBSYSTEM_CLEANUP(LLProxy);
     LLCore::LLHttp::cleanup();
 
-	SUBSYSTEM_CLEANUP(LLWearableType);
-
 	LLMainLoopRepeater::instance().stop();
 
 	ll_close_fail_log();
@@ -2179,7 +2159,7 @@ bool LLAppViewer::initThreads()
 {
 	static const bool enable_threads = true;
 
-	LLImage::initClass(gSavedSettings.getBOOL("TextureNewByteRange"),gSavedSettings.getS32("TextureReverseByteRange"));
+	LLImage::initParamSingleton(gSavedSettings.getBOOL("TextureNewByteRange"),gSavedSettings.getS32("TextureReverseByteRange"));
 
 	LLVFSThread::initClass(enable_threads && false);
 	LLLFSThread::initClass(enable_threads && false);
@@ -3063,7 +3043,7 @@ bool LLAppViewer::initWindow()
 		gViewerWindow->getWindow()->maximize();
 	}
 
-	LLUI::sWindow = gViewerWindow->getWindow();
+	LLUI::getInstance()->mWindow = gViewerWindow->getWindow();
 
 	// Show watch cursor
 	gViewerWindow->setCursor(UI_CURSOR_WAIT);
@@ -4165,7 +4145,7 @@ bool LLAppViewer::initCache()
 	mPurgeCache = false;
 	BOOL read_only = mSecondInstance ? TRUE : FALSE;
 	LLAppViewer::getTextureCache()->setReadOnly(read_only) ;
-	LLVOCache::getInstance()->setReadOnly(read_only);
+	LLVOCache::initParamSingleton(read_only);
 
 	bool texture_cache_mismatch = false;
 	if (gSavedSettings.getS32("LocalCacheVersion") != LLAppViewer::getTextureCacheVersion())
@@ -4237,7 +4217,8 @@ bool LLAppViewer::initCache()
 	S64 extra = LLAppViewer::getTextureCache()->initCache(LL_PATH_CACHE, texture_cache_size, texture_cache_mismatch);
 	texture_cache_size -= extra;
 
-	LLVOCache::getInstance()->initCache(LL_PATH_CACHE, gSavedSettings.getU32("CacheNumberOfRegionsForObjects"), getObjectCacheVersion()) ;
+
+	LLVOCache::getInstance()->initCache(LL_PATH_CACHE, gSavedSettings.getU32("CacheNumberOfRegionsForObjects"), getObjectCacheVersion());
 
 	LLSplashScreen::update(LLTrans::getString("StartupInitializingVFS"));
 
@@ -4567,7 +4548,7 @@ void LLAppViewer::loadNameCache()
 	llifstream name_cache_stream(filename.c_str());
 	if(name_cache_stream.is_open())
 	{
-		if ( ! LLAvatarNameCache::importFile(name_cache_stream))
+		if ( ! LLAvatarNameCache::getInstance()->importFile(name_cache_stream))
         {
             LL_WARNS("AppInit") << "removing invalid '" << filename << "'" << LL_ENDL;
             name_cache_stream.close();
@@ -4594,7 +4575,7 @@ void LLAppViewer::saveNameCache()
 	llofstream name_cache_stream(filename.c_str());
 	if(name_cache_stream.is_open())
 	{
-		LLAvatarNameCache::exportFile(name_cache_stream);
+		LLAvatarNameCache::getInstance()->exportFile(name_cache_stream);
     }
 
     // real names cache
@@ -5201,7 +5182,8 @@ void LLAppViewer::idleNameCache()
 	// granted to neighbor regions before the main agent gets there.  Can't
 	// do it in the move-into-region code because cap not guaranteed to be
 	// granted yet, for example on teleport.
-	bool had_capability = LLAvatarNameCache::hasNameLookupURL();
+	LLAvatarNameCache *name_cache = LLAvatarNameCache::getInstance();
+	bool had_capability = LLAvatarNameCache::getInstance()->hasNameLookupURL();
 	std::string name_lookup_url;
 	name_lookup_url.reserve(128); // avoid a memory allocation below
 	name_lookup_url = region->getCapability("GetDisplayNames");
@@ -5218,12 +5200,12 @@ void LLAppViewer::idleNameCache()
 	    {
 		    name_lookup_url += '/';
 	    }
-		LLAvatarNameCache::setNameLookupURL(name_lookup_url);
+		name_cache->setNameLookupURL(name_lookup_url);
 	}
 	else
 	{
 		// Display names not available on this region
-		LLAvatarNameCache::setNameLookupURL( std::string() );
+		name_cache->setNameLookupURL( std::string() );
 	}
 
 	// Error recovery - did we change state?
@@ -5233,7 +5215,7 @@ void LLAppViewer::idleNameCache()
 		LLVOAvatar::invalidateNameTags();
 	}
 
-	LLAvatarNameCache::idle();
+	name_cache->idle();
 }
 
 //
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 513f25e3017cd2795ae16c1698fc7d63d325a7c3..b0715a3afd38e54e22a6905e6371a6d684d00fee 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -154,7 +154,7 @@ LLAvatarList::LLAvatarList(const Params& p)
 		mLITUpdateTimer->start();
 	}
 	
-	LLAvatarNameCache::addUseDisplayNamesCallback(boost::bind(&LLAvatarList::handleDisplayNamesOptionChanged, this));
+	LLAvatarNameCache::getInstance()->addUseDisplayNamesCallback(boost::bind(&LLAvatarList::handleDisplayNamesOptionChanged, this));
 }
 
 
diff --git a/indra/newview/llbrowsernotification.cpp b/indra/newview/llbrowsernotification.cpp
index 19747757dbcc13b4af68d5f039a5470d61764784..0460bff1b4859f923f7b8a584ee5a5318fcf1a9a 100644
--- a/indra/newview/llbrowsernotification.cpp
+++ b/indra/newview/llbrowsernotification.cpp
@@ -50,7 +50,7 @@ bool LLBrowserNotification::processNotification(const LLNotificationPtr& notific
 	}
 	else if (LLViewerMediaFocus::instance().getControlsMediaID() == media_id)
 	{
-		LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(media_id);
+		LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(media_id);
 		if (impl)
 		{
 			impl->showNotification(notification);
diff --git a/indra/newview/llchannelmanager.cpp b/indra/newview/llchannelmanager.cpp
index d6240838b6eca6da33174638a3ff837580a14b70..0b7b9cbbc7aef373ff5a50e735dd34be8c922627 100644
--- a/indra/newview/llchannelmanager.cpp
+++ b/indra/newview/llchannelmanager.cpp
@@ -58,15 +58,22 @@ LLChannelManager::LLChannelManager()
 //--------------------------------------------------------------------------
 LLChannelManager::~LLChannelManager()
 {
-	for(std::vector<ChannelElem>::iterator it = mChannelList.begin(); it !=  mChannelList.end(); ++it)
-	{
-		LLScreenChannelBase* channel = it->channel.get();
-		if (!channel) continue;
+}
 
-		delete channel;
-	}
+//--------------------------------------------------------------------------
+void LLChannelManager::cleanupSingleton()
+{
+    // Note: LLScreenChannelBase is a LLUICtrl and depends onto other singletions
+    // not captured by singleton-dependency, so cleanup it here instead of destructor
+    for (std::vector<ChannelElem>::iterator it = mChannelList.begin(); it != mChannelList.end(); ++it)
+    {
+        LLScreenChannelBase* channel = it->channel.get();
+        if (!channel) continue;
 
-	mChannelList.clear();
+        delete channel;
+    }
+
+    mChannelList.clear();
 }
 
 //--------------------------------------------------------------------------
diff --git a/indra/newview/llchannelmanager.h b/indra/newview/llchannelmanager.h
index 8b9d0dda8b6ca2158b3e90bdec497039bc397fe6..8abe350196bd9630de2a4e6de8e3f4591d95f423 100644
--- a/indra/newview/llchannelmanager.h
+++ b/indra/newview/llchannelmanager.h
@@ -46,6 +46,7 @@ class LLChannelManager : public LLSingleton<LLChannelManager>
 	LLSINGLETON(LLChannelManager);
 	virtual ~LLChannelManager();
 
+	void cleanupSingleton();
 public:
 
 
diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index ba6b251d585eec4c48ba540b5170f467d3b042df..5539fa75dd4afb23b125514d78b2a310279b1db2 100644
--- a/indra/newview/llconversationlog.cpp
+++ b/indra/newview/llconversationlog.cpp
@@ -189,16 +189,6 @@ LLConversationLog::LLConversationLog() :
 	mAvatarNameCacheConnection(),
 	mLoggingEnabled(false)
 {
-	if(gSavedPerAccountSettings.controlExists("KeepConversationLogTranscripts"))
-	{
-		LLControlVariable * keep_log_ctrlp = gSavedPerAccountSettings.getControl("KeepConversationLogTranscripts").get();
-		S32 log_mode = keep_log_ctrlp->getValue();
-		keep_log_ctrlp->getSignal()->connect(boost::bind(&LLConversationLog::enableLogging, this, _2));
-		if (log_mode > 0)
-		{
-			enableLogging(log_mode);
-		}
-	}
 }
 
 void LLConversationLog::enableLogging(S32 log_mode)
@@ -443,6 +433,20 @@ bool LLConversationLog::moveLog(const std::string &originDirectory, const std::s
 	return true;
 }
 
+void LLConversationLog::initLoggingState()
+{
+    if (gSavedPerAccountSettings.controlExists("KeepConversationLogTranscripts"))
+    {
+        LLControlVariable * keep_log_ctrlp = gSavedPerAccountSettings.getControl("KeepConversationLogTranscripts").get();
+        S32 log_mode = keep_log_ctrlp->getValue();
+        keep_log_ctrlp->getSignal()->connect(boost::bind(&LLConversationLog::enableLogging, this, _2));
+        if (log_mode > 0)
+        {
+            enableLogging(log_mode);
+        }
+    }
+}
+
 std::string LLConversationLog::getFileName()
 {
 	std::string filename = "conversation";
diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h
index 035cbcb9451e7eb41be8747176b15ece750f84eb..46e46a3278b6c4c843b286054f56e21bf071bf3a 100644
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -111,7 +111,6 @@ class LLConversationLog : public LLSingleton<LLConversationLog>, LLIMSessionObse
 {
 	LLSINGLETON(LLConversationLog);
 public:
-
 	void removeConversation(const LLConversation& conversation);
 
 	/**
@@ -148,6 +147,12 @@ class LLConversationLog : public LLSingleton<LLConversationLog>, LLIMSessionObse
 	bool getIsLoggingEnabled() { return mLoggingEnabled; }
 	bool isLogEmpty() { return mConversations.empty(); }
 
+	/**
+	 * inits connection to per account settings,
+	 * loads saved file and inits enabled state
+	 */
+	void initLoggingState();
+
 	/**
 	 * constructs file name in which conversations log will be saved
 	 * file name is conversation.log
diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp
index 7d2712eec708f611338e0bae252facb0a078f8a8..cb5f9c8a2c98cb0ce48e1212c4130db8dc7cc8f7 100644
--- a/indra/newview/lldonotdisturbnotificationstorage.cpp
+++ b/indra/newview/lldonotdisturbnotificationstorage.cpp
@@ -48,7 +48,6 @@ const char * LLDoNotDisturbNotificationStorage::offerName = "UserGiveItem";
 
 LLDoNotDisturbNotificationStorageTimer::LLDoNotDisturbNotificationStorageTimer() : LLEventTimer(DND_TIMER)
 {
-
 }
 
 LLDoNotDisturbNotificationStorageTimer::~LLDoNotDisturbNotificationStorageTimer()
@@ -74,6 +73,7 @@ LLDoNotDisturbNotificationStorage::LLDoNotDisturbNotificationStorage()
 {
     nameToPayloadParameterMap[toastName] = "SESSION_ID";
     nameToPayloadParameterMap[offerName] = "object_id";
+    initialize();
 }
 
 LLDoNotDisturbNotificationStorage::~LLDoNotDisturbNotificationStorage()
diff --git a/indra/newview/lldonotdisturbnotificationstorage.h b/indra/newview/lldonotdisturbnotificationstorage.h
index e6cb7835e311b4277df3daf26c2363c3e8d29b62..c6f0bf1ab588ddd63fd52324bdf91f7dcd9d3516 100644
--- a/indra/newview/lldonotdisturbnotificationstorage.h
+++ b/indra/newview/lldonotdisturbnotificationstorage.h
@@ -45,7 +45,7 @@ class LLDoNotDisturbNotificationStorageTimer : public LLEventTimer
     BOOL tick();
 };
 
-class LLDoNotDisturbNotificationStorage : public LLSingleton<LLDoNotDisturbNotificationStorage>, public LLNotificationStorage
+class LLDoNotDisturbNotificationStorage : public LLParamSingleton<LLDoNotDisturbNotificationStorage>, public LLNotificationStorage
 {
 	LLSINGLETON(LLDoNotDisturbNotificationStorage);
 	~LLDoNotDisturbNotificationStorage();
@@ -55,7 +55,6 @@ class LLDoNotDisturbNotificationStorage : public LLSingleton<LLDoNotDisturbNotif
     static const char * toastName;
     static const char * offerName;
 
-	void initialize();
     bool getDirty();
     void resetDirty();
 	void saveNotifications();
@@ -66,6 +65,8 @@ class LLDoNotDisturbNotificationStorage : public LLSingleton<LLDoNotDisturbNotif
 protected:
 
 private:
+    void initialize();
+
     bool mDirty;
     LLDoNotDisturbNotificationStorageTimer mTimer;
 
diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp
index d657f04457ab937c3070a1a41e703099d847af82..3395777aab42424db453fa9314140951e6814f46 100644
--- a/indra/newview/llexpandabletextbox.cpp
+++ b/indra/newview/llexpandabletextbox.cpp
@@ -97,7 +97,7 @@ class LLExpanderSegment : public LLTextSegment
 	/*virtual*/ BOOL	handleMouseUp(S32 x, S32 y, MASK mask) { mEditor.onCommit(); return TRUE; }
 	/*virtual*/ BOOL	handleHover(S32 x, S32 y, MASK mask) 
 	{
-		LLUI::getWindow()->setCursor(UI_CURSOR_HAND);
+		LLUI::getInstance()->getWindow()->setCursor(UI_CURSOR_HAND);
 		return TRUE; 
 	}
 private:
diff --git a/indra/newview/llexternaleditor.cpp b/indra/newview/llexternaleditor.cpp
index 776bbf78c2a8dd2ce28d27551c742df42e559207..b66eb754a48c684aea5279944b89106b18a0e326 100644
--- a/indra/newview/llexternaleditor.cpp
+++ b/indra/newview/llexternaleditor.cpp
@@ -184,9 +184,9 @@ std::string LLExternalEditor::findCommand(
 		cmd = override;
 		LL_INFOS() << "Using override" << LL_ENDL;
 	}
-	else if (!LLUI::sSettingGroups["config"]->getString(sSetting).empty())
+	else if (!LLUI::getInstance()->mSettingGroups["config"]->getString(sSetting).empty())
 	{
-		cmd = LLUI::sSettingGroups["config"]->getString(sSetting);
+		cmd = LLUI::getInstance()->mSettingGroups["config"]->getString(sSetting);
 		LL_INFOS() << "Using setting" << LL_ENDL;
 	}
 	else                    // otherwise use the path specified by the environment variable
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 1d782cdabea5b34b71bdd703e73ab91051a189fb..85ee33edb19234b99736aba2c106c52b4cd3a71e 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -228,12 +228,6 @@ void LLFace::destroy()
 	mVObjp = NULL;
 }
 
-
-// static
-void LLFace::initClass()
-{
-}
-
 void LLFace::setWorldMatrix(const LLMatrix4 &mat)
 {
 	LL_ERRS() << "Faces on this drawable are not independently modifiable\n" << LL_ENDL;
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index a08e730e54c4beaf68ce059440a116db63f9af02..77861f7d2f9016b21e1f2e5e53b9236d6f5e836f 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -80,8 +80,6 @@ class LLFace : public LLTrace::MemTrackableNonVirtual<LLFace, 16>
 		PARTICLE		= 0x0080,
 	};
 
-	static void initClass();
-
 	static void cacheFaceInVRAM(const LLVolumeFace& vf);
 
 public:
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index 8d07035b97d85dcc528472db0d2b2c42b04b0d8e..aa9cba0c188b650e1527e53e7f5d61cfd91d4815 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -522,7 +522,7 @@ void LLFeatureManager::cleanupFeatureTables()
 	mMaskList.clear();
 }
 
-void LLFeatureManager::init()
+void LLFeatureManager::initSingleton()
 {
 	// load the tables
 	loadFeatureTables();
diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h
index f77861a1a754f4efa001027f946ac55897000d46..42a226cd18f843bdc40ed58e07f30543e58eedc4 100644
--- a/indra/newview/llfeaturemanager.h
+++ b/indra/newview/llfeaturemanager.h
@@ -100,9 +100,10 @@ class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManag
 	LLSINGLETON(LLFeatureManager);
 	~LLFeatureManager() {cleanupFeatureTables();}
 
-public:
 	// initialize this by loading feature table and gpu table
-	void init();
+	void initSingleton();
+
+public:
 
 	void maskCurrentList(const std::string& name); // Mask the current feature list with the named list
 
diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp
index 2e1afc68b40427407430d97a731f5c37e508db0f..1ce9fe3a7ad0a27d47f5a024bf80ac98bae382a4 100644
--- a/indra/newview/llfirstuse.cpp
+++ b/indra/newview/llfirstuse.cpp
@@ -40,37 +40,6 @@
 #include "lltracker.h"
 
 
-// static
-std::set<std::string> LLFirstUse::sConfigVariables;
-
-// static
-void LLFirstUse::addConfigVariable(const std::string& var)
-{
-	sConfigVariables.insert(var);
-}
-
-// static
-void LLFirstUse::disableFirstUse()
-{
-	// Set all first-use warnings to disabled
-	for (std::set<std::string>::iterator iter = sConfigVariables.begin();
-		 iter != sConfigVariables.end(); ++iter)
-	{
-		gWarningSettings.setBOOL(*iter, FALSE);
-	}
-}
-
-// static
-void LLFirstUse::resetFirstUse()
-{
-	// Set all first-use warnings to disabled
-	for (std::set<std::string>::iterator iter = sConfigVariables.begin();
-		 iter != sConfigVariables.end(); ++iter)
-	{
-		gWarningSettings.setBOOL(*iter, TRUE);
-	}
-}
-
 // static
 void LLFirstUse::otherAvatarChatFirst(bool enable)
 {
diff --git a/indra/newview/llfirstuse.h b/indra/newview/llfirstuse.h
index 4c8c9d3cde6b00fd622014652d3cedc13e45b95f..80b83580b389ebaa0bc8f3ff424771c9f6cf3433 100644
--- a/indra/newview/llfirstuse.h
+++ b/indra/newview/llfirstuse.h
@@ -78,14 +78,6 @@ class LLNotification;
 class LLFirstUse
 {
 public:
-
-	// Add a config variable to be reset on resetFirstUse()
-	static void addConfigVariable(const std::string& var);
-	
-	// Sets all controls back to show the dialogs.
-	static void disableFirstUse();
-	static void resetFirstUse();
-
 	static void otherAvatarChatFirst(bool enable = true);
 	static void speak(bool enable = true);
 	static void sit(bool enable = true);
@@ -100,7 +92,6 @@ class LLFirstUse
 	
 protected:
 	static void firstUseNotification(const std::string& control_var, bool enable, const std::string& notification_name, LLSD args = LLSD(), LLSD payload = LLSD());
-	static std::set<std::string> sConfigVariables;
 
 	static void init();
 	static bool processNotification(const LLSD& notify);
diff --git a/indra/newview/llflickrconnect.cpp b/indra/newview/llflickrconnect.cpp
deleted file mode 100644
index d7d161f239a1cfed6300ecb6b73bcb2ea75b2961..0000000000000000000000000000000000000000
--- a/indra/newview/llflickrconnect.cpp
+++ /dev/null
@@ -1,538 +0,0 @@
-/** 
- * @file llflickrconnect.h
- * @author Merov, Cho
- * @brief Connection to Flickr Service
- *
- * $LicenseInfo:firstyear=2013&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2013, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llflickrconnect.h"
-
-#include "llagent.h"
-#include "llcallingcard.h"			// for LLAvatarTracker
-#include "llcommandhandler.h"
-#include "llnotificationsutil.h"
-#include "llurlaction.h"
-#include "llimagepng.h"
-#include "llimagejpeg.h"
-#include "lltrans.h"
-#include "llevents.h"
-#include "llviewerregion.h"
-
-#include "llfloaterwebcontent.h"
-#include "llfloaterreg.h"
-#include "llcorehttputil.h"
-
-boost::scoped_ptr<LLEventPump> LLFlickrConnect::sStateWatcher(new LLEventStream("FlickrConnectState"));
-boost::scoped_ptr<LLEventPump> LLFlickrConnect::sInfoWatcher(new LLEventStream("FlickrConnectInfo"));
-boost::scoped_ptr<LLEventPump> LLFlickrConnect::sContentWatcher(new LLEventStream("FlickrConnectContent"));
-
-// Local functions
-void log_flickr_connect_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description)
-{
-    // Note: 302 (redirect) is *not* an error that warrants logging
-    if (status != 302)
-    {
-		LL_WARNS("FlickrConnect") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << " (" << description << ")" << LL_ENDL;
-    }
-}
-
-void toast_user_for_flickr_success()
-{
-	LLSD args;
-    args["MESSAGE"] = LLTrans::getString("flickr_post_success");
-    LLNotificationsUtil::add("FlickrConnect", args);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLFlickrConnect::flickrConnectCoro(std::string requestToken, std::string oauthVerifier)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    LLSD body;
-    if (!requestToken.empty())
-        body["request_token"] = requestToken;
-    if (!oauthVerifier.empty())
-        body["oauth_verifier"] = oauthVerifier;
-
-    setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS);
-
-    LLSD result = httpAdapter->putAndSuspend(httpRequest, getFlickrConnectURL("/connection"), body, httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (!status)
-    {
-        if ( status == LLCore::HttpStatus(HTTP_FOUND) )
-        {
-            std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION];
-            if (location.empty())
-            {
-                LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL;
-            }
-            else
-            {
-                openFlickrWeb(location);
-            }
-        }
-        else
-        {
-            LL_WARNS("FlickrConnect") << "Connection failed " << status.toString() << LL_ENDL;
-            setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED);
-            log_flickr_connect_error("Connect", status.getStatus(), status.toString(),
-                result.get("error_code"), result.get("error_description"));
-        }
-    }
-    else
-    {
-        LL_DEBUGS("FlickrConnect") << "Connect successful. " << LL_ENDL;
-        setConnectionState(LLFlickrConnect::FLICKR_CONNECTED);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-bool LLFlickrConnect::testShareStatus(LLSD &result)
-{
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (status)
-        return true;
-
-    if (status == LLCore::HttpStatus(HTTP_FOUND))
-    {
-        std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION];
-        if (location.empty())
-        {
-            LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL;
-        }
-        else
-        {
-            openFlickrWeb(location);
-        }
-    }
-    if (status == LLCore::HttpStatus(HTTP_NOT_FOUND))
-    {
-        LL_DEBUGS("FlickrConnect") << "Not connected. " << LL_ENDL;
-        connectToFlickr();
-    }
-    else
-    {
-        LL_WARNS("FlickrConnect") << "HTTP Status error " << status.toString() << LL_ENDL;
-        setConnectionState(LLFlickrConnect::FLICKR_POST_FAILED);
-        log_flickr_connect_error("Share", status.getStatus(), status.toString(),
-            result.get("error_code"), result.get("error_description"));
-    }
-    return false;
-}
-
-void LLFlickrConnect::flickrShareCoro(LLSD share)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    LLSD result = httpAdapter->postAndSuspend(httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts);
-
-    if (testShareStatus(result))
-    {
-        toast_user_for_flickr_success();
-        LL_DEBUGS("FlickrConnect") << "Post successful. " << LL_ENDL;
-        setConnectionState(LLFlickrConnect::FLICKR_POSTED);
-    }
-
-}
-
-void LLFlickrConnect::flickrShareImageCoro(LLPointer<LLImageFormatted> image, std::string title, std::string description, std::string tags, int safetyLevel)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    std::string imageFormat;
-    if (dynamic_cast<LLImagePNG*>(image.get()))
-    {
-        imageFormat = "png";
-    }
-    else if (dynamic_cast<LLImageJPEG*>(image.get()))
-    {
-        imageFormat = "jpg";
-    }
-    else
-    {
-        LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL;
-        return;
-    }
-
-    // All this code is mostly copied from LLWebProfile::post()
-    const std::string boundary = "----------------------------0123abcdefab";
-
-    std::string contentType = "multipart/form-data; boundary=" + boundary;
-    httpHeaders->append("Content-Type", contentType.c_str());
-
-    LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // 
-    LLCore::BufferArrayStream body(raw.get());
-
-    // *NOTE: The order seems to matter.
-    body << "--" << boundary << "\r\n"
-        << "Content-Disposition: form-data; name=\"title\"\r\n\r\n"
-        << title << "\r\n";
-
-    body << "--" << boundary << "\r\n"
-        << "Content-Disposition: form-data; name=\"description\"\r\n\r\n"
-        << description << "\r\n";
-
-    body << "--" << boundary << "\r\n"
-        << "Content-Disposition: form-data; name=\"tags\"\r\n\r\n"
-        << tags << "\r\n";
-
-    body << "--" << boundary << "\r\n"
-        << "Content-Disposition: form-data; name=\"safety_level\"\r\n\r\n"
-        << safetyLevel << "\r\n";
-
-    body << "--" << boundary << "\r\n"
-        << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n"
-        << "Content-Type: image/" << imageFormat << "\r\n\r\n";
-
-    // Insert the image data.
-    // *FIX: Treating this as a string will probably screw it up ...
-    U8* image_data = image->getData();
-    for (S32 i = 0; i < image->getDataSize(); ++i)
-    {
-        body << image_data[i];
-    }
-
-    body << "\r\n--" << boundary << "--\r\n";
-
-    LLSD result = httpAdapter->postAndSuspend(httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders);
-
-    if (testShareStatus(result))
-    {
-        toast_user_for_flickr_success();
-        LL_DEBUGS("FlickrConnect") << "Post successful. " << LL_ENDL;
-        setConnectionState(LLFlickrConnect::FLICKR_POSTED);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLFlickrConnect::flickrDisconnectCoro()
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    setConnectionState(LLFlickrConnect::FLICKR_DISCONNECTING);
-    httpOpts->setFollowRedirects(false);
-
-    LLSD result = httpAdapter->deleteAndSuspend(httpRequest, getFlickrConnectURL("/connection"), httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND)))
-    {
-        LL_WARNS("FlickrConnect") << "Disconnect failed!" << LL_ENDL;
-        setConnectionState(LLFlickrConnect::FLICKR_DISCONNECT_FAILED);
-
-        log_flickr_connect_error("Disconnect", status.getStatus(), status.toString(),
-            result.get("error_code"), result.get("error_description"));
-    }
-    else
-    {
-        LL_DEBUGS("FlickrConnect") << "Disconnect successful. " << LL_ENDL;
-        clearInfo();
-        setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLFlickrConnect::flickrConnectedCoro(bool autoConnect)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS);
-
-    httpOpts->setFollowRedirects(false);
-
-    LLSD result = httpAdapter->getAndSuspend(httpRequest, getFlickrConnectURL("/connection", true), httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (!status)
-    {
-        if (status == LLCore::HttpStatus(HTTP_NOT_FOUND))
-        {
-            LL_DEBUGS("FlickrConnect") << "Not connected. " << LL_ENDL;
-            if (autoConnect)
-            {
-                connectToFlickr();
-            }
-            else
-            {
-                setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED);
-            }
-        }
-        else
-        {
-            LL_WARNS("FlickrConnect") << "Failed to test connection:" << status.toTerseString() << LL_ENDL;
-
-            setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED);
-            log_flickr_connect_error("Connected", status.getStatus(), status.toString(),
-                result.get("error_code"), result.get("error_description"));
-        }
-    }
-    else
-    {
-        LL_DEBUGS("FlickrConnect") << "Connect successful. " << LL_ENDL;
-        setConnectionState(LLFlickrConnect::FLICKR_CONNECTED);
-    }
-
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLFlickrConnect::flickrInfoCoro()
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    LLSD result = httpAdapter->getAndSuspend(httpRequest, getFlickrConnectURL("/info", true), httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (status == LLCore::HttpStatus(HTTP_FOUND))
-    {
-        std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION];
-        if (location.empty())
-        {
-            LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL;
-        }
-        else
-        {
-            openFlickrWeb(location);
-        }
-    }
-    else if (!status)
-    {
-        LL_WARNS("FlickrConnect") << "Flickr Info failed: " << status.toString() << LL_ENDL;
-        log_flickr_connect_error("Info", status.getStatus(), status.toString(),
-            result.get("error_code"), result.get("error_description"));
-    }
-    else
-    {
-        LL_INFOS("FlickrConnect") << "Flickr: Info received" << LL_ENDL;
-        result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS);
-        storeInfo(result);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-LLFlickrConnect::LLFlickrConnect()
-:	mConnectionState(FLICKR_NOT_CONNECTED),
-	mConnected(false),
-	mInfo(),
-	mRefreshInfo(false),
-	mReadFromMaster(false)
-{
-}
-
-void LLFlickrConnect::openFlickrWeb(std::string url)
-{
-	LLFloaterWebContent::Params p;
-    p.url(url);
-    p.show_chrome(true);
-    p.allow_back_forward_navigation(false);
-    p.clean_browser(true);
-	LLFloater *floater = LLFloaterReg::showInstance("flickr_web", p);
-	//the internal web browser has a bug that prevents it from gaining focus unless a mouse event occurs first (it seems).
-	//So when showing the internal web browser, set focus to it's containing floater "flickr_web". When a mouse event 
-	//occurs on the "webbrowser" panel part of the floater, a mouse cursor will properly show and the "webbrowser" will gain focus.
-	//flickr_web floater contains the "webbrowser" panel.    JIRA: ACME-744
-	gFocusMgr.setKeyboardFocus( floater );
-
-	//LLUrlAction::openURLExternal(url);
-}
-
-std::string LLFlickrConnect::getFlickrConnectURL(const std::string& route, bool include_read_from_master)
-{
-    std::string url("");
-    LLViewerRegion *regionp = gAgent.getRegion();
-    if (regionp)
-    {
-		//url = "http://pdp15.lindenlab.com/flickr/agent/" + gAgentID.asString(); // TEMPORARY FOR TESTING - CHO
-        url = regionp->getCapability("FlickrConnect");
-        url += route;
-    
-        if (include_read_from_master && mReadFromMaster)
-        {
-            url += "?read_from_master=true";
-        }
-    }
-	return url;
-}
-
-void LLFlickrConnect::connectToFlickr(const std::string& request_token, const std::string& oauth_verifier)
-{
-    LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro",
-        boost::bind(&LLFlickrConnect::flickrConnectCoro, this, request_token, oauth_verifier));
-}
-
-void LLFlickrConnect::disconnectFromFlickr()
-{
-    LLCoros::instance().launch("LLFlickrConnect::flickrDisconnectCoro",
-        boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this));
-}
-
-void LLFlickrConnect::checkConnectionToFlickr(bool auto_connect)
-{
-    LLCoros::instance().launch("LLFlickrConnect::flickrConnectedCoro",
-        boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, auto_connect));
-}
-
-void LLFlickrConnect::loadFlickrInfo()
-{
-	if(mRefreshInfo)
-	{
-        LLCoros::instance().launch("LLFlickrConnect::flickrInfoCoro",
-            boost::bind(&LLFlickrConnect::flickrInfoCoro, this));
-	}
-}
-
-void LLFlickrConnect::uploadPhoto(const std::string& image_url, const std::string& title, const std::string& description, const std::string& tags, int safety_level)
-{
-	LLSD body;
-	body["image"] = image_url;
-	body["title"] = title;
-	body["description"] = description;
-	body["tags"] = tags;
-	body["safety_level"] = safety_level;
-
-    setConnectionState(LLFlickrConnect::FLICKR_POSTING);
-
-    LLCoros::instance().launch("LLFlickrConnect::flickrShareCoro",
-        boost::bind(&LLFlickrConnect::flickrShareCoro, this, body));
-}
-
-void LLFlickrConnect::uploadPhoto(LLPointer<LLImageFormatted> image, const std::string& title, const std::string& description, const std::string& tags, int safety_level)
-{
-    setConnectionState(LLFlickrConnect::FLICKR_POSTING);
-
-    LLCoros::instance().launch("LLFlickrConnect::flickrShareImageCoro",
-        boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, image, 
-        title, description, tags, safety_level));
-}
-
-void LLFlickrConnect::storeInfo(const LLSD& info)
-{
-	mInfo = info;
-	mRefreshInfo = false;
-
-	sInfoWatcher->post(info);
-}
-
-const LLSD& LLFlickrConnect::getInfo() const
-{
-	return mInfo;
-}
-
-void LLFlickrConnect::clearInfo()
-{
-	mInfo = LLSD();
-}
-
-void LLFlickrConnect::setDataDirty()
-{
-	mRefreshInfo = true;
-}
-
-void LLFlickrConnect::setConnectionState(LLFlickrConnect::EConnectionState connection_state)
-{
-	if(connection_state == FLICKR_CONNECTED)
-	{
-		mReadFromMaster = true;
-		setConnected(true);
-		setDataDirty();
-	}
-	else if(connection_state == FLICKR_NOT_CONNECTED)
-	{
-		setConnected(false);
-	}
-	else if(connection_state == FLICKR_POSTED)
-	{
-		mReadFromMaster = false;
-	}
-
-	if (mConnectionState != connection_state)
-	{
-		// set the connection state before notifying watchers
-		mConnectionState = connection_state;
-
-		LLSD state_info;
-		state_info["enum"] = connection_state;
-		sStateWatcher->post(state_info);
-	}
-}
-
-void LLFlickrConnect::setConnected(bool connected)
-{
-	mConnected = connected;
-}
diff --git a/indra/newview/llflickrconnect.h b/indra/newview/llflickrconnect.h
deleted file mode 100644
index 43cadca708957bcc170c502ef55e760435222e7c..0000000000000000000000000000000000000000
--- a/indra/newview/llflickrconnect.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/** 
- * @file llflickrconnect.h
- * @author Merov, Cho
- * @brief Connection to Flickr Service
- *
- * $LicenseInfo:firstyear=2013&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2013, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLFLICKRCONNECT_H
-#define LL_LLFLICKRCONNECT_H
-
-#include "llsingleton.h"
-#include "llimage.h"
-#include "llcoros.h"
-#include "lleventcoro.h"
-
-class LLEventPump;
-
-/**
- * @class LLFlickrConnect
- *
- * Manages authentication to, and interaction with, a web service allowing the
- * the viewer to upload photos to Flickr.
- */
-class LLFlickrConnect : public LLSingleton<LLFlickrConnect>
-{
-	LLSINGLETON(LLFlickrConnect);
-	~LLFlickrConnect() {};
-	LOG_CLASS(LLFlickrConnect);
-public:
-    enum EConnectionState
-	{
-		FLICKR_NOT_CONNECTED = 0,
-		FLICKR_CONNECTION_IN_PROGRESS = 1,
-		FLICKR_CONNECTED = 2,
-		FLICKR_CONNECTION_FAILED = 3,
-		FLICKR_POSTING = 4,
-		FLICKR_POSTED = 5,
-		FLICKR_POST_FAILED = 6,
-		FLICKR_DISCONNECTING = 7,
-		FLICKR_DISCONNECT_FAILED = 8
-	};
-	
-	void connectToFlickr(const std::string& request_token = "", const std::string& oauth_verifier = "");	// Initiate the complete Flickr connection. Please use checkConnectionToFlickr() in normal use.
-	void disconnectFromFlickr();																			// Disconnect from the Flickr service.
-    void checkConnectionToFlickr(bool auto_connect = false);												// Check if an access token is available on the Flickr service. If not, call connectToFlickr().
-    
-	void loadFlickrInfo();
-	void uploadPhoto(const std::string& image_url, const std::string& title, const std::string& description, const std::string& tags, int safety_level);
-	void uploadPhoto(LLPointer<LLImageFormatted> image, const std::string& title, const std::string& description, const std::string& tags, int safety_level);
-	
-	void storeInfo(const LLSD& info);
-	const LLSD& getInfo() const;
-	void clearInfo();
-	void setDataDirty();
-    
-    void setConnectionState(EConnectionState connection_state);
-	void setConnected(bool connected);
-	bool isConnected() { return mConnected; }
-	bool isTransactionOngoing() { return ((mConnectionState == FLICKR_CONNECTION_IN_PROGRESS) || (mConnectionState == FLICKR_POSTING) || (mConnectionState == FLICKR_DISCONNECTING)); }
-    EConnectionState getConnectionState() { return mConnectionState; }
-    
-    void openFlickrWeb(std::string url);
-
-private:
-
- 	std::string getFlickrConnectURL(const std::string& route = "", bool include_read_from_master = false);
-
-    EConnectionState mConnectionState;
-	BOOL mConnected;
-	LLSD mInfo;
-	bool mRefreshInfo;
-	bool mReadFromMaster;
-	
-	static boost::scoped_ptr<LLEventPump> sStateWatcher;
-	static boost::scoped_ptr<LLEventPump> sInfoWatcher;
-	static boost::scoped_ptr<LLEventPump> sContentWatcher;
-
-    bool testShareStatus(LLSD &result);
-    void flickrConnectCoro(std::string requestToken, std::string oauthVerifier);
-    void flickrShareCoro(LLSD share);
-    void flickrShareImageCoro(LLPointer<LLImageFormatted> image, std::string title, std::string description, std::string tags, int safetyLevel);
-    void flickrDisconnectCoro();
-    void flickrConnectedCoro(bool autoConnect);
-    void flickrInfoCoro();
-
-};
-
-#endif // LL_LLFLICKRCONNECT_H
diff --git a/indra/newview/llfloaterbigpreview.h b/indra/newview/llfloaterbigpreview.h
index 63c6784d36ead97349c3de495c53fbed90650363..513ed8da6ef65e77c71714ed45faff6586942467 100644
--- a/indra/newview/llfloaterbigpreview.h
+++ b/indra/newview/llfloaterbigpreview.h
@@ -1,6 +1,6 @@
 /** 
 * @file   llfloaterbigpreview.h
-* @brief  Display of extended (big) preview for snapshots and SL Share
+* @brief  Display of extended (big) preview for snapshots
 * @author merov@lindenlab.com
 *
 * $LicenseInfo:firstyear=2013&license=viewerlgpl$
diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp
index 080d0ed8ea914b30ee3697c176fc8a2eabad8338..ee7e6f85621d745265b972d1c41b0c4d6d582164 100644
--- a/indra/newview/llfloaterbvhpreview.cpp
+++ b/indra/newview/llfloaterbvhpreview.cpp
@@ -527,7 +527,7 @@ BOOL LLFloaterBvhPreview::handleHover(S32 x, S32 y, MASK mask)
 
 		mAnimPreview->requestUpdate();
 
-		LLUI::setMousePositionLocal(this, mLastMouseX, mLastMouseY);
+		LLUI::getInstance()->setMousePositionLocal(this, mLastMouseX, mLastMouseY);
 	}
 
 	if (!mPreviewRect.pointInRect(x, y) || !mAnimPreview)
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 20d650fa37187d3a97d98695e8402d2cef5a8bc8..f3406d93bb11ed388397ac50f1ad032d34d73a9b 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -351,7 +351,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val)
 	mCurrMode(CAMERA_CTRL_MODE_PAN),
 	mPrevMode(CAMERA_CTRL_MODE_PAN)
 {
-	LLHints::registerHintTarget("view_popup", getHandle());
+	LLHints::getInstance()->registerHintTarget("view_popup", getHandle());
 	mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
 }
 
diff --git a/indra/newview/llfloaterchatvoicevolume.cpp b/indra/newview/llfloaterchatvoicevolume.cpp
index 3c76a3a43cdfc1627d748cbef99e5b78a99ec603..45aea00a49e3a31f5fe1ef65b836e0ece56e88f1 100644
--- a/indra/newview/llfloaterchatvoicevolume.cpp
+++ b/indra/newview/llfloaterchatvoicevolume.cpp
@@ -35,7 +35,7 @@ LLFloaterChatVoiceVolume::LLFloaterChatVoiceVolume(const LLSD& key)
 void LLFloaterChatVoiceVolume::onOpen(const LLSD& key)
 {
 	LLInspect::onOpen(key);
-	LLUI::positionViewNearMouse(this);
+	LLUI::getInstance()->positionViewNearMouse(this);
 }
 
 LLFloaterChatVoiceVolume::~LLFloaterChatVoiceVolume()
diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp
index 37186ce3d5d2d35d59890fd3e36ac3c2c049d686..44725cab7023cfbe4eb027fb598b70d4b226cc55 100644
--- a/indra/newview/llfloaterconversationpreview.cpp
+++ b/indra/newview/llfloaterconversationpreview.cpp
@@ -117,7 +117,7 @@ void LLFloaterConversationPreview::setPages(std::list<LLSD>* messages, const std
 		getChild<LLTextBox>("page_num_label")->setValue(total_page_num);
 		mShowHistory = true;
 	}
-	LLLoadHistoryThread* loadThread = LLLogChat::getLoadHistoryThread(mSessionID);
+	LLLoadHistoryThread* loadThread = LLLogChat::getInstance()->getLoadHistoryThread(mSessionID);
 	if (loadThread)
 	{
 		loadThread->removeLoadEndSignal(boost::bind(&LLFloaterConversationPreview::setPages, this, _1, _2));
@@ -141,7 +141,7 @@ void LLFloaterConversationPreview::onOpen(const LLSD& key)
 		return;
 	}
 	mOpened = true;
-	if (!LLLogChat::historyThreadsFinished(mSessionID))
+	if (!LLLogChat::getInstance()->historyThreadsFinished(mSessionID))
 	{
 		LLNotificationsUtil::add("ChatHistoryIsBusyAlert");
 		mHistoryThreadsBusy = true;
@@ -172,15 +172,16 @@ void LLFloaterConversationPreview::onOpen(const LLSD& key)
 	// LLDeleteHistoryThread is started in destructor
 	std::list<LLSD>* messages = new std::list<LLSD>();
 
-	LLLogChat::cleanupHistoryThreads();
+	LLLogChat *log_chat_inst = LLLogChat::getInstance();
+	log_chat_inst->cleanupHistoryThreads();
 	
 	LLLoadHistoryThread* loadThread = new LLLoadHistoryThread(mChatHistoryFileName, messages, load_params);
 	loadThread->setLoadEndSignal(boost::bind(&LLFloaterConversationPreview::setPages, this, _1, _2));
 	loadThread->start();
-	LLLogChat::addLoadHistoryThread(mSessionID, loadThread);
+	log_chat_inst->addLoadHistoryThread(mSessionID, loadThread);
 
 	LLDeleteHistoryThread* deleteThread = new LLDeleteHistoryThread(messages, loadThread);
-	LLLogChat::addDeleteHistoryThread(mSessionID, deleteThread);
+	log_chat_inst->addDeleteHistoryThread(mSessionID, deleteThread);
 
 	mShowHistory = true;
 }
@@ -190,7 +191,7 @@ void LLFloaterConversationPreview::onClose(bool app_quitting)
 	mOpened = false;
 	if (!mHistoryThreadsBusy)
 	{
-		LLDeleteHistoryThread* deleteThread = LLLogChat::getDeleteHistoryThread(mSessionID);
+		LLDeleteHistoryThread* deleteThread = LLLogChat::getInstance()->getDeleteHistoryThread(mSessionID);
 		if (deleteThread)
 		{
 			deleteThread->start();
@@ -228,7 +229,7 @@ void LLFloaterConversationPreview::showHistory()
 		else
  		{
 			std::string legacy_name = gCacheName->buildLegacyName(from);
-			from_id = LLAvatarNameCache::findIdByName(legacy_name);
+			from_id = LLAvatarNameCache::getInstance()->findIdByName(legacy_name);
  		}
 
 		LLChat chat;
diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp
deleted file mode 100644
index 69a92b2b54c06cec017933cd77c295c2adf2e93e..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterflickr.cpp
+++ /dev/null
@@ -1,787 +0,0 @@
-/** 
-* @file llfloaterflickr.cpp
-* @brief Implementation of llfloaterflickr
-* @author cho@lindenlab.com
-*
-* $LicenseInfo:firstyear=2013&license=viewerlgpl$
-* Second Life Viewer Source Code
-* Copyright (C) 2013, Linden Research, Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation;
-* version 2.1 of the License only.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*
-* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
-* $/LicenseInfo$
-*/
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llfloaterflickr.h"
-
-#include "llagent.h"
-#include "llagentui.h"
-#include "llcheckboxctrl.h"
-#include "llcombobox.h"
-#include "llflickrconnect.h"
-#include "llfloaterreg.h"
-#include "lliconctrl.h"
-#include "llimagefiltersmanager.h"
-#include "llresmgr.h"		// LLLocale
-#include "llsdserialize.h"
-#include "llloadingindicator.h"
-#include "llslurl.h"
-#include "lltrans.h"
-#include "llsnapshotlivepreview.h"
-#include "llfloaterbigpreview.h"
-#include "llviewerregion.h"
-#include "llviewercontrol.h"
-#include "llviewermedia.h"
-#include "lltabcontainer.h"
-#include "llviewerparcelmgr.h"
-#include "llviewerregion.h"
-#include <boost/regex.hpp>
-static LLPanelInjector<LLFlickrPhotoPanel> t_panel_photo("llflickrphotopanel");
-static LLPanelInjector<LLFlickrAccountPanel> t_panel_account("llflickraccountpanel");
-
-const std::string DEFAULT_PHOTO_QUERY_PARAMETERS = "?sourceid=slshare_photo&utm_source=flickr&utm_medium=photo&utm_campaign=slshare";
-const std::string DEFAULT_TAG_TEXT = "secondlife ";
-const std::string FLICKR_MACHINE_TAGS_NAMESPACE = "secondlife";
-
-///////////////////////////
-//LLFlickrPhotoPanel///////
-///////////////////////////
-
-LLFlickrPhotoPanel::LLFlickrPhotoPanel() :
-mResolutionComboBox(NULL),
-mRefreshBtn(NULL),
-mBtnPreview(NULL),
-mWorkingLabel(NULL),
-mThumbnailPlaceholder(NULL),
-mTitleTextBox(NULL),
-mDescriptionTextBox(NULL),
-mLocationCheckbox(NULL),
-mTagsTextBox(NULL),
-mRatingComboBox(NULL),
-mBigPreviewFloater(NULL),
-mPostButton(NULL)
-{
-	mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLFlickrPhotoPanel::onSend, this));
-	mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLFlickrPhotoPanel::onClickNewSnapshot, this));
-	mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLFlickrPhotoPanel::onClickBigPreview, this));
-}
-
-LLFlickrPhotoPanel::~LLFlickrPhotoPanel()
-{
-	if(mPreviewHandle.get())
-	{
-		mPreviewHandle.get()->die();
-	}
-}
-
-BOOL LLFlickrPhotoPanel::postBuild()
-{
-	setVisibleCallback(boost::bind(&LLFlickrPhotoPanel::onVisibilityChange, this, _2));
-	
-	mResolutionComboBox = getChild<LLUICtrl>("resolution_combobox");
-	mResolutionComboBox->setCommitCallback(boost::bind(&LLFlickrPhotoPanel::updateResolution, this, TRUE));
-	mFilterComboBox = getChild<LLUICtrl>("filters_combobox");
-	mFilterComboBox->setCommitCallback(boost::bind(&LLFlickrPhotoPanel::updateResolution, this, TRUE));
-	mRefreshBtn = getChild<LLUICtrl>("new_snapshot_btn");
-	mBtnPreview = getChild<LLButton>("big_preview_btn");
-    mWorkingLabel = getChild<LLUICtrl>("working_lbl");
-	mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder");
-	mTitleTextBox = getChild<LLUICtrl>("photo_title");
-	mDescriptionTextBox = getChild<LLUICtrl>("photo_description");
-	mLocationCheckbox = getChild<LLUICtrl>("add_location_cb");
-	mTagsTextBox = getChild<LLUICtrl>("photo_tags");
-	mTagsTextBox->setValue(DEFAULT_TAG_TEXT);
-	mRatingComboBox = getChild<LLUICtrl>("rating_combobox");
-	mPostButton = getChild<LLUICtrl>("post_photo_btn");
-	mCancelButton = getChild<LLUICtrl>("cancel_photo_btn");
-	mBigPreviewFloater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview"));
-
-	// Update filter list
-    std::vector<std::string> filter_list = LLImageFiltersManager::getInstance()->getFiltersList();
-	LLComboBox* filterbox = static_cast<LLComboBox *>(mFilterComboBox);
-    for (U32 i = 0; i < filter_list.size(); i++) 
-	{
-        filterbox->add(filter_list[i]);
-    }
-
-	return LLPanel::postBuild();
-}
-
-// virtual
-S32 LLFlickrPhotoPanel::notify(const LLSD& info)
-{
-	if (info.has("snapshot-updating"))
-	{
-        // Disable the Post button and whatever else while the snapshot is not updated
-        // updateControls();
-		return 1;
-	}
-    
-	if (info.has("snapshot-updated"))
-	{
-        // Enable the send/post/save buttons.
-        updateControls();
-        
-		// The refresh button is initially hidden. We show it after the first update,
-		// i.e. after snapshot is taken
-		LLUICtrl * refresh_button = getRefreshBtn();
-		if (!refresh_button->getVisible())
-		{
-			refresh_button->setVisible(true);
-		}
-		return 1;
-	}
-    
-	return 0;
-}
-
-void LLFlickrPhotoPanel::draw()
-{ 
-	LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
-
-    // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts)
-    bool no_ongoing_connection = !(LLFlickrConnect::instance().isTransactionOngoing());
-    mCancelButton->setEnabled(no_ongoing_connection);
-    mTitleTextBox->setEnabled(no_ongoing_connection);
-    mDescriptionTextBox->setEnabled(no_ongoing_connection);
-    mTagsTextBox->setEnabled(no_ongoing_connection);
-    mRatingComboBox->setEnabled(no_ongoing_connection);
-    mResolutionComboBox->setEnabled(no_ongoing_connection);
-    mFilterComboBox->setEnabled(no_ongoing_connection);
-    mRefreshBtn->setEnabled(no_ongoing_connection);
-    mBtnPreview->setEnabled(no_ongoing_connection);
-    mLocationCheckbox->setEnabled(no_ongoing_connection);
-    
-    // Reassign the preview floater if we have the focus and the preview exists
-    if (hasFocus() && isPreviewVisible())
-    {
-        attachPreview();
-    }
-    
-    // Toggle the button state as appropriate
-    bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType<LLFloater>()));
-	mBtnPreview->setToggleState(preview_active);
-    
-    // Display the preview if one is available
-	if (previewp && previewp->getThumbnailImage())
-	{
-		const LLRect& thumbnail_rect = mThumbnailPlaceholder->getRect();
-		const S32 thumbnail_w = previewp->getThumbnailWidth();
-		const S32 thumbnail_h = previewp->getThumbnailHeight();
-
-		// calc preview offset within the preview rect
-		const S32 local_offset_x = (thumbnail_rect.getWidth()  - thumbnail_w) / 2 ;
-		const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ;
-		S32 offset_x = thumbnail_rect.mLeft + local_offset_x;
-		S32 offset_y = thumbnail_rect.mBottom + local_offset_y;
-
-		gGL.matrixMode(LLRender::MM_MODELVIEW);
-		// Apply floater transparency to the texture unless the floater is focused.
-		F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
-		LLColor4 color = LLColor4::white;
-		gl_draw_scaled_image(offset_x, offset_y, 
-			thumbnail_w, thumbnail_h,
-			previewp->getThumbnailImage(), color % alpha);
-	}
-
-    // Update the visibility of the working (computing preview) label
-    mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate()));
-    
-    // Enable Post if we have a preview to send and no on going connection being processed
-    mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate()));
-    
-    // Draw the rest of the panel on top of it
-	LLPanel::draw();
-}
-
-LLSnapshotLivePreview* LLFlickrPhotoPanel::getPreviewView()
-{
-	LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get();
-	return previewp;
-}
-
-void LLFlickrPhotoPanel::onVisibilityChange(BOOL visible)
-{
-	if (visible)
-	{
-		if (mPreviewHandle.get())
-		{
-			LLSnapshotLivePreview* preview = getPreviewView();
-			if(preview)
-			{
-				LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL;
-				preview->updateSnapshot(TRUE);
-			}
-		}
-		else
-		{
-			LLRect full_screen_rect = getRootView()->getRect();
-			LLSnapshotLivePreview::Params p;
-			p.rect(full_screen_rect);
-			LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p);
-			mPreviewHandle = previewp->getHandle();
-
-            previewp->setContainer(this);
-            previewp->setSnapshotType(LLSnapshotModel::SNAPSHOT_WEB);
-            previewp->setSnapshotFormat(LLSnapshotModel::SNAPSHOT_FORMAT_PNG);
-            previewp->setThumbnailSubsampled(TRUE);     // We want the preview to reflect the *saved* image
-            previewp->setAllowRenderUI(FALSE);          // We do not want the rendered UI in our snapshots
-            previewp->setAllowFullScreenPreview(FALSE);  // No full screen preview in SL Share mode
-			previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect());
-
-			updateControls();
-		}
-	}
-}
-
-void LLFlickrPhotoPanel::onClickNewSnapshot()
-{
-	LLSnapshotLivePreview* previewp = getPreviewView();
-	if (previewp)
-	{
-		previewp->updateSnapshot(TRUE);
-	}
-}
-
-void LLFlickrPhotoPanel::onClickBigPreview()
-{
-    // Toggle the preview
-    if (isPreviewVisible())
-    {
-        LLFloaterReg::hideInstance("big_preview");
-    }
-    else
-    {
-        attachPreview();
-        LLFloaterReg::showInstance("big_preview");
-    }
-}
-
-bool LLFlickrPhotoPanel::isPreviewVisible()
-{
-    return (mBigPreviewFloater && mBigPreviewFloater->getVisible());
-}
-
-void LLFlickrPhotoPanel::attachPreview()
-{
-    if (mBigPreviewFloater)
-    {
-        LLSnapshotLivePreview* previewp = getPreviewView();
-        mBigPreviewFloater->setPreview(previewp);
-        mBigPreviewFloater->setFloaterOwner(getParentByType<LLFloater>());
-    }
-}
-
-void LLFlickrPhotoPanel::onSend()
-{
-	LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrPhotoPanel"); // just in case it is already listening
-	LLEventPumps::instance().obtain("FlickrConnectState").listen("LLFlickrPhotoPanel", boost::bind(&LLFlickrPhotoPanel::onFlickrConnectStateChange, this, _1));
-	
-	// Connect to Flickr if necessary and then post
-	if (LLFlickrConnect::instance().isConnected())
-	{
-		sendPhoto();
-	}
-	else
-	{
-		LLFlickrConnect::instance().checkConnectionToFlickr(true);
-	}
-}
-
-bool LLFlickrPhotoPanel::onFlickrConnectStateChange(const LLSD& data)
-{
-	switch (data.get("enum").asInteger())
-	{
-		case LLFlickrConnect::FLICKR_CONNECTED:
-			sendPhoto();
-			break;
-
-		case LLFlickrConnect::FLICKR_POSTED:
-			LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrPhotoPanel");
-			clearAndClose();
-			break;
-	}
-
-	return false;
-}
-
-void LLFlickrPhotoPanel::sendPhoto()
-{
-	// Get the title, description, and tags
-	std::string title = mTitleTextBox->getValue().asString();
-	std::string description = mDescriptionTextBox->getValue().asString();
-	std::string tags = mTagsTextBox->getValue().asString();
-
-	// Add the location if required
-	bool add_location = mLocationCheckbox->getValue().asBoolean();
-	if (add_location)
-	{
-		// Get the SLURL for the location
-		LLSLURL slurl;
-		LLAgentUI::buildSLURL(slurl);
-		std::string slurl_string = slurl.getSLURLString();
-
-		// Add query parameters so Google Analytics can track incoming clicks!
-		slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS;
-
-		std::string photo_link_text = "Visit this location";// at [] in Second Life";
-		std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName();
-		if (!parcel_name.empty())
-		{
-			boost::regex pattern = boost::regex("\\S\\.[a-zA-Z]{2,}");
-			boost::match_results<std::string::const_iterator> matches;
-			if(!boost::regex_search(parcel_name, matches, pattern))
-			{
-				photo_link_text += " at " + parcel_name;
-			}
-		}
-		photo_link_text += " in Second Life";
-
-		slurl_string = "<a href=\"" + slurl_string + "\">" + photo_link_text + "</a>";
-
-		// Add it to the description (pretty crude, but we don't have a better option with photos)
-		if (description.empty())
-			description = slurl_string;
-		else
-			description = description + "\n\n" + slurl_string;
-
-		// Also add special "machine tags" with location metadata
-		const LLVector3& agent_pos_region = gAgent.getPositionAgent();
-		LLViewerRegion* region = gAgent.getRegion();
-		LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
-		if (region && parcel)
-		{
-			S32 pos_x = S32(agent_pos_region.mV[VX]);
-			S32 pos_y = S32(agent_pos_region.mV[VY]);
-			S32 pos_z = S32(agent_pos_region.mV[VZ]);
-			
-			std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName();
-			std::string region_name = region->getName();
-			
-			if (!region_name.empty())
-			{
-				tags += llformat(" \"%s:region=%s\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), region_name.c_str());
-			}
-			if (!parcel_name.empty())
-			{
-				tags += llformat(" \"%s:parcel=%s\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), parcel_name.c_str());
-			}
-			tags += llformat(" \"%s:x=%d\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), pos_x);
-			tags += llformat(" \"%s:y=%d\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), pos_y);
-			tags += llformat(" \"%s:z=%d\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), pos_z);
-		}
-	}
-
-	// Get the content rating
-	int content_rating = mRatingComboBox->getValue().asInteger();
-
-	// Get the image
-	LLSnapshotLivePreview* previewp = getPreviewView();
-	
-	// Post to Flickr
-	LLFlickrConnect::instance().uploadPhoto(previewp->getFormattedImage(), title, description, tags, content_rating);
-
-	updateControls();
-}
-
-void LLFlickrPhotoPanel::clearAndClose()
-{
-	mTitleTextBox->setValue("");
-	mDescriptionTextBox->setValue("");
-
-	LLFloater* floater = getParentByType<LLFloater>();
-	if (floater)
-	{
-		floater->closeFloater();
-        if (mBigPreviewFloater)
-        {
-            mBigPreviewFloater->closeOnFloaterOwnerClosing(floater);
-        }
-	}
-}
-
-void LLFlickrPhotoPanel::updateControls()
-{
-	LLSnapshotLivePreview* previewp = getPreviewView();
-	BOOL got_snap = previewp && previewp->getSnapshotUpToDate();
-
-	// *TODO: Separate maximum size for Web images from postcards
-	LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL;
-
-	updateResolution(FALSE);
-}
-
-void LLFlickrPhotoPanel::updateResolution(BOOL do_update)
-{
-	LLComboBox* combobox  = static_cast<LLComboBox *>(mResolutionComboBox);
-	LLComboBox* filterbox = static_cast<LLComboBox *>(mFilterComboBox);
-
-	std::string sdstring = combobox->getSelectedValue();
-	LLSD sdres;
-	std::stringstream sstream(sdstring);
-	LLSDSerialize::fromNotation(sdres, sstream, sdstring.size());
-
-	S32 width = sdres[0];
-	S32 height = sdres[1];
-    
-    // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale 
-    std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : "");
-
-	LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
-	if (previewp && combobox->getCurrentIndex() >= 0)
-	{
-		S32 original_width = 0 , original_height = 0 ;
-		previewp->getSize(original_width, original_height) ;
-
-		if (width == 0 || height == 0)
-		{
-			// take resolution from current window size
-			LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL;
-			previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw());
-		}
-		else
-		{
-			// use the resolution from the selected pre-canned drop-down choice
-			LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL;
-			previewp->setSize(width, height);
-		}
-
-		checkAspectRatio(width);
-
-		previewp->getSize(width, height);
-		if ((original_width != width) || (original_height != height))
-		{
-			previewp->setSize(width, height);
-			if (do_update)
-			{
-                previewp->updateSnapshot(TRUE);
-				updateControls();
-			}
-		}
-        // Get the old filter, compare to the current one "filter_name" and set if changed
-        std::string original_filter = previewp->getFilter();
-		if (original_filter != filter_name)
-		{
-            previewp->setFilter(filter_name);
-			if (do_update)
-			{
-                previewp->updateSnapshot(FALSE, TRUE);
-				updateControls();
-			}
-		}
-	}
-}
-
-void LLFlickrPhotoPanel::checkAspectRatio(S32 index)
-{
-	LLSnapshotLivePreview *previewp = getPreviewView() ;
-
-	BOOL keep_aspect = FALSE;
-
-	if (0 == index) // current window size
-	{
-		keep_aspect = TRUE;
-	}
-	else // predefined resolution
-	{
-		keep_aspect = FALSE;
-	}
-
-	if (previewp)
-	{
-		previewp->mKeepAspectRatio = keep_aspect;
-	}
-}
-
-LLUICtrl* LLFlickrPhotoPanel::getRefreshBtn()
-{
-	return mRefreshBtn;
-}
-
-///////////////////////////
-//LLFlickrAccountPanel//////
-///////////////////////////
-
-LLFlickrAccountPanel::LLFlickrAccountPanel() : 
-mAccountCaptionLabel(NULL),
-mAccountNameLabel(NULL),
-mPanelButtons(NULL),
-mConnectButton(NULL),
-mDisconnectButton(NULL)
-{
-	mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLFlickrAccountPanel::onConnect, this));
-	mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLFlickrAccountPanel::onDisconnect, this));
-
-	setVisibleCallback(boost::bind(&LLFlickrAccountPanel::onVisibilityChange, this, _2));
-}
-
-BOOL LLFlickrAccountPanel::postBuild()
-{
-	mAccountCaptionLabel = getChild<LLTextBox>("account_caption_label");
-	mAccountNameLabel = getChild<LLTextBox>("account_name_label");
-	mPanelButtons = getChild<LLUICtrl>("panel_buttons");
-	mConnectButton = getChild<LLUICtrl>("connect_btn");
-	mDisconnectButton = getChild<LLUICtrl>("disconnect_btn");
-
-	return LLPanel::postBuild();
-}
-
-void LLFlickrAccountPanel::draw()
-{
-	LLFlickrConnect::EConnectionState connection_state = LLFlickrConnect::instance().getConnectionState();
-
-	//Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress
-	bool disconnecting = connection_state == LLFlickrConnect::FLICKR_DISCONNECTING;
-	mDisconnectButton->setEnabled(!disconnecting);
-
-	//Disable the 'connect' button when a connection is in progress
-	bool connecting = connection_state == LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS;
-	mConnectButton->setEnabled(!connecting);
-
-	LLPanel::draw();
-}
-
-void LLFlickrAccountPanel::onVisibilityChange(BOOL visible)
-{
-	if(visible)
-	{
-		LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrAccountPanel");
-		LLEventPumps::instance().obtain("FlickrConnectState").listen("LLFlickrAccountPanel", boost::bind(&LLFlickrAccountPanel::onFlickrConnectStateChange, this, _1));
-
-		LLEventPumps::instance().obtain("FlickrConnectInfo").stopListening("LLFlickrAccountPanel");
-		LLEventPumps::instance().obtain("FlickrConnectInfo").listen("LLFlickrAccountPanel", boost::bind(&LLFlickrAccountPanel::onFlickrConnectInfoChange, this));
-
-		//Connected
-		if(LLFlickrConnect::instance().isConnected())
-		{
-			showConnectedLayout();
-		}
-		//Check if connected (show disconnected layout in meantime)
-		else
-		{
-			showDisconnectedLayout();
-		}
-        if ((LLFlickrConnect::instance().getConnectionState() == LLFlickrConnect::FLICKR_NOT_CONNECTED) ||
-            (LLFlickrConnect::instance().getConnectionState() == LLFlickrConnect::FLICKR_CONNECTION_FAILED))
-        {
-            LLFlickrConnect::instance().checkConnectionToFlickr();
-        }
-	}
-	else
-	{
-		LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrAccountPanel");
-		LLEventPumps::instance().obtain("FlickrConnectInfo").stopListening("LLFlickrAccountPanel");
-	}
-}
-
-bool LLFlickrAccountPanel::onFlickrConnectStateChange(const LLSD& data)
-{
-	if(LLFlickrConnect::instance().isConnected())
-	{
-		//In process of disconnecting so leave the layout as is
-		if(data.get("enum").asInteger() != LLFlickrConnect::FLICKR_DISCONNECTING)
-		{
-			showConnectedLayout();
-		}
-	}
-	else
-	{
-		showDisconnectedLayout();
-	}
-
-	return false;
-}
-
-bool LLFlickrAccountPanel::onFlickrConnectInfoChange()
-{
-	LLSD info = LLFlickrConnect::instance().getInfo();
-	std::string clickable_name;
-
-	//Strings of format [http://www.somewebsite.com Click Me] become clickable text
-	if(info.has("link") && info.has("name"))
-	{
-		clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]";
-	}
-
-	mAccountNameLabel->setText(clickable_name);
-
-	return false;
-}
-
-void LLFlickrAccountPanel::showConnectButton()
-{
-	if(!mConnectButton->getVisible())
-	{
-		mConnectButton->setVisible(TRUE);
-		mDisconnectButton->setVisible(FALSE);
-	}
-}
-
-void LLFlickrAccountPanel::hideConnectButton()
-{
-	if(mConnectButton->getVisible())
-	{
-		mConnectButton->setVisible(FALSE);
-		mDisconnectButton->setVisible(TRUE);
-	}
-}
-
-void LLFlickrAccountPanel::showDisconnectedLayout()
-{
-	mAccountCaptionLabel->setText(getString("flickr_disconnected"));
-	mAccountNameLabel->setText(std::string(""));
-	showConnectButton();
-}
-
-void LLFlickrAccountPanel::showConnectedLayout()
-{
-	LLFlickrConnect::instance().loadFlickrInfo();
-
-	mAccountCaptionLabel->setText(getString("flickr_connected"));
-	hideConnectButton();
-}
-
-void LLFlickrAccountPanel::onConnect()
-{
-	LLFlickrConnect::instance().checkConnectionToFlickr(true);
-}
-
-void LLFlickrAccountPanel::onDisconnect()
-{
-	LLFlickrConnect::instance().disconnectFromFlickr();
-}
-
-////////////////////////
-//LLFloaterFlickr///////
-////////////////////////
-
-LLFloaterFlickr::LLFloaterFlickr(const LLSD& key) : LLFloater(key),
-    mFlickrPhotoPanel(NULL),
-    mStatusErrorText(NULL),
-    mStatusLoadingText(NULL),
-    mStatusLoadingIndicator(NULL)
-{
-	mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterFlickr::onCancel, this));
-}
-
-void LLFloaterFlickr::onClose(bool app_quitting)
-{
-    LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview"));
-    if (big_preview_floater)
-    {
-        big_preview_floater->closeOnFloaterOwnerClosing(this);
-    }
-	LLFloater::onClose(app_quitting);
-}
-
-void LLFloaterFlickr::onCancel()
-{
-    LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview"));
-    if (big_preview_floater)
-    {
-        big_preview_floater->closeOnFloaterOwnerClosing(this);
-    }
-    closeFloater();
-}
-
-BOOL LLFloaterFlickr::postBuild()
-{
-    // Keep tab of the Photo Panel
-	mFlickrPhotoPanel = static_cast<LLFlickrPhotoPanel*>(getChild<LLUICtrl>("panel_flickr_photo"));
-    // Connection status widgets
-    mStatusErrorText = getChild<LLTextBox>("connection_error_text");
-    mStatusLoadingText = getChild<LLTextBox>("connection_loading_text");
-    mStatusLoadingIndicator = getChild<LLUICtrl>("connection_loading_indicator");
-	return LLFloater::postBuild();
-}
-
-void LLFloaterFlickr::showPhotoPanel()
-{
-	LLTabContainer* parent = dynamic_cast<LLTabContainer*>(mFlickrPhotoPanel->getParent());
-	if (!parent)
-	{
-		LL_WARNS() << "Cannot find panel container" << LL_ENDL;
-		return;
-	}
-
-	parent->selectTabPanel(mFlickrPhotoPanel);
-}
-
-void LLFloaterFlickr::draw()
-{
-    if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator)
-    {
-        mStatusErrorText->setVisible(false);
-        mStatusLoadingText->setVisible(false);
-        mStatusLoadingIndicator->setVisible(false);
-        LLFlickrConnect::EConnectionState connection_state = LLFlickrConnect::instance().getConnectionState();
-        std::string status_text;
-        
-        switch (connection_state)
-        {
-        case LLFlickrConnect::FLICKR_NOT_CONNECTED:
-            // No status displayed when first opening the panel and no connection done
-        case LLFlickrConnect::FLICKR_CONNECTED:
-            // When successfully connected, no message is displayed
-        case LLFlickrConnect::FLICKR_POSTED:
-            // No success message to show since we actually close the floater after successful posting completion
-            break;
-        case LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS:
-            // Connection loading indicator
-            mStatusLoadingText->setVisible(true);
-            status_text = LLTrans::getString("SocialFlickrConnecting");
-            mStatusLoadingText->setValue(status_text);
-            mStatusLoadingIndicator->setVisible(true);
-            break;
-        case LLFlickrConnect::FLICKR_POSTING:
-            // Posting indicator
-            mStatusLoadingText->setVisible(true);
-            status_text = LLTrans::getString("SocialFlickrPosting");
-            mStatusLoadingText->setValue(status_text);
-            mStatusLoadingIndicator->setVisible(true);
-			break;
-        case LLFlickrConnect::FLICKR_CONNECTION_FAILED:
-            // Error connecting to the service
-            mStatusErrorText->setVisible(true);
-            status_text = LLTrans::getString("SocialFlickrErrorConnecting");
-            mStatusErrorText->setValue(status_text);
-            break;
-        case LLFlickrConnect::FLICKR_POST_FAILED:
-            // Error posting to the service
-            mStatusErrorText->setVisible(true);
-            status_text = LLTrans::getString("SocialFlickrErrorPosting");
-            mStatusErrorText->setValue(status_text);
-            break;
-		case LLFlickrConnect::FLICKR_DISCONNECTING:
-			// Disconnecting loading indicator
-			mStatusLoadingText->setVisible(true);
-			status_text = LLTrans::getString("SocialFlickrDisconnecting");
-			mStatusLoadingText->setValue(status_text);
-			mStatusLoadingIndicator->setVisible(true);
-			break;
-		case LLFlickrConnect::FLICKR_DISCONNECT_FAILED:
-			// Error disconnecting from the service
-			mStatusErrorText->setVisible(true);
-			status_text = LLTrans::getString("SocialFlickrErrorDisconnecting");
-			mStatusErrorText->setValue(status_text);
-			break;
-        }
-    }
-	LLFloater::draw();
-}
-
diff --git a/indra/newview/llfloaterflickr.h b/indra/newview/llfloaterflickr.h
deleted file mode 100644
index 74da3bcea9ad214f01b106d58851e4b022740550..0000000000000000000000000000000000000000
--- a/indra/newview/llfloaterflickr.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/** 
-* @file   llfloaterflickr.h
-* @brief  Header file for llfloaterflickr
-* @author cho@lindenlab.com
-*
-* $LicenseInfo:firstyear=2013&license=viewerlgpl$
-* Second Life Viewer Source Code
-* Copyright (C) 2013, Linden Research, Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation;
-* version 2.1 of the License only.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*
-* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
-* $/LicenseInfo$
-*/
-#ifndef LL_LLFLOATERFLICKR_H
-#define LL_LLFLOATERFLICKR_H
-
-#include "llfloater.h"
-#include "lltextbox.h"
-#include "llviewertexture.h"
-
-class LLIconCtrl;
-class LLCheckBoxCtrl;
-class LLSnapshotLivePreview;
-class LLFloaterBigPreview;
-
-class LLFlickrPhotoPanel : public LLPanel
-{
-public:
-	LLFlickrPhotoPanel();
-	~LLFlickrPhotoPanel();
-
-	BOOL postBuild();
-	S32 notify(const LLSD& info);
-	void draw();
-
-	LLSnapshotLivePreview* getPreviewView();
-	void onVisibilityChange(BOOL new_visibility);
-	void onClickNewSnapshot();
-    void onClickBigPreview();
-	void onSend();
-	bool onFlickrConnectStateChange(const LLSD& data);
-
-	void sendPhoto();
-	void clearAndClose();
-
-	void updateControls();
-	void updateResolution(BOOL do_update);
-	void checkAspectRatio(S32 index);
-	LLUICtrl* getRefreshBtn();
-
-private:
-    bool isPreviewVisible();
-    void attachPreview();
-
-	LLHandle<LLView> mPreviewHandle;
-
-	LLUICtrl * mResolutionComboBox;
-	LLUICtrl * mFilterComboBox;
-	LLUICtrl * mRefreshBtn;
-	LLUICtrl * mWorkingLabel;
-	LLUICtrl * mThumbnailPlaceholder;
-	LLUICtrl * mTitleTextBox;
-	LLUICtrl * mDescriptionTextBox;
-	LLUICtrl * mLocationCheckbox;
-	LLUICtrl * mTagsTextBox;
-	LLUICtrl * mRatingComboBox;
-	LLUICtrl * mPostButton;
-	LLUICtrl * mCancelButton;
-	LLButton * mBtnPreview;
-
-    LLFloaterBigPreview * mBigPreviewFloater;
-};
-
-class LLFlickrAccountPanel : public LLPanel
-{
-public:
-	LLFlickrAccountPanel();
-	BOOL postBuild();
-	void draw();
-
-private:
-	void onVisibilityChange(BOOL new_visibility);
-	bool onFlickrConnectStateChange(const LLSD& data);
-	bool onFlickrConnectInfoChange();
-	void onConnect();
-	void onUseAnotherAccount();
-	void onDisconnect();
-
-	void showConnectButton();
-	void hideConnectButton();
-	void showDisconnectedLayout();
-	void showConnectedLayout();
-
-	LLTextBox * mAccountCaptionLabel;
-	LLTextBox * mAccountNameLabel;
-	LLUICtrl * mPanelButtons;
-	LLUICtrl * mConnectButton;
-	LLUICtrl * mDisconnectButton;
-};
-
-
-class LLFloaterFlickr : public LLFloater
-{
-public:
-	LLFloaterFlickr(const LLSD& key);
-	BOOL postBuild();
-	void draw();
-	void onClose(bool app_quitting);
-	void onCancel();
-	
-	void showPhotoPanel();
-
-private:
-	LLFlickrPhotoPanel* mFlickrPhotoPanel;
-    LLTextBox* mStatusErrorText;
-    LLTextBox* mStatusLoadingText;
-    LLUICtrl*  mStatusLoadingIndicator;
-};
-
-#endif // LL_LLFLOATERFLICKR_H
-
diff --git a/indra/newview/llfloaterforgetuser.cpp b/indra/newview/llfloaterforgetuser.cpp
index 5659cb2f793fb780cdb0290dc3a3c6676b302585..363951041afe02f513fd8539b8889cac8186dd61 100644
--- a/indra/newview/llfloaterforgetuser.cpp
+++ b/indra/newview/llfloaterforgetuser.cpp
@@ -54,7 +54,7 @@ LLFloaterForgetUser::~LLFloaterForgetUser()
 
 BOOL LLFloaterForgetUser::postBuild()
 {
-    // Note, storage works per grid, watever is selected currently in login screen or logged in.
+    // Note, storage works per grid, whatever is selected currently in login screen or logged in.
     // Since login screen can change grid, store the value.
     mGrid = LLGridManager::getInstance()->getGrid();
 
@@ -87,19 +87,25 @@ BOOL LLFloaterForgetUser::postBuild()
         LLPointer<LLCredential> cred = gSecAPIHandler->loadCredential(mGrid);
         if (cred.notNull())
         {
-            LLScrollListItem::Params item_params;
-            item_params.value(cred->userID());
-            item_params.columns.add()
-                .value(LLPanelLogin::getUserName(cred))
-                .column("user")
-                .font(LLFontGL::getFontSansSerifSmall());
-            scroll_list->addRow(item_params, ADD_BOTTOM);
-            scroll_list->selectFirstItem();
+            const LLSD &ident = cred->getIdentifier();
+            if (ident.isMap() && ident.has("type"))
+            {
+                LLScrollListItem::Params item_params;
+                item_params.value(cred->userID());
+                item_params.columns.add()
+                    .value(LLPanelLogin::getUserName(cred))
+                    .column("user")
+                    .font(LLFontGL::getFontSansSerifSmall());
+                scroll_list->addRow(item_params, ADD_BOTTOM);
+                scroll_list->selectFirstItem();
+            }
         }
     }
 
     bool enable_button = scroll_list->getFirstSelectedIndex() != -1;
-    getChild<LLView>("delete_data")->setEnabled(enable_button);
+    LLCheckBoxCtrl *chk_box = getChild<LLCheckBoxCtrl>("delete_data");
+    chk_box->setEnabled(enable_button);
+    chk_box->set(FALSE);
     LLButton *button = getChild<LLButton>("forget");
     button->setEnabled(enable_button);
     button->setCommitCallback(boost::bind(&LLFloaterForgetUser::onForgetClicked, this));
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index 3c428a70f30b86bdf5abaa6f7062ada259560005..d4b0fa85ab71162c9549f4777a98cdf9fa52f2ce 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -503,7 +503,7 @@ BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask)
 			mSculptedPreview->refresh();
 		}
 
-		LLUI::setMousePositionLocal(this, mLastMouseX, mLastMouseY);
+		LLUI::getInstance()->setMousePositionLocal(this, mLastMouseX, mLastMouseY);
 	}
 
 	if (!mPreviewRect.pointInRect(x, y) || !mAvatarPreview || !mSculptedPreview)
diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp
index 30d05ae2875b3230055272d8ec851e413a352c46..21420b122b8ead0d1db60d868cef5b0b15d3b6c5 100644
--- a/indra/newview/llfloaterimcontainer.cpp
+++ b/indra/newview/llfloaterimcontainer.cpp
@@ -237,7 +237,7 @@ BOOL LLFloaterIMContainer::postBuild()
 
 	collapseMessagesPane(gSavedPerAccountSettings.getBOOL("ConversationsMessagePaneCollapsed"));
 	collapseConversationsPane(gSavedPerAccountSettings.getBOOL("ConversationsListPaneCollapsed"), false);
-	LLAvatarNameCache::addUseDisplayNamesCallback(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false));
+	LLAvatarNameCache::getInstance()->addUseDisplayNamesCallback(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false));
 	mMicroChangedSignal = LLVoiceClient::getInstance()->MicroChangedCallback(boost::bind(&LLFloaterIMContainer::updateSpeakBtnState, this));
 
 	if (! mMessagesPane->isCollapsed() && ! mConversationsPane->isCollapsed())
@@ -267,7 +267,7 @@ BOOL LLFloaterIMContainer::postBuild()
 	// We'll take care of view updates on idle
 	gIdleCallbacks.addFunction(idle, this);
 	// When display name option change, we need to reload all participant names
-	LLAvatarNameCache::addUseDisplayNamesCallback(boost::bind(&LLFloaterIMContainer::processParticipantsStyleUpdate, this));
+	LLAvatarNameCache::getInstance()->addUseDisplayNamesCallback(boost::bind(&LLFloaterIMContainer::processParticipantsStyleUpdate, this));
 
     mParticipantRefreshTimer.setTimerExpirySec(0);
     mParticipantRefreshTimer.start();
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index f9efd136088cdc67cfb4b6460229eabf3668f942..a6531ed7e1b9ae3acd7b1bb6597dd6d1bae59e79 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -228,7 +228,7 @@ void LLFloaterIMNearbyChat::loadHistory()
 		else
  		{
 			std::string legacy_name = gCacheName->buildLegacyName(from);
-			from_id = LLAvatarNameCache::findIdByName(legacy_name);
+			from_id = LLAvatarNameCache::getInstance()->findIdByName(legacy_name);
  		}
 
 		LLChat chat;
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 74925caed4d5f3e5b5e9989cb9ff88a8bda80901..e12ad262f820e7e9e985e46bb8f76e637425d63d 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -807,7 +807,7 @@ BOOL LLFloaterModelPreview::handleHover	(S32 x, S32 y, MASK mask)
 
 		mModelPreview->refresh();
 
-		LLUI::setMousePositionLocal(this, mLastMouseX, mLastMouseY);
+		LLUI::getInstance()->setMousePositionLocal(this, mLastMouseX, mLastMouseY);
 	}
 
 	if (!mPreviewRect.pointInRect(x, y) || !mModelPreview)
diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp
index bfcd1b8b472407029f11a919935cda29b250f76f..dccef88e410bb3236f6d33a323f91f97b953bf94 100644
--- a/indra/newview/llfloateroutfitsnapshot.cpp
+++ b/indra/newview/llfloateroutfitsnapshot.cpp
@@ -31,8 +31,6 @@
 
 #include "llagent.h"
 #include "llfloaterreg.h"
-#include "llfloaterflickr.h"
-#include "llfloatertwitter.h"
 #include "llimagefiltersmanager.h"
 #include "llcheckboxctrl.h"
 #include "llcombobox.h"
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index b48495b5b294e355ebdf1403bef8013f6cf1d533..bcb0dfe856fa5dca4a76faced1e3aba59be837fe 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -276,8 +276,8 @@ bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response
 	if ( option == 0 ) // YES
 	{
 		// clean web
-		LLViewerMedia::clearAllCaches();
-		LLViewerMedia::clearAllCookies();
+		LLViewerMedia::getInstance()->clearAllCaches();
+		LLViewerMedia::getInstance()->clearAllCookies();
 		
 		// clean nav bar history
 		LLNavigationBar::getInstance()->clearHistoryCache();
@@ -300,13 +300,13 @@ bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response
 
 void handleNameTagOptionChanged(const LLSD& newvalue)
 {
-	LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
+	LLAvatarNameCache::getInstance()->setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
 	LLVOAvatar::invalidateNameTags();
 }
 
 void handleDisplayNamesOptionChanged(const LLSD& newvalue)
 {
-	LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean());
+	LLAvatarNameCache::getInstance()->setUseDisplayNames(newvalue.asBoolean());
 	LLVOAvatar::invalidateNameTags();
 }
 
@@ -546,7 +546,7 @@ BOOL LLFloaterPreference::postBuild()
 	// set 'enable' property for 'Clear log...' button
 	changed();
 
-	LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
+	LLLogChat::getInstance()->setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
 
 	LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
 	fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
@@ -658,14 +658,14 @@ void LLFloaterPreference::apply()
 	std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
 	setCacheLocation(cache_location);
 	
-	LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
+	LLViewerMedia::getInstance()->setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
 	
 	if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE))
 	{
 		bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
 		std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
 		int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
-		LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port);
+		LLViewerMedia::getInstance()->setProxyConfig(proxy_enable, proxy_address, proxy_port);
 	}
 	
 	if (mGotPersonalInfo)
@@ -1257,7 +1257,7 @@ void LLFloaterPreference::buildPopupLists()
 		{
 			if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
 			{
-				LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName);
+				LLSD last_response = LLUI::getInstance()->mSettingGroups["config"]->getLLSD("Default" + templatep->mName);
 				if (!last_response.isUndefined())
 				{
 					for (LLSD::map_const_iterator it = last_response.beginMap();
@@ -1797,7 +1797,7 @@ void LLFloaterPreference::onClickEnablePopup()
 		LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
 		//gSavedSettings.setWarning(templatep->mName, TRUE);
 		std::string notification_name = templatep->mName;
-		LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
+		LLUI::getInstance()->mSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
 	}
 	
 	buildPopupLists();
diff --git a/indra/newview/llfloatersearch.cpp b/indra/newview/llfloatersearch.cpp
index d1246dae4c8d230513b8793eade97921cf930eac..779542cfcc8821d83232b693f5f02ae7663f1b72 100644
--- a/indra/newview/llfloatersearch.cpp
+++ b/indra/newview/llfloatersearch.cpp
@@ -48,7 +48,7 @@ class LLSearchHandler : public LLCommandHandler
 	LLSearchHandler() : LLCommandHandler("search", UNTRUSTED_THROTTLE) { }
 	bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableSearch"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableSearch"))
 		{
 			LLNotificationsUtil::add("NoSearch", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 2798e375c7c7cbeeb35cfcc44703f764ad8fcfc9..ef7a9fd5366eec9e9cef73482c09926c06aa9f59 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -29,8 +29,6 @@
 #include "llfloatersnapshot.h"
 
 #include "llfloaterreg.h"
-#include "llfloaterflickr.h"
-#include "llfloatertwitter.h"
 #include "llimagefiltersmanager.h"
 #include "llcheckboxctrl.h"
 #include "llcombobox.h"
@@ -1240,10 +1238,7 @@ BOOL LLFloaterSnapshot::isWaitingState()
 
 BOOL LLFloaterSnapshotBase::ImplBase::updatePreviewList(bool initialized)
 {
-	LLFloaterFlickr* floater_flickr = LLFloaterReg::findTypedInstance<LLFloaterFlickr>("flickr");
-	LLFloaterTwitter* floater_twitter = LLFloaterReg::findTypedInstance<LLFloaterTwitter>("twitter");
-
-	if (!initialized && !floater_flickr && !floater_twitter)
+	if (!initialized)
 		return FALSE;
 
 	BOOL changed = FALSE;
diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp
index b87044ef5a538967b8b02fcf65200a56daf5b756..de5d59f484552149c30d6effc0b5e8d7de21ff4b 100644
--- a/indra/newview/llfloaterspellchecksettings.cpp
+++ b/indra/newview/llfloaterspellchecksettings.cpp
@@ -56,7 +56,7 @@ void LLFloaterSpellCheckerSettings::draw()
 	bool enable_remove = !sel_items.empty();
 	for (std::vector<LLScrollListItem*>::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it)
 	{
-		enable_remove &= LLSpellChecker::canRemoveDictionary((*sel_it)->getValue().asString());
+		enable_remove &= LLSpellChecker::getInstance()->canRemoveDictionary((*sel_it)->getValue().asString());
 	}
 	getChild<LLUICtrl>("spellcheck_remove_btn")->setEnabled(enable_remove);
 }
@@ -121,7 +121,7 @@ void LLFloaterSpellCheckerSettings::onClose(bool app_quitting)
 		for (std::vector<LLScrollListItem*>::const_iterator item_it = list_items.begin(); item_it != list_items.end(); ++item_it)
 		{
 			const std::string language = (*item_it)->getValue().asString();
-			if (LLSpellChecker::hasDictionary(language, true))
+			if (LLSpellChecker::getInstance()->hasDictionary(language, true))
 			{
 				list_dict.push_back(language);
 			}
@@ -164,7 +164,7 @@ void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings)
 	}
 	dict_combo->clearRows();
 
-	const LLSD& dict_map = LLSpellChecker::getDictionaryMap();
+	const LLSD& dict_map = LLSpellChecker::getInstance()->getDictionaryMap();
 	if (dict_map.size())
 	{
 		for (LLSD::array_const_iterator dict_it = dict_map.beginArray(); dict_it != dict_map.endArray(); ++dict_it)
@@ -216,7 +216,7 @@ void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings)
 	for (LLSpellChecker::dict_list_t::const_iterator it = active_list.begin(); it != active_list.end(); ++it)
 	{
 		const std::string language = *it;
-		const LLSD dict = LLSpellChecker::getDictionaryData(language);
+		const LLSD dict = LLSpellChecker::getInstance()->getDictionaryData(language);
 		row["value"] = language;
 		row["columns"][0]["value"] = (!dict["user_installed"].asBoolean()) ? language : language + " " + LLTrans::getString("UserDictionary");
 		active_ctrl->addElement(row);
@@ -380,7 +380,7 @@ void LLFloaterSpellCheckerImport::onBtnOK()
 			custom_file_out.close();
 		}
 
-		LLSpellChecker::refreshDictionaryMap();
+		LLSpellChecker::getInstance()->refreshDictionaryMap();
 	}
 
 	closeFloater(false);
diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp
deleted file mode 100644
index 2b33bc69356d7b565c65d1653938883236799d0f..0000000000000000000000000000000000000000
--- a/indra/newview/llfloatertwitter.cpp
+++ /dev/null
@@ -1,810 +0,0 @@
-/** 
-* @file llfloatertwitter.cpp
-* @brief Implementation of llfloatertwitter
-* @author cho@lindenlab.com
-*
-* $LicenseInfo:firstyear=2013&license=viewerlgpl$
-* Second Life Viewer Source Code
-* Copyright (C) 2013, Linden Research, Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation;
-* version 2.1 of the License only.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*
-* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
-* $/LicenseInfo$
-*/
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llfloatertwitter.h"
-
-#include "llagent.h"
-#include "llagentui.h"
-#include "llcheckboxctrl.h"
-#include "llcombobox.h"
-#include "lltwitterconnect.h"
-#include "llfloaterbigpreview.h"
-#include "llfloaterreg.h"
-#include "lliconctrl.h"
-#include "llimagefiltersmanager.h"
-#include "llresmgr.h"		// LLLocale
-#include "llsdserialize.h"
-#include "llloadingindicator.h"
-#include "llslurl.h"
-#include "lltrans.h"
-#include "llsnapshotlivepreview.h"
-#include "llviewerregion.h"
-#include "llviewercontrol.h"
-#include "llviewermedia.h"
-#include "lltabcontainer.h"
-#include "lltexteditor.h"
-
-static LLPanelInjector<LLTwitterPhotoPanel> t_panel_photo("lltwitterphotopanel");
-static LLPanelInjector<LLTwitterAccountPanel> t_panel_account("lltwitteraccountpanel");
-
-const std::string DEFAULT_PHOTO_LOCATION_URL = "http://maps.secondlife.com/";
-const std::string DEFAULT_PHOTO_QUERY_PARAMETERS = "?sourceid=slshare_photo&utm_source=twitter&utm_medium=photo&utm_campaign=slshare";
-const std::string DEFAULT_STATUS_TEXT = " #SecondLife";
-
-///////////////////////////
-//LLTwitterPhotoPanel///////
-///////////////////////////
-
-LLTwitterPhotoPanel::LLTwitterPhotoPanel() :
-mResolutionComboBox(NULL),
-mRefreshBtn(NULL),
-mBtnPreview(NULL),
-mWorkingLabel(NULL),
-mThumbnailPlaceholder(NULL),
-mStatusCounterLabel(NULL),
-mStatusTextBox(NULL),
-mLocationCheckbox(NULL),
-mPhotoCheckbox(NULL),
-mBigPreviewFloater(NULL),
-mPostButton(NULL)
-{
-	mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLTwitterPhotoPanel::onSend, this));
-	mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLTwitterPhotoPanel::onClickNewSnapshot, this));
-	mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLTwitterPhotoPanel::onClickBigPreview, this));
-}
-
-LLTwitterPhotoPanel::~LLTwitterPhotoPanel()
-{
-	if(mPreviewHandle.get())
-	{
-		mPreviewHandle.get()->die();
-	}
-}
-
-BOOL LLTwitterPhotoPanel::postBuild()
-{
-	setVisibleCallback(boost::bind(&LLTwitterPhotoPanel::onVisibilityChange, this, _2));
-	
-	mResolutionComboBox = getChild<LLUICtrl>("resolution_combobox");
-	mResolutionComboBox->setValue("[i800,i600]"); // hardcoded defaults ftw!
-	mResolutionComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE));
-	mFilterComboBox = getChild<LLUICtrl>("filters_combobox");
-	mFilterComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE));
-	mRefreshBtn = getChild<LLUICtrl>("new_snapshot_btn");
-	mBtnPreview = getChild<LLButton>("big_preview_btn");
-    mWorkingLabel = getChild<LLUICtrl>("working_lbl");
-	mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder");
-	mStatusCounterLabel = getChild<LLUICtrl>("status_counter_label");
-	mStatusTextBox = getChild<LLUICtrl>("photo_status");
-	mStatusTextBox->setValue(DEFAULT_STATUS_TEXT);
-	mLocationCheckbox = getChild<LLUICtrl>("add_location_cb");
-	mLocationCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddLocationToggled, this));
-	mPhotoCheckbox = getChild<LLUICtrl>("add_photo_cb");
-	mPhotoCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddPhotoToggled, this));
-	mPostButton = getChild<LLUICtrl>("post_photo_btn");
-	mCancelButton = getChild<LLUICtrl>("cancel_photo_btn");
-	mBigPreviewFloater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview"));
-
-	// Update filter list
-    std::vector<std::string> filter_list = LLImageFiltersManager::getInstance()->getFiltersList();
-	LLComboBox* filterbox = static_cast<LLComboBox *>(mFilterComboBox);
-    for (U32 i = 0; i < filter_list.size(); i++)
-	{
-        filterbox->add(filter_list[i]);
-    }
-
-	return LLPanel::postBuild();
-}
-
-// virtual
-S32 LLTwitterPhotoPanel::notify(const LLSD& info)
-{
-	if (info.has("snapshot-updating"))
-	{
-        // Disable the Post button and whatever else while the snapshot is not updated
-        // updateControls();
-		return 1;
-	}
-    
-	if (info.has("snapshot-updated"))
-	{
-        // Enable the send/post/save buttons.
-        updateControls();
-        
-		// The refresh button is initially hidden. We show it after the first update,
-		// i.e. after snapshot is taken
-		LLUICtrl * refresh_button = getRefreshBtn();
-		if (!refresh_button->getVisible())
-		{
-			refresh_button->setVisible(true);
-		}
-		return 1;
-	}
-    
-	return 0;
-}
-
-void LLTwitterPhotoPanel::draw()
-{ 
-	LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
-
-    // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts)
-    bool no_ongoing_connection = !(LLTwitterConnect::instance().isTransactionOngoing());
-    bool photo_checked = mPhotoCheckbox->getValue().asBoolean();
-    mCancelButton->setEnabled(no_ongoing_connection);
-    mStatusTextBox->setEnabled(no_ongoing_connection);
-    mResolutionComboBox->setEnabled(no_ongoing_connection && photo_checked);
-    mFilterComboBox->setEnabled(no_ongoing_connection && photo_checked);
-    mRefreshBtn->setEnabled(no_ongoing_connection && photo_checked);
-    mBtnPreview->setEnabled(no_ongoing_connection);
-    mLocationCheckbox->setEnabled(no_ongoing_connection);
-    mPhotoCheckbox->setEnabled(no_ongoing_connection);
-
-	bool add_location = mLocationCheckbox->getValue().asBoolean();
-	bool add_photo = mPhotoCheckbox->getValue().asBoolean();
-	updateStatusTextLength(false);
-
-    // Reassign the preview floater if we have the focus and the preview exists
-    if (hasFocus() && isPreviewVisible())
-    {
-        attachPreview();
-    }
-    
-    // Toggle the button state as appropriate
-    bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType<LLFloater>()));
-	mBtnPreview->setToggleState(preview_active);
-    
-    // Display the preview if one is available
-	if (previewp && previewp->getThumbnailImage())
-	{
-		const LLRect& thumbnail_rect = mThumbnailPlaceholder->getRect();
-		const S32 thumbnail_w = previewp->getThumbnailWidth();
-		const S32 thumbnail_h = previewp->getThumbnailHeight();
-
-		// calc preview offset within the preview rect
-		const S32 local_offset_x = (thumbnail_rect.getWidth()  - thumbnail_w) / 2 ;
-		const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ;
-		S32 offset_x = thumbnail_rect.mLeft + local_offset_x;
-		S32 offset_y = thumbnail_rect.mBottom + local_offset_y;
-        
-		gGL.matrixMode(LLRender::MM_MODELVIEW);
-		// Apply floater transparency to the texture unless the floater is focused.
-		F32 alpha = (add_photo ? (getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency()) : 0.5f);
-		LLColor4 color = LLColor4::white;
-		gl_draw_scaled_image(offset_x, offset_y, 
-			thumbnail_w, thumbnail_h,
-			previewp->getThumbnailImage(), color % alpha);
-	}
-
-    // Update the visibility of the working (computing preview) label
-    mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate()));
-    
-    // Enable Post if we have a preview to send and no on going connection being processed
-    mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate()) && (add_photo || add_location || !mStatusTextBox->getValue().asString().empty()));
-    
-    // Draw the rest of the panel on top of it
-	LLPanel::draw();
-}
-
-LLSnapshotLivePreview* LLTwitterPhotoPanel::getPreviewView()
-{
-	LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get();
-	return previewp;
-}
-
-void LLTwitterPhotoPanel::onVisibilityChange(BOOL visible)
-{
-	if (visible)
-	{
-		if (mPreviewHandle.get())
-		{
-			LLSnapshotLivePreview* preview = getPreviewView();
-			if(preview)
-			{
-				LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL;
-				preview->updateSnapshot(TRUE);
-			}
-		}
-		else
-		{
-			LLRect full_screen_rect = getRootView()->getRect();
-			LLSnapshotLivePreview::Params p;
-			p.rect(full_screen_rect);
-			LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p);
-			mPreviewHandle = previewp->getHandle();
-
-            previewp->setContainer(this);
-            previewp->setSnapshotType(LLSnapshotModel::SNAPSHOT_WEB);
-            previewp->setSnapshotFormat(LLSnapshotModel::SNAPSHOT_FORMAT_JPEG);
-            previewp->setThumbnailSubsampled(TRUE);     // We want the preview to reflect the *saved* image
-            previewp->setAllowRenderUI(FALSE);          // We do not want the rendered UI in our snapshots
-            previewp->setAllowFullScreenPreview(FALSE);  // No full screen preview in SL Share mode
-			previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect());
-
-			updateControls();
-		}
-	}
-}
-
-void LLTwitterPhotoPanel::onAddLocationToggled()
-{
-	bool add_location = mLocationCheckbox->getValue().asBoolean();
-	updateStatusTextLength(!add_location);
-}
-
-void LLTwitterPhotoPanel::onAddPhotoToggled()
-{
-	bool add_photo = mPhotoCheckbox->getValue().asBoolean();
-	updateStatusTextLength(!add_photo);
-}
-
-void LLTwitterPhotoPanel::onClickNewSnapshot()
-{
-	LLSnapshotLivePreview* previewp = getPreviewView();
-	if (previewp)
-	{
-		previewp->updateSnapshot(TRUE);
-	}
-}
-
-void LLTwitterPhotoPanel::onClickBigPreview()
-{
-    // Toggle the preview
-    if (isPreviewVisible())
-    {
-        LLFloaterReg::hideInstance("big_preview");
-    }
-    else
-    {
-        attachPreview();
-        LLFloaterReg::showInstance("big_preview");
-    }
-}
-
-bool LLTwitterPhotoPanel::isPreviewVisible()
-{
-    return (mBigPreviewFloater && mBigPreviewFloater->getVisible());
-}
-
-void LLTwitterPhotoPanel::attachPreview()
-{
-    if (mBigPreviewFloater)
-    {
-        LLSnapshotLivePreview* previewp = getPreviewView();
-        mBigPreviewFloater->setPreview(previewp);
-        mBigPreviewFloater->setFloaterOwner(getParentByType<LLFloater>());
-    }
-}
-
-void LLTwitterPhotoPanel::onSend()
-{
-	LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterPhotoPanel"); // just in case it is already listening
-	LLEventPumps::instance().obtain("TwitterConnectState").listen("LLTwitterPhotoPanel", boost::bind(&LLTwitterPhotoPanel::onTwitterConnectStateChange, this, _1));
-	
-	// Connect to Twitter if necessary and then post
-	if (LLTwitterConnect::instance().isConnected())
-	{
-		sendPhoto();
-	}
-	else
-	{
-		LLTwitterConnect::instance().checkConnectionToTwitter(true);
-	}
-}
-
-bool LLTwitterPhotoPanel::onTwitterConnectStateChange(const LLSD& data)
-{
-	switch (data.get("enum").asInteger())
-	{
-		case LLTwitterConnect::TWITTER_CONNECTED:
-			sendPhoto();
-			break;
-
-		case LLTwitterConnect::TWITTER_POSTED:
-			LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterPhotoPanel");
-			clearAndClose();
-			break;
-	}
-
-	return false;
-}
-
-void LLTwitterPhotoPanel::sendPhoto()
-{
-	// Get the status text
-	std::string status = mStatusTextBox->getValue().asString();
-	
-	// Add the location if required
-	bool add_location = mLocationCheckbox->getValue().asBoolean();
-	if (add_location)
-	{
-		// Get the SLURL for the location
-		LLSLURL slurl;
-		LLAgentUI::buildSLURL(slurl);
-		std::string slurl_string = slurl.getSLURLString();
-
-		// Use a valid http:// URL if the scheme is secondlife:// 
-		LLURI slurl_uri(slurl_string);
-		if (slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME)
-		{
-			slurl_string = DEFAULT_PHOTO_LOCATION_URL;
-		}
-
-		// Add query parameters so Google Analytics can track incoming clicks!
-		slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS;
-
-		// Add it to the status (pretty crude, but we don't have a better option with photos)
-		if (status.empty())
-			status = slurl_string;
-		else
-			status = status + " " + slurl_string;
-	}
-
-	// Add the photo if required
-	bool add_photo = mPhotoCheckbox->getValue().asBoolean();
-	if (add_photo)
-	{
-		// Get the image
-		LLSnapshotLivePreview* previewp = getPreviewView();
-	
-		// Post to Twitter
-		LLTwitterConnect::instance().uploadPhoto(previewp->getFormattedImage(), status);
-	}
-	else
-	{
-		// Just post the status to Twitter
-		LLTwitterConnect::instance().updateStatus(status);
-	}
-
-	updateControls();
-}
-
-void LLTwitterPhotoPanel::clearAndClose()
-{
-	mStatusTextBox->setValue(DEFAULT_STATUS_TEXT);
-
-	LLFloater* floater = getParentByType<LLFloater>();
-	if (floater)
-	{
-		floater->closeFloater();
-        if (mBigPreviewFloater)
-        {
-            mBigPreviewFloater->closeOnFloaterOwnerClosing(floater);
-        }
-	}
-}
-
-void LLTwitterPhotoPanel::updateStatusTextLength(BOOL restore_old_status_text)
-{
-	bool add_location = mLocationCheckbox->getValue().asBoolean();
-
-	// Restrict the status text length to Twitter's character limit
-	LLTextEditor* status_text_box = dynamic_cast<LLTextEditor*>(mStatusTextBox);
-	if (status_text_box)
-	{
-		int max_status_length = 280 - (add_location ? 40 : 0);
-		status_text_box->setMaxTextLength(max_status_length);
-		if (restore_old_status_text)
-		{
-			if (mOldStatusText.length() > status_text_box->getText().length() && status_text_box->getText() == mOldStatusText.substr(0, status_text_box->getText().length()))
-			{
-				status_text_box->setText(mOldStatusText);
-			}
-			if (mOldStatusText.length() <= max_status_length)
-			{
-				mOldStatusText = "";
-			}
-		}
-		if (status_text_box->getText().length() > max_status_length)
-		{
-			if (mOldStatusText.length() < status_text_box->getText().length() || status_text_box->getText() != mOldStatusText.substr(0, status_text_box->getText().length()))
-			{
-				mOldStatusText = status_text_box->getText();
-			}
-			status_text_box->setText(mOldStatusText.substr(0, max_status_length));
-		}
-
-		// Update the status character counter
-		int characters_remaining = max_status_length - status_text_box->getText().length();
-		mStatusCounterLabel->setValue(characters_remaining);
-	}
-
-}
-
-void LLTwitterPhotoPanel::updateControls()
-{
-	LLSnapshotLivePreview* previewp = getPreviewView();
-	BOOL got_snap = previewp && previewp->getSnapshotUpToDate();
-    
-	// *TODO: Separate maximum size for Web images from postcards
-	LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL;
-    
-	updateResolution(FALSE);
-}
-
-void LLTwitterPhotoPanel::updateResolution(BOOL do_update)
-{
-	LLComboBox* combobox = static_cast<LLComboBox *>(mResolutionComboBox);
-	LLComboBox* filterbox = static_cast<LLComboBox *>(mFilterComboBox);
-
-	std::string sdstring = combobox->getSelectedValue();
-	LLSD sdres;
-	std::stringstream sstream(sdstring);
-	LLSDSerialize::fromNotation(sdres, sstream, sdstring.size());
-
-	S32 width = sdres[0];
-	S32 height = sdres[1];
-
-    // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale
-    std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : "");
-
-	LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
-	if (previewp && combobox->getCurrentIndex() >= 0)
-	{
-		S32 original_width = 0 , original_height = 0 ;
-		previewp->getSize(original_width, original_height) ;
-
-		if (width == 0 || height == 0)
-		{
-			// take resolution from current window size
-			LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL;
-			previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw());
-		}
-		else
-		{
-			// use the resolution from the selected pre-canned drop-down choice
-			LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL;
-			previewp->setSize(width, height);
-		}
-
-		checkAspectRatio(width);
-
-		previewp->getSize(width, height);
-		
-		if (original_width != width || original_height != height)
-		{
-			previewp->setSize(width, height);
-			if (do_update)
-			{
-                previewp->updateSnapshot(TRUE);
-				updateControls();
-			}
-		}
-        // Get the old filter, compare to the current one "filter_name" and set if changed
-        std::string original_filter = previewp->getFilter();
-		if (original_filter != filter_name)
-		{
-            previewp->setFilter(filter_name);
-			if (do_update)
-			{
-                previewp->updateSnapshot(FALSE, TRUE);
-				updateControls();
-			}
-		}
-	}
-}
-
-void LLTwitterPhotoPanel::checkAspectRatio(S32 index)
-{
-	LLSnapshotLivePreview *previewp = getPreviewView() ;
-
-	BOOL keep_aspect = FALSE;
-
-	if (0 == index) // current window size
-	{
-		keep_aspect = TRUE;
-	}
-	else // predefined resolution
-	{
-		keep_aspect = FALSE;
-	}
-
-	if (previewp)
-	{
-		previewp->mKeepAspectRatio = keep_aspect;
-	}
-}
-
-LLUICtrl* LLTwitterPhotoPanel::getRefreshBtn()
-{
-	return mRefreshBtn;
-}
-
-///////////////////////////
-//LLTwitterAccountPanel//////
-///////////////////////////
-
-LLTwitterAccountPanel::LLTwitterAccountPanel() : 
-mAccountCaptionLabel(NULL),
-mAccountNameLabel(NULL),
-mPanelButtons(NULL),
-mConnectButton(NULL),
-mDisconnectButton(NULL)
-{
-	mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLTwitterAccountPanel::onConnect, this));
-	mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLTwitterAccountPanel::onDisconnect, this));
-
-	setVisibleCallback(boost::bind(&LLTwitterAccountPanel::onVisibilityChange, this, _2));
-}
-
-BOOL LLTwitterAccountPanel::postBuild()
-{
-	mAccountCaptionLabel = getChild<LLTextBox>("account_caption_label");
-	mAccountNameLabel = getChild<LLTextBox>("account_name_label");
-	mPanelButtons = getChild<LLUICtrl>("panel_buttons");
-	mConnectButton = getChild<LLUICtrl>("connect_btn");
-	mDisconnectButton = getChild<LLUICtrl>("disconnect_btn");
-
-	return LLPanel::postBuild();
-}
-
-void LLTwitterAccountPanel::draw()
-{
-	LLTwitterConnect::EConnectionState connection_state = LLTwitterConnect::instance().getConnectionState();
-
-	//Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress
-	bool disconnecting = connection_state == LLTwitterConnect::TWITTER_DISCONNECTING;
-	mDisconnectButton->setEnabled(!disconnecting);
-
-	//Disable the 'connect' button when a connection is in progress
-	bool connecting = connection_state == LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS;
-	mConnectButton->setEnabled(!connecting);
-
-	LLPanel::draw();
-}
-
-void LLTwitterAccountPanel::onVisibilityChange(BOOL visible)
-{
-	if(visible)
-	{
-		LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterAccountPanel");
-		LLEventPumps::instance().obtain("TwitterConnectState").listen("LLTwitterAccountPanel", boost::bind(&LLTwitterAccountPanel::onTwitterConnectStateChange, this, _1));
-
-		LLEventPumps::instance().obtain("TwitterConnectInfo").stopListening("LLTwitterAccountPanel");
-		LLEventPumps::instance().obtain("TwitterConnectInfo").listen("LLTwitterAccountPanel", boost::bind(&LLTwitterAccountPanel::onTwitterConnectInfoChange, this));
-
-		//Connected
-		if(LLTwitterConnect::instance().isConnected())
-		{
-			showConnectedLayout();
-		}
-		//Check if connected (show disconnected layout in meantime)
-		else
-		{
-			showDisconnectedLayout();
-		}
-        if ((LLTwitterConnect::instance().getConnectionState() == LLTwitterConnect::TWITTER_NOT_CONNECTED) ||
-            (LLTwitterConnect::instance().getConnectionState() == LLTwitterConnect::TWITTER_CONNECTION_FAILED))
-        {
-            LLTwitterConnect::instance().checkConnectionToTwitter();
-        }
-	}
-	else
-	{
-		LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterAccountPanel");
-		LLEventPumps::instance().obtain("TwitterConnectInfo").stopListening("LLTwitterAccountPanel");
-	}
-}
-
-bool LLTwitterAccountPanel::onTwitterConnectStateChange(const LLSD& data)
-{
-	if(LLTwitterConnect::instance().isConnected())
-	{
-		//In process of disconnecting so leave the layout as is
-		if(data.get("enum").asInteger() != LLTwitterConnect::TWITTER_DISCONNECTING)
-		{
-			showConnectedLayout();
-		}
-	}
-	else
-	{
-		showDisconnectedLayout();
-	}
-
-	return false;
-}
-
-bool LLTwitterAccountPanel::onTwitterConnectInfoChange()
-{
-	LLSD info = LLTwitterConnect::instance().getInfo();
-	std::string clickable_name;
-
-	//Strings of format [http://www.somewebsite.com Click Me] become clickable text
-	if(info.has("link") && info.has("name"))
-	{
-		clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]";
-	}
-
-	mAccountNameLabel->setText(clickable_name);
-
-	return false;
-}
-
-void LLTwitterAccountPanel::showConnectButton()
-{
-	if(!mConnectButton->getVisible())
-	{
-		mConnectButton->setVisible(TRUE);
-		mDisconnectButton->setVisible(FALSE);
-	}
-}
-
-void LLTwitterAccountPanel::hideConnectButton()
-{
-	if(mConnectButton->getVisible())
-	{
-		mConnectButton->setVisible(FALSE);
-		mDisconnectButton->setVisible(TRUE);
-	}
-}
-
-void LLTwitterAccountPanel::showDisconnectedLayout()
-{
-	mAccountCaptionLabel->setText(getString("twitter_disconnected"));
-	mAccountNameLabel->setText(std::string(""));
-	showConnectButton();
-}
-
-void LLTwitterAccountPanel::showConnectedLayout()
-{
-	LLTwitterConnect::instance().loadTwitterInfo();
-
-	mAccountCaptionLabel->setText(getString("twitter_connected"));
-	hideConnectButton();
-}
-
-void LLTwitterAccountPanel::onConnect()
-{
-	LLTwitterConnect::instance().checkConnectionToTwitter(true);
-}
-
-void LLTwitterAccountPanel::onDisconnect()
-{
-	LLTwitterConnect::instance().disconnectFromTwitter();
-}
-
-////////////////////////
-//LLFloaterTwitter///////
-////////////////////////
-
-LLFloaterTwitter::LLFloaterTwitter(const LLSD& key) : LLFloater(key),
-    mTwitterPhotoPanel(NULL),
-    mStatusErrorText(NULL),
-    mStatusLoadingText(NULL),
-    mStatusLoadingIndicator(NULL)
-{
-	mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterTwitter::onCancel, this));
-}
-
-void LLFloaterTwitter::onClose(bool app_quitting)
-{
-    LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview"));
-    if (big_preview_floater)
-    {
-        big_preview_floater->closeOnFloaterOwnerClosing(this);
-    }
-	LLFloater::onClose(app_quitting);
-}
-
-void LLFloaterTwitter::onCancel()
-{
-    LLFloaterBigPreview* big_preview_floater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview"));
-    if (big_preview_floater)
-    {
-        big_preview_floater->closeOnFloaterOwnerClosing(this);
-    }
-    closeFloater();
-}
-
-BOOL LLFloaterTwitter::postBuild()
-{
-    // Keep tab of the Photo Panel
-	mTwitterPhotoPanel = static_cast<LLTwitterPhotoPanel*>(getChild<LLUICtrl>("panel_twitter_photo"));
-    // Connection status widgets
-    mStatusErrorText = getChild<LLTextBox>("connection_error_text");
-    mStatusLoadingText = getChild<LLTextBox>("connection_loading_text");
-    mStatusLoadingIndicator = getChild<LLUICtrl>("connection_loading_indicator");
-	return LLFloater::postBuild();
-}
-
-void LLFloaterTwitter::showPhotoPanel()
-{
-	LLTabContainer* parent = dynamic_cast<LLTabContainer*>(mTwitterPhotoPanel->getParent());
-	if (!parent)
-	{
-		LL_WARNS() << "Cannot find panel container" << LL_ENDL;
-		return;
-	}
-
-	parent->selectTabPanel(mTwitterPhotoPanel);
-}
-
-void LLFloaterTwitter::draw()
-{
-    if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator)
-    {
-        mStatusErrorText->setVisible(false);
-        mStatusLoadingText->setVisible(false);
-        mStatusLoadingIndicator->setVisible(false);
-        LLTwitterConnect::EConnectionState connection_state = LLTwitterConnect::instance().getConnectionState();
-        std::string status_text;
-        
-        switch (connection_state)
-        {
-        case LLTwitterConnect::TWITTER_NOT_CONNECTED:
-            // No status displayed when first opening the panel and no connection done
-        case LLTwitterConnect::TWITTER_CONNECTED:
-            // When successfully connected, no message is displayed
-        case LLTwitterConnect::TWITTER_POSTED:
-            // No success message to show since we actually close the floater after successful posting completion
-            break;
-        case LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS:
-            // Connection loading indicator
-            mStatusLoadingText->setVisible(true);
-            status_text = LLTrans::getString("SocialTwitterConnecting");
-            mStatusLoadingText->setValue(status_text);
-            mStatusLoadingIndicator->setVisible(true);
-            break;
-        case LLTwitterConnect::TWITTER_POSTING:
-            // Posting indicator
-            mStatusLoadingText->setVisible(true);
-            status_text = LLTrans::getString("SocialTwitterPosting");
-            mStatusLoadingText->setValue(status_text);
-            mStatusLoadingIndicator->setVisible(true);
-			break;
-        case LLTwitterConnect::TWITTER_CONNECTION_FAILED:
-            // Error connecting to the service
-            mStatusErrorText->setVisible(true);
-            status_text = LLTrans::getString("SocialTwitterErrorConnecting");
-            mStatusErrorText->setValue(status_text);
-            break;
-        case LLTwitterConnect::TWITTER_POST_FAILED:
-            // Error posting to the service
-            mStatusErrorText->setVisible(true);
-            status_text = LLTrans::getString("SocialTwitterErrorPosting");
-            mStatusErrorText->setValue(status_text);
-            break;
-		case LLTwitterConnect::TWITTER_DISCONNECTING:
-			// Disconnecting loading indicator
-			mStatusLoadingText->setVisible(true);
-			status_text = LLTrans::getString("SocialTwitterDisconnecting");
-			mStatusLoadingText->setValue(status_text);
-			mStatusLoadingIndicator->setVisible(true);
-			break;
-		case LLTwitterConnect::TWITTER_DISCONNECT_FAILED:
-			// Error disconnecting from the service
-			mStatusErrorText->setVisible(true);
-			status_text = LLTrans::getString("SocialTwitterErrorDisconnecting");
-			mStatusErrorText->setValue(status_text);
-			break;
-        }
-    }
-	LLFloater::draw();
-}
-
diff --git a/indra/newview/llfloatertwitter.h b/indra/newview/llfloatertwitter.h
deleted file mode 100644
index d586799d18a2294ffdd763081a35564ae9a3b548..0000000000000000000000000000000000000000
--- a/indra/newview/llfloatertwitter.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/** 
-* @file   llfloatertwitter.h
-* @brief  Header file for llfloatertwitter
-* @author cho@lindenlab.com
-*
-* $LicenseInfo:firstyear=2013&license=viewerlgpl$
-* Second Life Viewer Source Code
-* Copyright (C) 2013, Linden Research, Inc.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation;
-* version 2.1 of the License only.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*
-* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
-* $/LicenseInfo$
-*/
-#ifndef LL_LLFLOATERTWITTER_H
-#define LL_LLFLOATERTWITTER_H
-
-#include "llfloater.h"
-#include "lltextbox.h"
-#include "llviewertexture.h"
-
-class LLIconCtrl;
-class LLCheckBoxCtrl;
-class LLSnapshotLivePreview;
-class LLFloaterBigPreview;
-
-class LLTwitterPhotoPanel : public LLPanel
-{
-public:
-	LLTwitterPhotoPanel();
-	~LLTwitterPhotoPanel();
-
-	BOOL postBuild();
-	void draw();
-
-	LLSnapshotLivePreview* getPreviewView();
-	void onVisibilityChange(BOOL new_visibility);
-	void onAddLocationToggled();
-	void onAddPhotoToggled();
-    void onClickBigPreview();
-	void onClickNewSnapshot();
-	void onSend();
-	S32 notify(const LLSD& info);
-	bool onTwitterConnectStateChange(const LLSD& data);
-
-	void sendPhoto();
-	void clearAndClose();
-
-	void updateStatusTextLength(BOOL restore_old_status_text);
-	void updateControls();
-	void updateResolution(BOOL do_update);
-	void checkAspectRatio(S32 index);
-	LLUICtrl* getRefreshBtn();
-
-private:
-    bool isPreviewVisible();
-    void attachPreview();
-
-	LLHandle<LLView> mPreviewHandle;
-
-	LLUICtrl * mResolutionComboBox;
-	LLUICtrl * mFilterComboBox;
-	LLUICtrl * mRefreshBtn;
-	LLUICtrl * mWorkingLabel;
-	LLUICtrl * mThumbnailPlaceholder;
-	LLUICtrl * mStatusCounterLabel;
-	LLUICtrl * mStatusTextBox;
-	LLUICtrl * mLocationCheckbox;
-	LLUICtrl * mPhotoCheckbox;
-	LLUICtrl * mPostButton;
-	LLUICtrl * mCancelButton;
-	LLButton * mBtnPreview;
-
-    LLFloaterBigPreview * mBigPreviewFloater;
-    
-	std::string mOldStatusText;
-};
-
-class LLTwitterAccountPanel : public LLPanel
-{
-public:
-	LLTwitterAccountPanel();
-	BOOL postBuild();
-	void draw();
-
-private:
-	void onVisibilityChange(BOOL new_visibility);
-	bool onTwitterConnectStateChange(const LLSD& data);
-	bool onTwitterConnectInfoChange();
-	void onConnect();
-	void onUseAnotherAccount();
-	void onDisconnect();
-
-	void showConnectButton();
-	void hideConnectButton();
-	void showDisconnectedLayout();
-	void showConnectedLayout();
-
-	LLTextBox * mAccountCaptionLabel;
-	LLTextBox * mAccountNameLabel;
-	LLUICtrl * mPanelButtons;
-	LLUICtrl * mConnectButton;
-	LLUICtrl * mDisconnectButton;
-};
-
-
-class LLFloaterTwitter : public LLFloater
-{
-public:
-	LLFloaterTwitter(const LLSD& key);
-	BOOL postBuild();
-	void draw();
-	void onClose(bool app_quitting);
-	void onCancel();
-
-	void showPhotoPanel();
-
-private:
-	LLTwitterPhotoPanel* mTwitterPhotoPanel;
-    LLTextBox* mStatusErrorText;
-    LLTextBox* mStatusLoadingText;
-    LLUICtrl*  mStatusLoadingIndicator;
-};
-
-#endif // LL_LLFLOATERTWITTER_H
-
diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp
index db5a1922870c2768ecdc4cf214c36344451322ca..e67c79a3a0f54f33a27d767c8d78cff4ec5e5a5c 100644
--- a/indra/newview/llfloateruipreview.cpp
+++ b/indra/newview/llfloateruipreview.cpp
@@ -291,8 +291,8 @@ bool LLPreviewedFloater::sShowRectangles = false;
 // Changes are made here
 LLLocalizationResetForcer::LLLocalizationResetForcer(LLFloaterUIPreview* floater, S32 ID)
 {
-	mSavedLocalization = LLUI::sSettingGroups["config"]->getString("Language");				// save current localization setting
-	LLUI::sSettingGroups["config"]->setString("Language", floater->getLocStr(ID));// hack language to be the one we want to preview floaters in
+	mSavedLocalization = LLUI::getInstance()->mSettingGroups["config"]->getString("Language");				// save current localization setting
+	LLUI::getInstance()->mSettingGroups["config"]->setString("Language", floater->getLocStr(ID));// hack language to be the one we want to preview floaters in
 	// forcibly reset XUI paths with this new language
 	gDirUtilp->setSkinFolder(gDirUtilp->getSkinFolder(), floater->getLocStr(ID));
 }
@@ -301,7 +301,7 @@ LLLocalizationResetForcer::LLLocalizationResetForcer(LLFloaterUIPreview* floater
 // Changes are reversed here
 LLLocalizationResetForcer::~LLLocalizationResetForcer()
 {
-	LLUI::sSettingGroups["config"]->setString("Language", mSavedLocalization);	// reset language to what it was before we changed it
+	LLUI::getInstance()->mSettingGroups["config"]->setString("Language", mSavedLocalization);	// reset language to what it was before we changed it
 	// forcibly reset XUI paths with this new language
 	gDirUtilp->setSkinFolder(gDirUtilp->getSkinFolder(), mSavedLocalization);
 }
diff --git a/indra/newview/llfloatervoicevolume.cpp b/indra/newview/llfloatervoicevolume.cpp
index 38446e46df8979e73f8ce826ce476f4fe37dfdb7..59e1f49f81d7895c4ab39813a350a5ffa1b81308 100644
--- a/indra/newview/llfloatervoicevolume.cpp
+++ b/indra/newview/llfloatervoicevolume.cpp
@@ -127,7 +127,7 @@ void LLFloaterVoiceVolume::onOpen(const LLSD& data)
 	// Extract appropriate avatar id
 	mAvatarID = data["avatar_id"];
 
-	LLUI::positionViewNearMouse(this);
+	LLUI::getInstance()->positionViewNearMouse(this);
 
 	getChild<LLUICtrl>("avatar_name")->setValue("");
 	updateVolumeControls();
diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp
index 13953d6be5b77942ebb16d0527ba8abf11af1cf2..23fd6d9c8eb9d6fbfaddb87878270511828f1221 100644
--- a/indra/newview/llfloaterwebcontent.cpp
+++ b/indra/newview/llfloaterwebcontent.cpp
@@ -30,8 +30,6 @@
 #include "lliconctrl.h"
 #include "llfloaterreg.h"
 #include "llhttpconstants.h"
-#include "llflickrconnect.h"
-#include "lltwitterconnect.h"
 #include "lllayoutstack.h"
 #include "llpluginclassmedia.h"
 #include "llprogressbar.h"
@@ -234,7 +232,7 @@ void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p)
 
 void LLFloaterWebContent::open_media(const Params& p)
 {
-	LLViewerMedia::proxyWindowOpened(p.target(), p.id());
+	LLViewerMedia::getInstance()->proxyWindowOpened(p.target(), p.id());
 	mWebBrowser->setHomePageUrl(p.url);
 	mWebBrowser->setTarget(p.target);
 	mWebBrowser->navigateTo(p.url);
@@ -288,27 +286,7 @@ void LLFloaterWebContent::onOpen(const LLSD& key)
 //virtual
 void LLFloaterWebContent::onClose(bool app_quitting)
 {
-    // If we close the web browsing window showing the Flickr login, we need to signal to this object that the connection will not happen
-	// MAINT-3440 note change here to use findInstance and not getInstance - latter creates an instance if it's not there which is bad.
-	LLFloater* flickr_web = LLFloaterReg::findInstance("flickr_web");
-    if (flickr_web == this)
-    {
-        if (!LLFlickrConnect::instance().isConnected())
-        {
-            LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED);
-        }
-    }
-	// Same with Twitter
-	// MAINT-3440 note change here to use findInstance and not getInstance - latter creates an instance if it's not there which is bad.
-	LLFloater* twitter_web = LLFloaterReg::findInstance("twitter_web");
-    if (twitter_web == this)
-    {
-        if (!LLTwitterConnect::instance().isConnected())
-        {
-            LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED);
-        }
-    }
-	LLViewerMedia::proxyWindowClosed(mUUID);
+	LLViewerMedia::getInstance()->proxyWindowClosed(mUUID);
 	destroy();
 }
 
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 1e9c9ce5e0407c1f33521064e664d2d4a05c3782..27197f0b065075055cef8c772c0a6f82247027a1 100644
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -122,7 +122,7 @@ class LLWorldMapHandler : public LLCommandHandler
 	bool handle(const LLSD& params, const LLSD& query_map,
 				LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableWorldMap"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableWorldMap"))
 		{
 			LLNotificationsUtil::add("NoWorldMap", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
@@ -160,7 +160,7 @@ class LLMapTrackAvatarHandler : public LLCommandHandler
 	
 	bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableWorldMap"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableWorldMap"))
 		{
 			LLNotificationsUtil::add("NoWorldMap", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
diff --git a/indra/newview/llfollowcam.cpp b/indra/newview/llfollowcam.cpp
index 612afc0d18fdeb8142499f3155072aa3af394bfc..c2ea3b07c1a87ad706a17f2f7b83f1eec6e57353 100644
--- a/indra/newview/llfollowcam.cpp
+++ b/indra/newview/llfollowcam.cpp
@@ -29,12 +29,6 @@
 #include "llfollowcam.h"
 #include "llagent.h"
 
-//-------------------------------------------------------
-// class statics
-//-------------------------------------------------------
-std::map<LLUUID, LLFollowCamParams*> LLFollowCamMgr::sParamMap;
-std::vector<LLFollowCamParams*> LLFollowCamMgr::sParamStack;
-
 //-------------------------------------------------------
 // constants
 //-------------------------------------------------------
@@ -668,18 +662,20 @@ LLFollowCam::~LLFollowCam()
 //-------------------------------------------------------
 // LLFollowCamMgr
 //-------------------------------------------------------
-//static
-void LLFollowCamMgr::cleanupClass()
+LLFollowCamMgr::LLFollowCamMgr()
 {
-	for (param_map_t::iterator iter = sParamMap.begin(); iter != sParamMap.end(); ++iter)
-	{
-		LLFollowCamParams* params = iter->second;
-		delete params;
-	}
-	sParamMap.clear();
 }
 
-//static
+LLFollowCamMgr::~LLFollowCamMgr()
+{
+    for (param_map_t::iterator iter = mParamMap.begin(); iter != mParamMap.end(); ++iter)
+    {
+        LLFollowCamParams* params = iter->second;
+        delete params;
+    }
+    mParamMap.clear();
+}
+
 void LLFollowCamMgr::setPositionLag( const LLUUID& source, F32 lag)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -689,7 +685,6 @@ void LLFollowCamMgr::setPositionLag( const LLUUID& source, F32 lag)
 	}
 }
 
-//static
 void LLFollowCamMgr::setFocusLag( const LLUUID& source, F32 lag)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -699,7 +694,6 @@ void LLFollowCamMgr::setFocusLag( const LLUUID& source, F32 lag)
 	}
 }
 
-//static
 void LLFollowCamMgr::setFocusThreshold( const LLUUID& source, F32 threshold)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -710,7 +704,6 @@ void LLFollowCamMgr::setFocusThreshold( const LLUUID& source, F32 threshold)
 
 }
 
-//static
 void LLFollowCamMgr::setPositionThreshold( const LLUUID& source, F32 threshold)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -720,7 +713,6 @@ void LLFollowCamMgr::setPositionThreshold( const LLUUID& source, F32 threshold)
 	}
 }
 
-//static
 void LLFollowCamMgr::setDistance( const LLUUID& source, F32 distance)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -730,7 +722,6 @@ void LLFollowCamMgr::setDistance( const LLUUID& source, F32 distance)
 	}
 }
 
-//static
 void LLFollowCamMgr::setPitch( const LLUUID& source, F32 pitch)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -740,7 +731,6 @@ void LLFollowCamMgr::setPitch( const LLUUID& source, F32 pitch)
 	}
 }
 
-//static
 void LLFollowCamMgr::setFocusOffset( const LLUUID& source, const LLVector3& offset)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -750,7 +740,6 @@ void LLFollowCamMgr::setFocusOffset( const LLUUID& source, const LLVector3& offs
 	}
 }
 
-//static
 void LLFollowCamMgr::setBehindnessAngle( const LLUUID& source, F32 angle)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -760,7 +749,6 @@ void LLFollowCamMgr::setBehindnessAngle( const LLUUID& source, F32 angle)
 	}
 }
 
-//static
 void LLFollowCamMgr::setBehindnessLag( const LLUUID& source, F32 force)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -770,7 +758,6 @@ void LLFollowCamMgr::setBehindnessLag( const LLUUID& source, F32 force)
 	}
 }
 
-//static
 void LLFollowCamMgr::setPosition( const LLUUID& source, const LLVector3 position)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -780,7 +767,6 @@ void LLFollowCamMgr::setPosition( const LLUUID& source, const LLVector3 position
 	}
 }
 
-//static
 void LLFollowCamMgr::setFocus( const LLUUID& source, const LLVector3 focus)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -790,7 +776,6 @@ void LLFollowCamMgr::setFocus( const LLUUID& source, const LLVector3 focus)
 	}
 }
 
-//static
 void LLFollowCamMgr::setPositionLocked( const LLUUID& source, bool locked)
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -800,7 +785,6 @@ void LLFollowCamMgr::setPositionLocked( const LLUUID& source, bool locked)
 	}
 }
 
-//static
 void LLFollowCamMgr::setFocusLocked( const LLUUID& source, bool locked )
 {
 	LLFollowCamParams* paramsp = getParamsForID(source);
@@ -810,16 +794,15 @@ void LLFollowCamMgr::setFocusLocked( const LLUUID& source, bool locked )
 	}
 }
 
-//static 
 LLFollowCamParams* LLFollowCamMgr::getParamsForID(const LLUUID& source)
 {
 	LLFollowCamParams* params = NULL;
 
-	param_map_t::iterator found_it = sParamMap.find(source);
-	if (found_it == sParamMap.end()) // didn't find it?
+	param_map_t::iterator found_it = mParamMap.find(source);
+	if (found_it == mParamMap.end()) // didn't find it?
 	{
 		params = new LLFollowCamParams();
-		sParamMap[source] = params;
+		mParamMap[source] = params;
 	}
 	else
 	{
@@ -829,56 +812,51 @@ LLFollowCamParams* LLFollowCamMgr::getParamsForID(const LLUUID& source)
 	return params;
 }
 
-//static
 LLFollowCamParams* LLFollowCamMgr::getActiveFollowCamParams()
 {
-	if (sParamStack.empty())
+	if (mParamStack.empty())
 	{
 		return NULL;
 	}
 
-	return sParamStack.back();
+	return mParamStack.back();
 }
 
-//static 
 void LLFollowCamMgr::setCameraActive( const LLUUID& source, bool active )
 {
 	LLFollowCamParams* params = getParamsForID(source);
-	param_stack_t::iterator found_it = std::find(sParamStack.begin(), sParamStack.end(), params);
-	if (found_it != sParamStack.end())
+	param_stack_t::iterator found_it = std::find(mParamStack.begin(), mParamStack.end(), params);
+	if (found_it != mParamStack.end())
 	{
-		sParamStack.erase(found_it);
+		mParamStack.erase(found_it);
 	}
 	// put on top of stack
 	if(active)
 	{
-		sParamStack.push_back(params);
+		mParamStack.push_back(params);
 	}
 }
 
-//static
 void LLFollowCamMgr::removeFollowCamParams(const LLUUID& source)
 {
 	setCameraActive(source, FALSE);
 	LLFollowCamParams* params = getParamsForID(source);
-	sParamMap.erase(source);
+	mParamMap.erase(source);
 	delete params;
 }
 
-//static
 bool LLFollowCamMgr::isScriptedCameraSource(const LLUUID& source)
 {
-	param_map_t::iterator found_it = sParamMap.find(source);
-	return (found_it != sParamMap.end());
+	param_map_t::iterator found_it = mParamMap.find(source);
+	return (found_it != mParamMap.end());
 }
 
-//static 
 void LLFollowCamMgr::dump()
 {
 	S32 param_count = 0;
 	LL_INFOS() << "Scripted camera active stack" << LL_ENDL;
-	for (param_stack_t::iterator param_it = sParamStack.begin();
-		param_it != sParamStack.end();
+	for (param_stack_t::iterator param_it = mParamStack.begin();
+		param_it != mParamStack.end();
 		++param_it)
 	{
 		LL_INFOS() << param_count++ << 
diff --git a/indra/newview/llfollowcam.h b/indra/newview/llfollowcam.h
index f4b7b2723a0091ffdd7560722a783060d5268381..799584816051b8741aacf9d9c689e43eff14781d 100644
--- a/indra/newview/llfollowcam.h
+++ b/indra/newview/llfollowcam.h
@@ -193,40 +193,40 @@ class LLFollowCam : public LLFollowCamParams
 };// end of FollowCam class
 
 
-class LLFollowCamMgr
+class LLFollowCamMgr : public LLSingleton<LLFollowCamMgr>
 {
-public:
-	static void cleanupClass			( );
-	
-	static void setPositionLag			( const LLUUID& source, F32 lag);
-	static void setFocusLag				( const LLUUID& source, F32 lag);
-	static void setFocusThreshold		( const LLUUID& source, F32 threshold);
-	static void setPositionThreshold	( const LLUUID& source, F32 threshold);
-	static void setDistance				( const LLUUID& source, F32 distance);
-	static void setPitch				( const LLUUID& source, F32 pitch);
-	static void setFocusOffset			( const LLUUID& source, const LLVector3& offset);
-	static void setBehindnessAngle		( const LLUUID& source, F32 angle);
-	static void setBehindnessLag		( const LLUUID& source, F32 lag);
-	static void setPosition				( const LLUUID& source, const LLVector3 position);
-	static void setFocus				( const LLUUID& source, const LLVector3 focus);
-	static void setPositionLocked		( const LLUUID& source, bool locked);
-	static void setFocusLocked			( const LLUUID& source, bool locked );
-
-	static void setCameraActive			( const LLUUID& source, bool active );
-
-	static LLFollowCamParams* getActiveFollowCamParams();
-	static LLFollowCamParams* getParamsForID(const LLUUID& source);
-	static void removeFollowCamParams(const LLUUID& source);
-	static bool isScriptedCameraSource(const LLUUID& source);
-	static void dump();
+    LLSINGLETON(LLFollowCamMgr);
+    ~LLFollowCamMgr();
+public:	
+	void setPositionLag			( const LLUUID& source, F32 lag);
+	void setFocusLag				( const LLUUID& source, F32 lag);
+	void setFocusThreshold		( const LLUUID& source, F32 threshold);
+	void setPositionThreshold	( const LLUUID& source, F32 threshold);
+	void setDistance				( const LLUUID& source, F32 distance);
+	void setPitch				( const LLUUID& source, F32 pitch);
+	void setFocusOffset			( const LLUUID& source, const LLVector3& offset);
+	void setBehindnessAngle		( const LLUUID& source, F32 angle);
+	void setBehindnessLag		( const LLUUID& source, F32 lag);
+	void setPosition				( const LLUUID& source, const LLVector3 position);
+	void setFocus				( const LLUUID& source, const LLVector3 focus);
+	void setPositionLocked		( const LLUUID& source, bool locked);
+	void setFocusLocked			( const LLUUID& source, bool locked );
+
+	void setCameraActive			( const LLUUID& source, bool active );
+
+	LLFollowCamParams* getActiveFollowCamParams();
+	LLFollowCamParams* getParamsForID(const LLUUID& source);
+	void removeFollowCamParams(const LLUUID& source);
+	bool isScriptedCameraSource(const LLUUID& source);
+	void dump();
 
 protected:
 
 	typedef std::map<LLUUID, LLFollowCamParams*> param_map_t;
-	static param_map_t sParamMap;
+	param_map_t mParamMap;
 
 	typedef std::vector<LLFollowCamParams*> param_stack_t;
-	static param_stack_t sParamStack;
+	param_stack_t mParamStack;
 };
 
 #endif //LL_FOLLOWCAM_H
diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp
index 913efd643426aa50e727377a6d9987095cd206ae..599790d2bb8e0d3591d488ddb0c6f8b71f21ec59 100644
--- a/indra/newview/llgroupactions.cpp
+++ b/indra/newview/llgroupactions.cpp
@@ -55,7 +55,7 @@ class LLGroupHandler : public LLCommandHandler
 	bool handle(const LLSD& tokens, const LLSD& query_map,
 				LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableGroupInfo"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableGroupInfo"))
 		{
 			LLNotificationsUtil::add("NoGroupInfo", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
diff --git a/indra/newview/llhints.cpp b/indra/newview/llhints.cpp
index 197408b40e8e9fe167e3aa86d6dcf6ea134ae51f..7271376a3c18f8fac6238ea0aeb32975a1078dc2 100644
--- a/indra/newview/llhints.cpp
+++ b/indra/newview/llhints.cpp
@@ -240,7 +240,7 @@ void LLHintPopup::draw()
 		}
 		else 
 		{
-			LLView* targetp = LLHints::getHintTarget(mTarget).get();
+			LLView* targetp = LLHints::getInstance()->getHintTarget(mTarget).get();
 			if (!targetp)
 			{
 				// target widget is no longer valid, go away
@@ -349,10 +349,20 @@ void LLHintPopup::draw()
 }
 
 
-LLRegistry<std::string, LLHandle<LLView> > LLHints::sTargetRegistry;
-std::map<LLNotificationPtr, class LLHintPopup*> LLHints::sHints;
+/// LLHints
+
+LLHints::LLHints()
+{
+    LLControlVariablePtr control = gSavedSettings.getControl("EnableUIHints");
+    mControlConnection = control->getSignal()->connect(boost::bind(&LLHints::showHints, this, _2));
+    gViewerWindow->getHintHolder()->setVisible(control->getValue().asBoolean());
+}
+
+LLHints::~LLHints()
+{
+    mControlConnection.disconnect();
+}
 
-//static
 void LLHints::show(LLNotificationPtr hint)
 {
 	LLHintPopup::Params p(LLUICtrlFactory::getDefaultParams<LLHintPopup>());
@@ -365,7 +375,7 @@ void LLHints::show(LLNotificationPtr hint)
 	{
 		LLHintPopup* popup = new LLHintPopup(p);
 
-		sHints[hint] = popup;
+		mHints[hint] = popup;
 
 		LLView* hint_holder = gViewerWindow->getHintHolder();
 		if (hint_holder)
@@ -376,27 +386,24 @@ void LLHints::show(LLNotificationPtr hint)
 	}
 }
 
-//static
 void LLHints::hide(LLNotificationPtr hint)
 {
-	hint_map_t::iterator found_it = sHints.find(hint);
-	if (found_it != sHints.end())
+	hint_map_t::iterator found_it = mHints.find(hint);
+	if (found_it != mHints.end())
 	{
 		found_it->second->hide();
-		sHints.erase(found_it);
+		mHints.erase(found_it);
 	}
 }
 
-//static
 void LLHints::registerHintTarget(const std::string& name, LLHandle<LLView> target)
 {
-	sTargetRegistry.defaultRegistrar().replace(name, target);
+	mTargetRegistry.defaultRegistrar().replace(name, target);
 }
 
-//static 
 LLHandle<LLView> LLHints::getHintTarget(const std::string& name)
 {
-	LLHandle<LLView>* handlep = sTargetRegistry.getValue(name);
+	LLHandle<LLView>* handlep = mTargetRegistry.getValue(name);
 	if (handlep) 
 	{
 		return *handlep;
@@ -407,18 +414,6 @@ LLHandle<LLView> LLHints::getHintTarget(const std::string& name)
 	}
 }
 
-//static
-void LLHints::initClass()
-{
-	sRegister.reference();
-
-	LLControlVariablePtr control = gSavedSettings.getControl("EnableUIHints");
-	control->getSignal()->connect(boost::bind(&showHints, _2));
-	gViewerWindow->getHintHolder()->setVisible(control->getValue().asBoolean());
-
-}
-
-//staic
 void LLHints::showHints(const LLSD& show)
 {
 	bool visible = show.asBoolean();
diff --git a/indra/newview/llhints.h b/indra/newview/llhints.h
index dd6195a9ce37e782287df50b334dd7e61a5f8be4..1f730734d0124e8d7d5c335b858fa4895b14d2ce 100644
--- a/indra/newview/llhints.h
+++ b/indra/newview/llhints.h
@@ -32,19 +32,22 @@
 #include "llinitdestroyclass.h"
 
 
-class LLHints :  public LLInitClass<LLHints>
+class LLHints :  public LLSingleton<LLHints>
 {
+	LLSINGLETON(LLHints);
+	~LLHints();
 public:
-	static void show(LLNotificationPtr hint);
-	static void hide(LLNotificationPtr hint);
-	static void registerHintTarget(const std::string& name, LLHandle<LLView> target);
-	static LLHandle<LLView> getHintTarget(const std::string& name);
-	static void initClass();
+	void show(LLNotificationPtr hint);
+	void hide(LLNotificationPtr hint);
+	void registerHintTarget(const std::string& name, LLHandle<LLView> target);
+	LLHandle<LLView> getHintTarget(const std::string& name);
 private:
-	static LLRegistry<std::string, LLHandle<LLView> > sTargetRegistry;
+	LLRegistry<std::string, LLHandle<LLView> > mTargetRegistry;
 	typedef std::map<LLNotificationPtr, class LLHintPopup*> hint_map_t;
-	static hint_map_t sHints;
-	static void showHints(const LLSD& show);
+	hint_map_t mHints;
+	void showHints(const LLSD& show);
+
+	boost::signals2::connection mControlConnection;
 };
 
 
diff --git a/indra/newview/llimagefiltersmanager.cpp b/indra/newview/llimagefiltersmanager.cpp
index ee6b39efaca6b650f5df139399a3f2b63ad1ede2..3b8adc1610da299c86b21718f394410156ddd8a1 100644
--- a/indra/newview/llimagefiltersmanager.cpp
+++ b/indra/newview/llimagefiltersmanager.cpp
@@ -1,6 +1,6 @@
 /** 
  * @file llimagefiltersmanager.cpp
- * @brief Load image filters list and retrieve their path. Mostly used for Flickr UI at the moment.
+ * @brief Load image filters list and retrieve their path.
  *
  * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  * Second Life Viewer Source Code
@@ -48,7 +48,7 @@ LLImageFiltersManager::~LLImageFiltersManager()
 {
 }
 
-// virtual static
+// virtual
 void LLImageFiltersManager::initSingleton()
 {
 	loadAllFilters();
diff --git a/indra/newview/llimagefiltersmanager.h b/indra/newview/llimagefiltersmanager.h
index f1ed3cf1c395cdbac8a695ba45942fcdcf34e886..d06212d85aea06a7ad0d911723c2b8d7965c19de 100644
--- a/indra/newview/llimagefiltersmanager.h
+++ b/indra/newview/llimagefiltersmanager.h
@@ -1,6 +1,6 @@
 /** 
  * @file llimagefiltersmanager.h
- * @brief Load image filters list and retrieve their path. Mostly used for Flickr UI at the moment.
+ * @brief Load image filters list and retrieve their path.
  *
  * $LicenseInfo:firstyear=2000&license=viewerlgpl$
  * Second Life Viewer Source Code
diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index fa6f959ed0fae8a36c052b10e8ace45d894d3616..9633683771196ea223f2a0cd3ef00169e34b4350 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -698,7 +698,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
                 // The group notice packet does not have an AgentID.  Obtain one from the name cache.
                 // If last name is "Resident" strip it out so the cache name lookup works.
                 std::string legacy_name = gCacheName->buildLegacyName(original_name);
-                agent_id = LLAvatarNameCache::findIdByName(legacy_name);
+                agent_id = LLAvatarNameCache::getInstance()->findIdByName(legacy_name);
 
                 if (agent_id.isNull())
                 {
@@ -857,18 +857,39 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
             }
             else // IM_TASK_INVENTORY_OFFERED
             {
-                info->mType = (LLAssetType::EType) binary_bucket[0];
-                info->mObjectID = LLUUID::null;
-                info->mFromObject = TRUE;
-            }
+                if (offline == IM_OFFLINE && session_id.isNull() && aux_id.notNull() && binary_bucket_size > sizeof(S8)* 5)
+                {
+                    // cap received offline message
+                    std::string str_bucket = ll_safe_string((char*)binary_bucket, binary_bucket_size);
+                    typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+                    boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
+                    tokenizer tokens(str_bucket, sep);
+                    tokenizer::iterator iter = tokens.begin();
+
+                    info->mType = (LLAssetType::EType)(atoi((*(iter++)).c_str()));
+                    // Note There is more elements in 'tokens' ...
 
-            // In the case of an offline message, the transaction id will be in aux_id and th session_id will be null
-            // (conversely when online the transaction id is passed as session_id)
-            info->mTransactionID = session_id.isNull() ? aux_id : session_id;
+                    info->mObjectID = LLUUID::null;
+                    info->mFromObject = TRUE;
+                }
+                else
+                {
+                    if (sizeof(S8) != binary_bucket_size)
+                    {
+                        LL_WARNS("Messaging") << "Malformed inventory offer from object" << LL_ENDL;
+                        delete info;
+                        break;
+                    }
+                    info->mType = (LLAssetType::EType) binary_bucket[0];
+                    info->mObjectID = LLUUID::null;
+                    info->mFromObject = TRUE;
+                }
+            }
 
             info->mIM = dialog;
             info->mFromID = from_id;
             info->mFromGroup = from_group;
+            info->mTransactionID = session_id;
             info->mFolderID = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(info->mType));
 
             info->mFromName = name;
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index c07064389b6e07878d2fbfedaf44c07d9b2c3f29..d5142a4496a9b2bc3e9a6c2894d80a6ba3a73f7d 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -83,11 +83,6 @@ void startConfrenceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId,
 void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType);
 void start_deprecated_conference_chat(const LLUUID& temp_session_id, const LLUUID& creator_id, const LLUUID& other_participant_id, const LLSD& agents_to_invite);
 
-std::string LLCallDialogManager::sPreviousSessionlName = "";
-LLIMModel::LLIMSession::SType LLCallDialogManager::sPreviousSessionType = LLIMModel::LLIMSession::P2P_SESSION;
-std::string LLCallDialogManager::sCurrentSessionlName = "";
-LLIMModel::LLIMSession* LLCallDialogManager::sSession = NULL;
-LLVoiceChannel::EState LLCallDialogManager::sOldState = LLVoiceChannel::STATE_READY;
 const LLUUID LLOutgoingCallDialog::OCD_KEY = LLUUID("7CF78E11-0CFE-498D-ADB9-1417BF03DDB4");
 //
 // Globals
@@ -811,7 +806,7 @@ void LLIMModel::LLIMSession::addMessagesFromHistory(const std::list<LLSD>& histo
 		{
 			// convert it to a legacy name if we have a complete name
 			std::string legacy_name = gCacheName->buildLegacyName(from);
-			from_id = LLAvatarNameCache::findIdByName(legacy_name);
+			from_id = LLAvatarNameCache::getInstance()->findIdByName(legacy_name);
 		}
 
 		std::string timestamp = msg[LL_IM_TIME];
@@ -1795,7 +1790,12 @@ LLIMMgr::onConfirmForceCloseError(
 // Class LLCallDialogManager
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-LLCallDialogManager::LLCallDialogManager()
+LLCallDialogManager::LLCallDialogManager():
+mPreviousSessionlName(""),
+mPreviousSessionType(LLIMModel::LLIMSession::P2P_SESSION),
+mCurrentSessionlName(""),
+mSession(NULL),
+mOldState(LLVoiceChannel::STATE_READY)
 {
 }
 
@@ -1803,39 +1803,45 @@ LLCallDialogManager::~LLCallDialogManager()
 {
 }
 
-void LLCallDialogManager::initClass()
+void LLCallDialogManager::initSingleton()
 {
 	LLVoiceChannel::setCurrentVoiceChannelChangedCallback(LLCallDialogManager::onVoiceChannelChanged);
 }
 
+// static
 void LLCallDialogManager::onVoiceChannelChanged(const LLUUID &session_id)
+{
+    LLCallDialogManager::getInstance()->onVoiceChannelChangedInt(session_id);
+}
+
+void LLCallDialogManager::onVoiceChannelChangedInt(const LLUUID &session_id)
 {
 	LLIMModel::LLIMSession* session = LLIMModel::getInstance()->findIMSession(session_id);
 	if(!session)
 	{		
-		sPreviousSessionlName = sCurrentSessionlName;
-		sCurrentSessionlName = ""; // Empty string results in "Nearby Voice Chat" after substitution
+		mPreviousSessionlName = mCurrentSessionlName;
+		mCurrentSessionlName = ""; // Empty string results in "Nearby Voice Chat" after substitution
 		return;
 	}
 	
-	if (sSession)
+	if (mSession)
 	{
 		// store previous session type to process Avaline calls in dialogs
-		sPreviousSessionType = sSession->mSessionType;
+		mPreviousSessionType = mSession->mSessionType;
 	}
 
-	sSession = session;
+	mSession = session;
 
 	static boost::signals2::connection prev_channel_state_changed_connection;
 	// disconnect previously connected callback to avoid have invalid sSession in onVoiceChannelStateChanged()
 	prev_channel_state_changed_connection.disconnect();
 	prev_channel_state_changed_connection =
-		sSession->mVoiceChannel->setStateChangedCallback(boost::bind(LLCallDialogManager::onVoiceChannelStateChanged, _1, _2, _3, _4));
+		mSession->mVoiceChannel->setStateChangedCallback(boost::bind(LLCallDialogManager::onVoiceChannelStateChanged, _1, _2, _3, _4));
 
-	if(sCurrentSessionlName != session->mName)
+	if(mCurrentSessionlName != session->mName)
 	{
-		sPreviousSessionlName = sCurrentSessionlName;
-		sCurrentSessionlName = session->mName;
+		mPreviousSessionlName = mCurrentSessionlName;
+		mCurrentSessionlName = session->mName;
 	}
 
 	if (LLVoiceChannel::getCurrentVoiceChannel()->getState() == LLVoiceChannel::STATE_CALL_STARTED &&
@@ -1844,14 +1850,14 @@ void LLCallDialogManager::onVoiceChannelChanged(const LLUUID &session_id)
 		
 		//*TODO get rid of duplicated code
 		LLSD mCallDialogPayload;
-		mCallDialogPayload["session_id"] = sSession->mSessionID;
-		mCallDialogPayload["session_name"] = sSession->mName;
-		mCallDialogPayload["other_user_id"] = sSession->mOtherParticipantID;
-		mCallDialogPayload["old_channel_name"] = sPreviousSessionlName;
-		mCallDialogPayload["old_session_type"] = sPreviousSessionType;
+		mCallDialogPayload["session_id"] = mSession->mSessionID;
+		mCallDialogPayload["session_name"] = mSession->mName;
+		mCallDialogPayload["other_user_id"] = mSession->mOtherParticipantID;
+		mCallDialogPayload["old_channel_name"] = mPreviousSessionlName;
+		mCallDialogPayload["old_session_type"] = mPreviousSessionType;
 		mCallDialogPayload["state"] = LLVoiceChannel::STATE_CALL_STARTED;
-		mCallDialogPayload["disconnected_channel_name"] = sSession->mName;
-		mCallDialogPayload["session_type"] = sSession->mSessionType;
+		mCallDialogPayload["disconnected_channel_name"] = mSession->mName;
+		mCallDialogPayload["session_type"] = mSession->mSessionType;
 
 		LLOutgoingCallDialog* ocd = LLFloaterReg::getTypedInstance<LLOutgoingCallDialog>("outgoing_call", LLOutgoingCallDialog::OCD_KEY);
 		if(ocd)
@@ -1862,26 +1868,32 @@ void LLCallDialogManager::onVoiceChannelChanged(const LLUUID &session_id)
 
 }
 
+// static
 void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state, const LLVoiceChannel::EDirection& direction, bool ended_by_agent)
+{
+    LLCallDialogManager::getInstance()->onVoiceChannelStateChangedInt(old_state, new_state, direction, ended_by_agent);
+}
+
+void LLCallDialogManager::onVoiceChannelStateChangedInt(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state, const LLVoiceChannel::EDirection& direction, bool ended_by_agent)
 {
 	LLSD mCallDialogPayload;
 	LLOutgoingCallDialog* ocd = NULL;
 
-	if(sOldState == new_state)
+	if(mOldState == new_state)
 	{
 		return;
 	}
 
-	sOldState = new_state;
+	mOldState = new_state;
 
-	mCallDialogPayload["session_id"] = sSession->mSessionID;
-	mCallDialogPayload["session_name"] = sSession->mName;
-	mCallDialogPayload["other_user_id"] = sSession->mOtherParticipantID;
-	mCallDialogPayload["old_channel_name"] = sPreviousSessionlName;
-	mCallDialogPayload["old_session_type"] = sPreviousSessionType;
+	mCallDialogPayload["session_id"] = mSession->mSessionID;
+	mCallDialogPayload["session_name"] = mSession->mName;
+	mCallDialogPayload["other_user_id"] = mSession->mOtherParticipantID;
+	mCallDialogPayload["old_channel_name"] = mPreviousSessionlName;
+	mCallDialogPayload["old_session_type"] = mPreviousSessionType;
 	mCallDialogPayload["state"] = new_state;
-	mCallDialogPayload["disconnected_channel_name"] = sSession->mName;
-	mCallDialogPayload["session_type"] = sSession->mSessionType;
+	mCallDialogPayload["disconnected_channel_name"] = mSession->mName;
+	mCallDialogPayload["session_type"] = mSession->mSessionType;
 	mCallDialogPayload["ended_by_agent"] = ended_by_agent;
 
 	switch(new_state)
@@ -1896,7 +1908,7 @@ void LLCallDialogManager::onVoiceChannelStateChanged(const LLVoiceChannel::EStat
 
 	case LLVoiceChannel::STATE_HUNG_UP:
 		// this state is coming before session is changed, so, put it into payload map
-		mCallDialogPayload["old_session_type"] = sSession->mSessionType;
+		mCallDialogPayload["old_session_type"] = mSession->mSessionType;
 		break;
 
 	case LLVoiceChannel::STATE_CONNECTED :
@@ -1934,7 +1946,7 @@ LLCallDialog::LLCallDialog(const LLSD& payload)
 
 LLCallDialog::~LLCallDialog()
 {
-	LLUI::removePopup(this);
+	LLUI::getInstance()->removePopup(this);
 }
 
 BOOL LLCallDialog::postBuild()
@@ -2011,7 +2023,7 @@ void LLCallDialog::onOpen(const LLSD& key)
 	LLDockableFloater::onOpen(key);
 
 	// it should be over the all floaters. EXT-5116
-	LLUI::addPopup(this);
+	LLUI::getInstance()->addPopup(this);
 }
 
 void LLCallDialog::setIcon(const LLSD& session_id, const LLSD& participant_id)
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 344f6d9a83dec1469ae35d91d740aa2cda2eb459..79c831ebb6a6981d2f3695ee43c6bdc003bb615f 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -500,22 +500,26 @@ class LLIMMgr : public LLSingleton<LLIMMgr>
 	LLSD mPendingAgentListUpdates;
 };
 
-class LLCallDialogManager : public LLInitClass<LLCallDialogManager>
+class LLCallDialogManager : public LLSingleton<LLCallDialogManager>
 {
-public:
-	LLCallDialogManager();
+	LLSINGLETON(LLCallDialogManager);
 	~LLCallDialogManager();
-
-	static void initClass();
+public:
+	// static for convinience
 	static void onVoiceChannelChanged(const LLUUID &session_id);
 	static void onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state, const LLVoiceChannel::EDirection& direction, bool ended_by_agent);
 
+private:
+	void initSingleton();
+	void onVoiceChannelChangedInt(const LLUUID &session_id);
+	void onVoiceChannelStateChangedInt(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state, const LLVoiceChannel::EDirection& direction, bool ended_by_agent);
+
 protected:
-	static std::string sPreviousSessionlName;
-	static LLIMModel::LLIMSession::SType sPreviousSessionType;
-	static std::string sCurrentSessionlName;
-	static LLIMModel::LLIMSession* sSession;
-	static LLVoiceChannel::EState sOldState;
+	std::string mPreviousSessionlName;
+	LLIMModel::LLIMSession::SType mPreviousSessionType;
+	std::string mCurrentSessionlName;
+	LLIMModel::LLIMSession* mSession;
+	LLVoiceChannel::EState mOldState;
 };
 
 class LLCallDialog : public LLDockableFloater
diff --git a/indra/newview/llinspect.cpp b/indra/newview/llinspect.cpp
index e6cb068613c8bb1e1d6cd253d16e332fd39c0f81..479e8f9abf96bf65ffe9c3dec18e4e83786567a4 100644
--- a/indra/newview/llinspect.cpp
+++ b/indra/newview/llinspect.cpp
@@ -28,7 +28,7 @@
 
 #include "lltooltip.h"
 #include "llcontrol.h"	// LLCachedControl
-#include "llui.h"		// LLUI::sSettingsGroups
+#include "llui.h"		// LLUI::getInstance()->mSettingsGroups
 #include "llviewermenu.h"
 
 LLInspect::LLInspect(const LLSD& key)
@@ -45,8 +45,8 @@ LLInspect::~LLInspect()
 // virtual
 void LLInspect::draw()
 {
-	static LLCachedControl<F32> FADE_TIME(*LLUI::sSettingGroups["config"], "InspectorFadeTime", 1.f);
-	static LLCachedControl<F32> STAY_TIME(*LLUI::sSettingGroups["config"], "InspectorShowTime", 1.f);
+	static LLCachedControl<F32> FADE_TIME(*LLUI::getInstance()->mSettingGroups["config"], "InspectorFadeTime", 1.f);
+	static LLCachedControl<F32> STAY_TIME(*LLUI::getInstance()->mSettingGroups["config"], "InspectorShowTime", 1.f);
 	if (mOpenTimer.getStarted())
 	{
 		LLFloater::draw();
@@ -113,7 +113,7 @@ BOOL LLInspect::handleToolTip(S32 x, S32 y, MASK mask)
 		params.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>());
 		params.message = child_handler->getToolTip();
 		//set up delay if there is no visible tooltip at this moment
-		params.delay_time =  LLToolTipMgr::instance().toolTipVisible() ? 0.f : LLUI::sSettingGroups["config"]->getF32( "ToolTipDelay" );
+		params.delay_time =  LLToolTipMgr::instance().toolTipVisible() ? 0.f : LLUI::getInstance()->mSettingGroups["config"]->getF32( "ToolTipDelay" );
 		LLToolTipMgr::instance().show(params);
 		handled = TRUE;
 	}
@@ -137,7 +137,7 @@ bool LLInspect::childHasVisiblePopupMenu()
 		LLRect floater_rc = calcScreenRect();
 		LLRect menu_screen_rc = child_menu->calcScreenRect();
 		S32 mx, my;
-		LLUI::getMousePositionScreen(&mx, &my);
+		LLUI::getInstance()->getMousePositionScreen(&mx, &my);
 
 		// This works wrong if we spawn a menu near Inspector and menu overlaps Inspector.
 		if(floater_rc.overlaps(menu_screen_rc) && menu_screen_rc.pointInRect(mx, my))
diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index 88e7ad1b71b7f99ef77c64dc48946b978b1e3cc0..10814ac0769db1f3675c36211e83774d3a9eb84f 100644
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -207,11 +207,11 @@ void LLInspectAvatar::onOpen(const LLSD& data)
 	// See LLToolTipMgr::createToolTip
 	if (data.has("pos"))
 	{
-		LLUI::positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
+		LLUI::getInstance()->positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
 	}
 	else
 	{
-		LLUI::positionViewNearMouse(this);
+		LLUI::getInstance()->positionViewNearMouse(this);
 	}
 
 	// Generate link to avatar profile.
diff --git a/indra/newview/llinspectgroup.cpp b/indra/newview/llinspectgroup.cpp
index 8332443162add399e0c24916f6cc70618a662e8d..fa8a53c5466db45f0bb051f6a2680db36b512f00 100644
--- a/indra/newview/llinspectgroup.cpp
+++ b/indra/newview/llinspectgroup.cpp
@@ -129,11 +129,11 @@ void LLInspectGroup::onOpen(const LLSD& data)
 	// See LLToolTipMgr::createToolTip
 	if (data.has("pos"))
 	{
-		LLUI::positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
+		LLUI::getInstance()->positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
 	}
 	else
 	{
-		LLUI::positionViewNearMouse(this);
+		LLUI::getInstance()->positionViewNearMouse(this);
 	}
 
 	// can't call from constructor as widgets are not built yet
diff --git a/indra/newview/llinspectobject.cpp b/indra/newview/llinspectobject.cpp
index 46019557f85f91be6784dd5a4a169eaa15d3264f..f78a5cc64e0c2b9a3b65a39f6e9a5517c30403f8 100644
--- a/indra/newview/llinspectobject.cpp
+++ b/indra/newview/llinspectobject.cpp
@@ -202,11 +202,11 @@ void LLInspectObject::onOpen(const LLSD& data)
 	// See LLToolTipMgr::createToolTip
 	if (data.has("pos"))
 	{
-		LLUI::positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
+		LLUI::getInstance()->positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
 	}
 	else
 	{
-		LLUI::positionViewNearMouse(this);
+		LLUI::getInstance()->positionViewNearMouse(this);
 	}
 
 	// Promote hovered object to a complete selection, which will also force
@@ -241,7 +241,7 @@ void LLInspectObject::onOpen(const LLSD& data)
 		if(!mMediaEntry)
 			return;
 		
-		mMediaImpl = LLViewerMedia::getMediaImplFromTextureID(mMediaEntry->getMediaID());
+		mMediaImpl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mMediaEntry->getMediaID());
 	}
 }
 
@@ -300,7 +300,7 @@ void LLInspectObject::update()
 	if(!mMediaEntry)
 		return;
 	
-	mMediaImpl = LLViewerMedia::getMediaImplFromTextureID(mMediaEntry->getMediaID());
+	mMediaImpl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mMediaEntry->getMediaID());
 	
 	updateMediaCurrentURL();
 	updateSecureBrowsing();
diff --git a/indra/newview/llinspectremoteobject.cpp b/indra/newview/llinspectremoteobject.cpp
index b64df2bd47176affd6fcfc24bb7de8f2f3c24d1f..272c8acbd5b8fc0d683b52d0af7bb00ea1c9f6cc 100644
--- a/indra/newview/llinspectremoteobject.cpp
+++ b/indra/newview/llinspectremoteobject.cpp
@@ -116,11 +116,11 @@ void LLInspectRemoteObject::onOpen(const LLSD& data)
 	// See LLToolTipMgr::createToolTip
 	if (data.has("pos"))
 	{
-		LLUI::positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
+		LLUI::getInstance()->positionViewNearMouse(this, data["pos"]["x"].asInteger(), data["pos"]["y"].asInteger());
 	}
 	else
 	{
-		LLUI::positionViewNearMouse(this);
+		LLUI::getInstance()->positionViewNearMouse(this);
 	}
 }
 
diff --git a/indra/newview/llinspecttoast.cpp b/indra/newview/llinspecttoast.cpp
index 47560341e727c48312d96e4b63e9a0c22e013dec..d0034eff1346ea0bfdc34aef61576cc6251626ad 100644
--- a/indra/newview/llinspecttoast.cpp
+++ b/indra/newview/llinspecttoast.cpp
@@ -110,7 +110,7 @@ void LLInspectToast::onOpen(const LLSD& notification_id)
 	panel_rect = panel->getRect();
 	reshape(panel_rect.getWidth(), panel_rect.getHeight());
 
-	LLUI::positionViewNearMouse(this);
+	LLUI::getInstance()->positionViewNearMouse(this);
 }
 
 // virtual
diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index 0243e2183e6d4a328758e5c3d338dbae122a23e8..b8bde39bd105af0d6cf8991be35e821ba8250c5a 100644
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -69,9 +69,6 @@
 /*=======================================*/
 /*  Formal declarations, constants, etc. */
 /*=======================================*/ 
-std::list<LLLocalBitmap*>   LLLocalBitmapMgr::sBitmapList;
-LLLocalBitmapTimer          LLLocalBitmapMgr::sTimer;
-bool                        LLLocalBitmapMgr::sNeedsRebake;
 
 static const F32 LL_LOCAL_TIMER_HEARTBEAT   = 3.0;
 static const BOOL LL_LOCAL_USE_MIPMAPS      = true;
@@ -131,7 +128,7 @@ LLLocalBitmap::~LLLocalBitmap()
 	if(LL_LOCAL_REPLACE_ON_DEL && mValid && gAgentAvatarp) // fix for STORM-1837
 	{
 		replaceIDs(mWorldID, IMG_DEFAULT);
-		LLLocalBitmapMgr::doRebake();
+		LLLocalBitmapMgr::getInstance()->doRebake();
 	}
 
 	// delete self from gimagelist
@@ -571,7 +568,7 @@ void LLLocalBitmap::updateUserLayers(LLUUID old_id, LLUUID new_id, LLWearableTyp
 							gAgentAvatarp->setLocalTexture(reg_texind, gTextureList.getImage(new_id), FALSE, index);
 							gAgentAvatarp->wearableUpdated(type);
 							/* telling the manager to rebake once update cycle is fully done */
-							LLLocalBitmapMgr::setNeedsRebake();
+							LLLocalBitmapMgr::getInstance()->setNeedsRebake();
 						}
 					}
 
@@ -905,7 +902,7 @@ bool LLLocalBitmapTimer::isRunning()
 
 BOOL LLLocalBitmapTimer::tick()
 {
-	LLLocalBitmapMgr::doUpdates();
+	LLLocalBitmapMgr::getInstance()->doUpdates();
 	return FALSE;
 }
 
@@ -914,17 +911,12 @@ BOOL LLLocalBitmapTimer::tick()
 /*=======================================*/ 
 LLLocalBitmapMgr::LLLocalBitmapMgr()
 {
-	// The class is all made of static members, should i even bother instantiating?
 }
 
 LLLocalBitmapMgr::~LLLocalBitmapMgr()
 {
-}
-
-void LLLocalBitmapMgr::cleanupClass()
-{
-	std::for_each(sBitmapList.begin(), sBitmapList.end(), DeletePointer());
-	sBitmapList.clear();
+    std::for_each(mBitmapList.begin(), mBitmapList.end(), DeletePointer());
+    mBitmapList.clear();
 }
 
 bool LLLocalBitmapMgr::addUnit()
@@ -934,7 +926,7 @@ bool LLLocalBitmapMgr::addUnit()
 	LLFilePicker& picker = LLFilePicker::instance();
 	if (picker.getMultipleOpenFiles(LLFilePicker::FFLOAD_IMAGE))
 	{
-		sTimer.stopTimer();
+		mTimer.stopTimer();
 
 		std::string filename = picker.getFirstFile();
 		while(!filename.empty())
@@ -949,7 +941,7 @@ bool LLLocalBitmapMgr::addUnit()
 
 			if (unit->getValid())
 			{
-				sBitmapList.push_back(unit);
+				mBitmapList.push_back(unit);
 				add_successful = true;
 			}
 			else
@@ -968,7 +960,7 @@ bool LLLocalBitmapMgr::addUnit()
 			filename = picker.getNextFile();
 		}
 		
-		sTimer.startTimer();
+		mTimer.startTimer();
 	}
 
 	return add_successful;
@@ -1007,10 +999,10 @@ bool LLLocalBitmapMgr::checkTextureDimensions(std::string filename)
 
 void LLLocalBitmapMgr::delUnit(LLUUID tracking_id)
 {
-	if (!sBitmapList.empty())
+	if (!mBitmapList.empty())
 	{	
 		std::vector<LLLocalBitmap*> to_delete;
-		for (local_list_iter iter = sBitmapList.begin(); iter != sBitmapList.end(); iter++)
+		for (local_list_iter iter = mBitmapList.begin(); iter != mBitmapList.end(); iter++)
 		{   /* finding which ones we want deleted and making a separate list */
 			LLLocalBitmap* unit = *iter;
 			if (unit->getTrackingID() == tracking_id)
@@ -1023,7 +1015,7 @@ void LLLocalBitmapMgr::delUnit(LLUUID tracking_id)
 			del_iter != to_delete.end(); del_iter++)
 		{   /* iterating over a temporary list, hence preserving the iterator validity while deleting. */
 			LLLocalBitmap* unit = *del_iter;
-			sBitmapList.remove(unit);
+			mBitmapList.remove(unit);
 			delete unit;
 			unit = NULL;
 		}
@@ -1034,7 +1026,7 @@ LLUUID LLLocalBitmapMgr::getWorldID(LLUUID tracking_id)
 {
 	LLUUID world_id = LLUUID::null;
 
-	for (local_list_iter iter = sBitmapList.begin(); iter != sBitmapList.end(); iter++)
+	for (local_list_iter iter = mBitmapList.begin(); iter != mBitmapList.end(); iter++)
 	{
 		LLLocalBitmap* unit = *iter;
 		if (unit->getTrackingID() == tracking_id)
@@ -1050,7 +1042,7 @@ std::string LLLocalBitmapMgr::getFilename(LLUUID tracking_id)
 {
 	std::string filename = "";
 
-	for (local_list_iter iter = sBitmapList.begin(); iter != sBitmapList.end(); iter++)
+	for (local_list_iter iter = mBitmapList.begin(); iter != mBitmapList.end(); iter++)
 	{
 		LLLocalBitmap* unit = *iter;
 		if (unit->getTrackingID() == tracking_id)
@@ -1068,10 +1060,10 @@ void LLLocalBitmapMgr::feedScrollList(LLScrollListCtrl* ctrl)
 	{
 		ctrl->clearRows();
 
-		if (!sBitmapList.empty())
+		if (!mBitmapList.empty())
 		{
-			for (local_list_iter iter = sBitmapList.begin();
-				 iter != sBitmapList.end(); iter++)
+			for (local_list_iter iter = mBitmapList.begin();
+				 iter != mBitmapList.end(); iter++)
 			{
 				LLSD element;
 				element["columns"][0]["column"] = "unit_name";
@@ -1092,29 +1084,29 @@ void LLLocalBitmapMgr::feedScrollList(LLScrollListCtrl* ctrl)
 void LLLocalBitmapMgr::doUpdates()
 {
 	// preventing theoretical overlap in cases with huge number of loaded images.
-	sTimer.stopTimer();
-	sNeedsRebake = false;
+	mTimer.stopTimer();
+	mNeedsRebake = false;
 
-	for (local_list_iter iter = sBitmapList.begin(); iter != sBitmapList.end(); iter++)
+	for (local_list_iter iter = mBitmapList.begin(); iter != mBitmapList.end(); iter++)
 	{
 		(*iter)->updateSelf();
 	}
 
 	doRebake();
-	sTimer.startTimer();
+	mTimer.startTimer();
 }
 
 void LLLocalBitmapMgr::setNeedsRebake()
 {
-	sNeedsRebake = true;
+	mNeedsRebake = true;
 }
 
 void LLLocalBitmapMgr::doRebake()
 { /* separated that from doUpdates to insure a rebake can be called separately during deletion */
-	if (sNeedsRebake)
+	if (mNeedsRebake)
 	{
 		gAgentAvatarp->forceBakeAllTextures(LL_LOCAL_SLAM_FOR_DEBUG);
-		sNeedsRebake = false;
+		mNeedsRebake = false;
 	}
 }
 
diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h
index ee4161fb45f8397b9640fc92ff925371387fb5a1..f6cc1e919e00cc8bdc82565de32c254786e3a5fa 100644
--- a/indra/newview/lllocalbitmaps.h
+++ b/indra/newview/lllocalbitmaps.h
@@ -110,31 +110,28 @@ class LLLocalBitmapTimer : public LLEventTimer
 
 };
 
-class LLLocalBitmapMgr
+class LLLocalBitmapMgr : public LLSingleton<LLLocalBitmapMgr>
 {
-	public:
-		LLLocalBitmapMgr();
-		~LLLocalBitmapMgr();
-
-	public:
-		static void			cleanupClass();
-		static bool         addUnit();
-		static void         delUnit(LLUUID tracking_id);
-		static bool 		checkTextureDimensions(std::string filename);
-
-		static LLUUID       getWorldID(LLUUID tracking_id);
-		static std::string  getFilename(LLUUID tracking_id);
-		
-		static void         feedScrollList(LLScrollListCtrl* ctrl);
-		static void         doUpdates();
-		static void         setNeedsRebake();
-		static void         doRebake();
-		
-	private:
-		static std::list<LLLocalBitmap*>    sBitmapList;
-		static LLLocalBitmapTimer           sTimer;
-		static bool                         sNeedsRebake;
-		typedef std::list<LLLocalBitmap*>::iterator local_list_iter;
+	LLSINGLETON(LLLocalBitmapMgr);
+	~LLLocalBitmapMgr();
+public:
+	bool         addUnit();
+	void         delUnit(LLUUID tracking_id);
+	bool 		checkTextureDimensions(std::string filename);
+
+	LLUUID       getWorldID(LLUUID tracking_id);
+	std::string  getFilename(LLUUID tracking_id);
+
+	void         feedScrollList(LLScrollListCtrl* ctrl);
+	void         doUpdates();
+	void         setNeedsRebake();
+	void         doRebake();
+	
+private:
+	std::list<LLLocalBitmap*>    mBitmapList;
+	LLLocalBitmapTimer           mTimer;
+	bool                         mNeedsRebake;
+	typedef std::list<LLLocalBitmap*>::iterator local_list_iter;
 };
 
 #endif
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 638daef598133aae93b80f68d41396569176b5ba..802e4941e634c6137f7faee131054389ac7b7ce1 100644
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -666,7 +666,7 @@ void LLLocationInputCtrl::onAgentParcelChange()
 
 void LLLocationInputCtrl::onMaturityButtonClicked()
 {
-	LLUI::sHelpImpl->showTopic(mMaturityHelpTopic);
+	LLUI::getInstance()->mHelpImpl->showTopic(mMaturityHelpTopic);
 }
 
 void LLLocationInputCtrl::onRegionBoundaryCrossed()
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index e2f253d2bdcd34ffe7e13b225759af6f552974e0..0c64531783b6cfa32c73626fd068dc313bfb4373 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -211,11 +211,24 @@ LLLogChatTimeScanner::LLLogChatTimeScanner()
 	mTimeStream.imbue(std::locale(mTimeStream.getloc(), new time_input_facet(DATE_FORMAT)));
 }
 
-LLLogChat::save_history_signal_t * LLLogChat::sSaveHistorySignal = NULL;
+LLLogChat::LLLogChat()
+: mSaveHistorySignal(NULL) // only needed in preferences
+{
+    mHistoryThreadsMutex = new LLMutex();
+}
 
-std::map<LLUUID,LLLoadHistoryThread *> LLLogChat::sLoadHistoryThreads;
-std::map<LLUUID,LLDeleteHistoryThread *> LLLogChat::sDeleteHistoryThreads;
-LLMutex* LLLogChat::sHistoryThreadsMutex = NULL;
+LLLogChat::~LLLogChat()
+{
+    delete mHistoryThreadsMutex;
+    mHistoryThreadsMutex = NULL;
+
+    if (mSaveHistorySignal)
+    {
+        mSaveHistorySignal->disconnect_all_slots();
+        delete mSaveHistorySignal;
+        mSaveHistorySignal = NULL;
+    }
+}
 
 
 //static
@@ -340,10 +353,7 @@ void LLLogChat::saveHistory(const std::string& filename,
 
 	file.close();
 
-	if (NULL != sSaveHistorySignal)
-	{
-		(*sSaveHistorySignal)();
-	}
+	LLLogChat::getInstance()->triggerHistorySignal();
 }
 
 // static
@@ -433,13 +443,12 @@ void LLLogChat::loadChatHistory(const std::string& file_name, std::list<LLSD>& m
 	fclose(fptr);
 }
 
-// static
 bool LLLogChat::historyThreadsFinished(LLUUID session_id)
 {
 	LLMutexLock lock(historyThreadsMutex());
 	bool finished = true;
-	std::map<LLUUID,LLLoadHistoryThread *>::iterator it = sLoadHistoryThreads.find(session_id);
-	if (it != sLoadHistoryThreads.end())
+	std::map<LLUUID,LLLoadHistoryThread *>::iterator it = mLoadHistoryThreads.find(session_id);
+	if (it != mLoadHistoryThreads.end())
 	{
 		finished = it->second->isFinished();
 	}
@@ -447,95 +456,93 @@ bool LLLogChat::historyThreadsFinished(LLUUID session_id)
 	{
 		return false;
 	}
-	std::map<LLUUID,LLDeleteHistoryThread *>::iterator dit = sDeleteHistoryThreads.find(session_id);
-	if (dit != sDeleteHistoryThreads.end())
+	std::map<LLUUID,LLDeleteHistoryThread *>::iterator dit = mDeleteHistoryThreads.find(session_id);
+	if (dit != mDeleteHistoryThreads.end())
 	{
 		finished = finished && dit->second->isFinished();
 	}
 	return finished;
 }
 
-// static
 LLLoadHistoryThread* LLLogChat::getLoadHistoryThread(LLUUID session_id)
 {
 	LLMutexLock lock(historyThreadsMutex());
-	std::map<LLUUID,LLLoadHistoryThread *>::iterator it = sLoadHistoryThreads.find(session_id);
-	if (it != sLoadHistoryThreads.end())
+	std::map<LLUUID,LLLoadHistoryThread *>::iterator it = mLoadHistoryThreads.find(session_id);
+	if (it != mLoadHistoryThreads.end())
 	{
 		return it->second;
 	}
 	return NULL;
 }
 
-// static
 LLDeleteHistoryThread* LLLogChat::getDeleteHistoryThread(LLUUID session_id)
 {
 	LLMutexLock lock(historyThreadsMutex());
-	std::map<LLUUID,LLDeleteHistoryThread *>::iterator it = sDeleteHistoryThreads.find(session_id);
-	if (it != sDeleteHistoryThreads.end())
+	std::map<LLUUID,LLDeleteHistoryThread *>::iterator it = mDeleteHistoryThreads.find(session_id);
+	if (it != mDeleteHistoryThreads.end())
 	{
 		return it->second;
 	}
 	return NULL;
 }
 
-// static
 bool LLLogChat::addLoadHistoryThread(LLUUID& session_id, LLLoadHistoryThread* lthread)
 {
 	LLMutexLock lock(historyThreadsMutex());
-	std::map<LLUUID,LLLoadHistoryThread *>::const_iterator it = sLoadHistoryThreads.find(session_id);
-	if (it != sLoadHistoryThreads.end())
+	std::map<LLUUID,LLLoadHistoryThread *>::const_iterator it = mLoadHistoryThreads.find(session_id);
+	if (it != mLoadHistoryThreads.end())
 	{
 		return false;
 	}
-	sLoadHistoryThreads[session_id] = lthread;
+	mLoadHistoryThreads[session_id] = lthread;
 	return true;
 }
 
-// static
 bool LLLogChat::addDeleteHistoryThread(LLUUID& session_id, LLDeleteHistoryThread* dthread)
 {
 	LLMutexLock lock(historyThreadsMutex());
-	std::map<LLUUID,LLDeleteHistoryThread *>::const_iterator it = sDeleteHistoryThreads.find(session_id);
-	if (it != sDeleteHistoryThreads.end())
+	std::map<LLUUID,LLDeleteHistoryThread *>::const_iterator it = mDeleteHistoryThreads.find(session_id);
+	if (it != mDeleteHistoryThreads.end())
 	{
 		return false;
 	}
-	sDeleteHistoryThreads[session_id] = dthread;
+	mDeleteHistoryThreads[session_id] = dthread;
 	return true;
 }
 
-// static
 void LLLogChat::cleanupHistoryThreads()
 {
 	LLMutexLock lock(historyThreadsMutex());
 	std::vector<LLUUID> uuids;
-	std::map<LLUUID,LLLoadHistoryThread *>::iterator lit = sLoadHistoryThreads.begin();
-	for (; lit != sLoadHistoryThreads.end(); lit++)
+	std::map<LLUUID,LLLoadHistoryThread *>::iterator lit = mLoadHistoryThreads.begin();
+	for (; lit != mLoadHistoryThreads.end(); lit++)
 	{
-		if (lit->second->isFinished() && sDeleteHistoryThreads[lit->first]->isFinished())
+		if (lit->second->isFinished() && mDeleteHistoryThreads[lit->first]->isFinished())
 		{
 			delete lit->second;
-			delete sDeleteHistoryThreads[lit->first];
+			delete mDeleteHistoryThreads[lit->first];
 			uuids.push_back(lit->first);
 		}
 	}
 	std::vector<LLUUID>::iterator uuid_it = uuids.begin();
 	for ( ;uuid_it != uuids.end(); uuid_it++)
 	{
-		sLoadHistoryThreads.erase(*uuid_it);
-		sDeleteHistoryThreads.erase(*uuid_it);
+		mLoadHistoryThreads.erase(*uuid_it);
+		mDeleteHistoryThreads.erase(*uuid_it);
 	}
 }
 
-//static
 LLMutex* LLLogChat::historyThreadsMutex()
 {
-	if (sHistoryThreadsMutex == NULL)
-	{
-		sHistoryThreadsMutex = new LLMutex();
-	}
-	return sHistoryThreadsMutex;
+	return mHistoryThreadsMutex;
+}
+
+void LLLogChat::triggerHistorySignal()
+{
+    if (NULL != mSaveHistorySignal)
+    {
+        (*mSaveHistorySignal)();
+    }
 }
 
 // static
@@ -613,15 +620,14 @@ void LLLogChat::getListOfTranscriptBackupFiles(std::vector<std::string>& list_of
 	findTranscriptFiles(pattern, list_of_transcriptions);
 }
 
-//static
 boost::signals2::connection LLLogChat::setSaveHistorySignal(const save_history_signal_t::slot_type& cb)
 {
-	if (NULL == sSaveHistorySignal)
+	if (NULL == mSaveHistorySignal)
 	{
-		sSaveHistorySignal = new save_history_signal_t();
+		mSaveHistorySignal = new save_history_signal_t();
 	}
 
-	return sSaveHistorySignal->connect(cb);
+	return mSaveHistorySignal->connect(cb);
 }
 
 //static
diff --git a/indra/newview/lllogchat.h b/indra/newview/lllogchat.h
index 6ccb2caf43dce06c48560ea20da76e1d8e390935..8b7fe14e1684ad4c6c4b7596a09aaa948978f154 100644
--- a/indra/newview/lllogchat.h
+++ b/indra/newview/lllogchat.h
@@ -79,8 +79,10 @@ class LLDeleteHistoryThread : public LLActionThread
 	static void deleteHistory();
 };
 
-class LLLogChat
+class LLLogChat : public LLSingleton<LLLogChat>
 {
+    LLSINGLETON(LLLogChat);
+    ~LLLogChat();
 public:
 	// status values for callback function
 	enum ELogLineType {
@@ -107,7 +109,7 @@ class LLLogChat
 	static void loadChatHistory(const std::string& file_name, std::list<LLSD>& messages, const LLSD& load_params = LLSD(), bool is_group = false);
 
 	typedef boost::signals2::signal<void ()> save_history_signal_t;
-	static boost::signals2::connection setSaveHistorySignal(const save_history_signal_t::slot_type& cb);
+	boost::signals2::connection setSaveHistorySignal(const save_history_signal_t::slot_type& cb);
 
 	static bool moveTranscripts(const std::string currentDirectory, 
 									const std::string newDirectory, 
@@ -123,21 +125,23 @@ class LLLogChat
 	static bool isAdHocTranscriptExist(std::string file_name);
 	static bool isTranscriptFileFound(std::string fullname);
 
-	static bool historyThreadsFinished(LLUUID session_id);
-	static LLLoadHistoryThread* getLoadHistoryThread(LLUUID session_id);
-	static LLDeleteHistoryThread* getDeleteHistoryThread(LLUUID session_id);
-	static bool addLoadHistoryThread(LLUUID& session_id, LLLoadHistoryThread* lthread);
-	static bool addDeleteHistoryThread(LLUUID& session_id, LLDeleteHistoryThread* dthread);
-	static void cleanupHistoryThreads();
+	bool historyThreadsFinished(LLUUID session_id);
+	LLLoadHistoryThread* getLoadHistoryThread(LLUUID session_id);
+	LLDeleteHistoryThread* getDeleteHistoryThread(LLUUID session_id);
+	bool addLoadHistoryThread(LLUUID& session_id, LLLoadHistoryThread* lthread);
+	bool addDeleteHistoryThread(LLUUID& session_id, LLDeleteHistoryThread* dthread);
+	void cleanupHistoryThreads();
 
 private:
 	static std::string cleanFileName(std::string filename);
-	static save_history_signal_t * sSaveHistorySignal;
 
-	static std::map<LLUUID,LLLoadHistoryThread *> sLoadHistoryThreads;
-	static std::map<LLUUID,LLDeleteHistoryThread *> sDeleteHistoryThreads;
-	static LLMutex* sHistoryThreadsMutex;
-	static LLMutex* historyThreadsMutex();
+	LLMutex* historyThreadsMutex();
+	void triggerHistorySignal();
+
+	save_history_signal_t * mSaveHistorySignal;
+	std::map<LLUUID,LLLoadHistoryThread *> mLoadHistoryThreads;
+	std::map<LLUUID,LLDeleteHistoryThread *> mDeleteHistoryThreads;
+	LLMutex* mHistoryThreadsMutex;
 };
 
 /**
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 92a09357c8fa5adc77405f2118df0aceb10915db..9248c160c66cca92b2b839a9b6ff31699537dbfe 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -386,7 +386,7 @@ BOOL LLManipTranslate::handleMouseDownOnPart( S32 x, S32 y, MASK mask )
 		}
 		else if (gSavedSettings.getBOOL("SnapToMouseCursor"))
 		{
-			LLUI::setMousePositionScreen(mouse_pos.mX, mouse_pos.mY);
+			LLUI::getInstance()->setMousePositionScreen(mouse_pos.mX, mouse_pos.mY);
 			x = mouse_pos.mX;
 			y = mouse_pos.mY;
 		}
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index 26977593f4a59ed07c399bef92ef83bef8d81afa..aa0c7fb73bcbe46d739a249d0fe020fedbf1c28a 100644
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -219,7 +219,7 @@ namespace LLMarketplaceImport
         httpHeaders->append(HTTP_OUT_HEADER_CONNECTION, "Keep-Alive");
         httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sMarketplaceCookie);
         httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML);
-        httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getCurrentUserAgent());
+        httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getInstance()->getCurrentUserAgent());
 
         LLSD result = httpAdapter->postAndSuspend(httpRequest, url, LLSD(), httpOpts, httpHeaders);
 
@@ -283,11 +283,11 @@ namespace LLMarketplaceImport
             httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*");
             httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sMarketplaceCookie);
             httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);
-            httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getCurrentUserAgent());
+            httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getInstance()->getCurrentUserAgent());
         }
         else
         {
-            httpHeaders = LLViewerMedia::getHttpHeaders();
+            httpHeaders = LLViewerMedia::getInstance()->getHttpHeaders();
         }
 
         LLSD result = httpAdapter->getAndSuspend(httpRequest, url, httpOpts, httpHeaders);
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 6cab9b9e99754e7ae19e6efb51dd7fb54625e988..0affe8efb4b51f15efb57b8560ade06b949b4e08 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -708,7 +708,7 @@ bool LLMediaCtrl::ensureMediaSourceExists()
 	if(mMediaSource.isNull())
 	{
 		// If we don't already have a media source, try to create one.
-		mMediaSource = LLViewerMedia::newMediaImpl(mMediaTextureID, mTextureWidth, mTextureHeight);
+		mMediaSource = LLViewerMedia::getInstance()->newMediaImpl(mMediaTextureID, mTextureWidth, mTextureHeight);
 		if ( mMediaSource )
 		{
 			mMediaSource->setUsedInUI(true);
@@ -1115,7 +1115,7 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)
 			auth_request_params.substitutions = args;
 
 			auth_request_params.payload = LLSD().with("media_id", mMediaTextureID);
-			auth_request_params.functor.function = boost::bind(&LLViewerMedia::onAuthSubmit, _1, _2);
+			auth_request_params.functor.function = boost::bind(&LLViewerMedia::authSubmitCallback, _1, _2);
 			LLNotifications::instance().add(auth_request_params);
 		};
 		break;
@@ -1161,7 +1161,7 @@ void LLMediaCtrl::onPopup(const LLSD& notification, const LLSD& response)
 	else
 	{
 		// Make sure the opening instance knows its window open request was denied, so it can clean things up.
-		LLViewerMedia::proxyWindowClosed(notification["payload"]["uuid"]);
+		LLViewerMedia::getInstance()->proxyWindowClosed(notification["payload"]["uuid"]);
 	}
 }
 
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp
index 28201b7345e146c60cda1e54ec1828a01a812117..54409a69943fb201bec596cfad43d18d656fefa5 100644
--- a/indra/newview/llmoveview.cpp
+++ b/indra/newview/llmoveview.cpp
@@ -568,7 +568,7 @@ BOOL LLPanelStandStopFlying::postBuild()
 	mStandButton->setCommitCallback(boost::bind(&LLPanelStandStopFlying::onStandButtonClick, this));
 	mStandButton->setCommitCallback(boost::bind(&LLFloaterMove::enableInstance));
 	mStandButton->setVisible(FALSE);
-	LLHints::registerHintTarget("stand_btn", mStandButton->getHandle());
+	LLHints::getInstance()->registerHintTarget("stand_btn", mStandButton->getHandle());
 	
 	mStopFlyingButton = getChild<LLButton>("stop_fly_btn");
 	//mStopFlyingButton->setCommitCallback(boost::bind(&LLFloaterMove::setFlyingMode, FALSE));
@@ -672,7 +672,7 @@ LLPanelStandStopFlying* LLPanelStandStopFlying::getStandStopFlyingPanel()
 	panel->buildFromFile("panel_stand_stop_flying.xml");
 
 	panel->setVisible(FALSE);
-	//LLUI::getRootView()->addChild(panel);
+	//LLUI::getInstance()->getRootView()->addChild(panel);
 
 	LL_INFOS() << "Build LLPanelStandStopFlying panel" << LL_ENDL;
 
diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp
index d7c5364fba0e27ca162b2f542719e02e72ac5f10..3209d23e430b7f127165c19fcee7444301871561 100644
--- a/indra/newview/llnamelistctrl.cpp
+++ b/indra/newview/llnamelistctrl.cpp
@@ -154,7 +154,7 @@ void	LLNameListCtrl::mouseOverHighlightNthItem( S32 target_index )
 		bool is_mouse_over_name_cell = false;
 
 		S32 mouse_x, mouse_y;
-		LLUI::getMousePositionLocal(this, &mouse_x, &mouse_y);
+		LLUI::getInstance()->getMousePositionLocal(this, &mouse_x, &mouse_y);
 
 		S32 column_index = getColumnIndexFromOffset(mouse_x);
 		LLScrollListItem* hit_item = hitItem(mouse_x, mouse_y);
diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp
index cfe2e6bf6a7bc17e0c4a9488549af68a0ef99622..179c64b5c572d5882e499d7211340af28464f15d 100644
--- a/indra/newview/llnavigationbar.cpp
+++ b/indra/newview/llnavigationbar.cpp
@@ -320,7 +320,7 @@ BOOL LLNavigationBar::postBuild()
 	LLTeleportHistory::getInstance()->setHistoryChangedCallback(
 			boost::bind(&LLNavigationBar::onTeleportHistoryChanged, this));
 
-	LLHints::registerHintTarget("nav_bar", getHandle());
+	LLHints::getInstance()->registerHintTarget("nav_bar", getHandle());
 
 	mNavigationPanel = getChild<LLLayoutPanel>("navigation_layout_panel");
 	mFavoritePanel = getChild<LLLayoutPanel>("favorites_layout_panel");
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index cb6f3fcf2d1e4a58199c8a3bab4c0ff6b56484a7..112da556825647b5d5d1ed65cd2119c8f576b1e2 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -329,7 +329,7 @@ void LLNetMap::draw()
 		S32 local_mouse_x;
 		S32 local_mouse_y;
 		//localMouse(&local_mouse_x, &local_mouse_y);
-		LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
+		LLUI::getInstance()->getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
 		mClosestAgentToCursor.setNull();
 		F32 closest_dist_squared = F32_MAX; // value will be overridden in the loop
 		F32 min_pick_dist_squared = (mDotRadius * MIN_PICK_SCALE) * (mDotRadius * MIN_PICK_SCALE);
@@ -835,7 +835,7 @@ BOOL LLNetMap::handleMouseUp( S32 x, S32 y, MASK mask )
 			LLRect clip_rect = getRect();
 			clip_rect.stretch(-8);
 			clip_rect.clipPointToRect(mMouseDown.mX, mMouseDown.mY, local_x, local_y);
-			LLUI::setMousePositionLocal(this, local_x, local_y);
+			LLUI::getInstance()->setMousePositionLocal(this, local_x, local_y);
 
 			// finish the pan
 			mPanning = false;
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index 6a5819676079934bd4afc6b76e410fb3cc83a9dd..9a3f1a853a9f3066ca11193c8d4b7fb9b855411b 100644
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -177,7 +177,7 @@ void LLHandlerUtil::logGroupNoticeToIMGroup(
 	{
 		// Legacy support and fallback method
 		// if we can't retrieve sender id from group notice system message, try to lookup it from cache
-		sender_id = LLAvatarNameCache::findIdByName(sender_name);
+		sender_id = LLAvatarNameCache::getInstance()->findIdByName(sender_name);
 	}
 
 	logToIM(IM_SESSION_GROUP_START, group_name, sender_name, payload["message"],
diff --git a/indra/newview/llnotificationhinthandler.cpp b/indra/newview/llnotificationhinthandler.cpp
index f40369a2e061735eaa67b9eff730addf3e9c3944..f1226c53ffe0b20c135f70d02e16a6d5bc858474 100644
--- a/indra/newview/llnotificationhinthandler.cpp
+++ b/indra/newview/llnotificationhinthandler.cpp
@@ -40,17 +40,17 @@ LLHintHandler::LLHintHandler()
 
 void LLHintHandler::onAdd(LLNotificationPtr p)
 {
-	LLHints::show(p);
+	LLHints::getInstance()->show(p);
 }
 
 void LLHintHandler::onLoad(LLNotificationPtr p)
 {
-	LLHints::show(p);
+	LLHints::getInstance()->show(p);
 }
 
 void LLHintHandler::onDelete(LLNotificationPtr p)
 {
-	LLHints::hide(p);
+	LLHints::getInstance()->hide(p);
 }
 
 bool LLHintHandler::processNotification(const LLNotificationPtr& p)
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index c686aab82178f50b4a3794e612bf4b96864ade80..5742b5ad1a5b7c40ce245db871037072c35fb664 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -979,7 +979,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
                break;
 				}
 
-			if(LLViewerMedia::textureHasMedia(id))
+			if(LLViewerMedia::getInstance()->textureHasMedia(id))
 			{
 				getChildView("button align")->setEnabled(editable);
 			}
@@ -2517,13 +2517,13 @@ struct LLPanelFaceSetMediaFunctor : public LLSelectedTEFunctor
 		const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL;
 		if ( mep )
 		{
-			pMediaImpl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+			pMediaImpl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
 		}
 		
 		if ( pMediaImpl.isNull())
 		{
 			// If we didn't find face media for this face, check whether this face is showing parcel media.
-			pMediaImpl = LLViewerMedia::getMediaImplFromTextureID(tep->getID());
+			pMediaImpl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(tep->getID());
 		}
 		
 		if ( pMediaImpl.notNull())
@@ -2691,7 +2691,7 @@ void LLPanelFace::LLSelectedTE::getTexId(LLUUID& id, bool& identical)
 				id = image->getID();
 			}
 
-			if (!id.isNull() && LLViewerMedia::textureHasMedia(id))
+			if (!id.isNull() && LLViewerMedia::getInstance()->textureHasMedia(id))
 			{
 				if (te)
 				{
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index d7c189271edf301f0bc1836a161bf64073bd8eec..4fd39d12117ac933379f12137eee818a5ac03478 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -554,12 +554,12 @@ void LLPanelLogin::populateFields(LLPointer<LLCredential> credential, bool remem
     if (sInstance->mFirstLoginThisInstall)
     {
         // no list to populate
-        setFields(credential, remember_psswrd);
+        setFields(credential);
     }
     else
     {
         sInstance->getChild<LLUICtrl>("remember_name")->setValue(remember_user);
-        sInstance->populateUserList(credential, remember_psswrd);
+        sInstance->populateUserList(credential);
         remember_check->setEnabled(remember_user);
     }
 }
@@ -580,16 +580,13 @@ void LLPanelLogin::resetFields()
     }
     else
     {
-        LLUICtrl* remember_check = sInstance->getChild<LLUICtrl>("remember_check");
-        bool remember_psswrd = remember_check->getValue();
         LLPointer<LLCredential> cred = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid());
-        sInstance->populateUserList(cred, remember_psswrd);
+        sInstance->populateUserList(cred);
     }
 }
 
 // static
-void LLPanelLogin::setFields(LLPointer<LLCredential> credential,
-							 bool remember_psswrd)
+void LLPanelLogin::setFields(LLPointer<LLCredential> credential)
 {
 	if (!sInstance)
 	{
@@ -631,7 +628,7 @@ void LLPanelLogin::setFields(LLPointer<LLCredential> credential,
 	LL_INFOS("Credentials") << "Setting authenticator field " << authenticator["type"].asString() << LL_ENDL;
 	if(authenticator.isMap() && 
 	   authenticator.has("secret") && 
-	   (authenticator["secret"].asString().size() > 0) && remember_psswrd)
+	   (authenticator["secret"].asString().size() > 0))
 	{
 		
 		// This is a MD5 hex digest of a password.
@@ -752,7 +749,7 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential,
     }
     else
     {
-        remember_user = true;
+        remember_user = remember_psswrd; // on panel_login_first "remember_check" is named as 'remember me'
     }
 }
 
@@ -1096,8 +1093,7 @@ void LLPanelLogin::onUserListCommit(void*)
         {
             std::string user_key = username_combo->getSelectedValue();
             LLPointer<LLCredential> cred = gSecAPIHandler->loadFromCredentialMap("login_list", LLGridManager::getInstance()->getGrid(), user_key);
-            bool remember_psswrd = sInstance->getChild<LLUICtrl>("remember_check")->getValue();
-            setFields(cred, remember_psswrd);
+            setFields(cred);
             sInstance->mPasswordModified = false;
         }
         else
@@ -1156,10 +1152,9 @@ void LLPanelLogin::updateServer()
 			if(!sInstance->areCredentialFieldsDirty())
 			{
 				// populate dropbox and setFields
-				bool remember_psswrd = sInstance->getChild<LLUICtrl>("remember_check")->getValue();
 				// Note: following call is related to initializeLoginInfo()
 				LLPointer<LLCredential> credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid());
-				sInstance->populateUserList(credential, remember_psswrd);
+				sInstance->populateUserList(credential);
 			}
 
 			// update the login panel links 
@@ -1198,7 +1193,7 @@ void LLPanelLogin::updateLoginButtons()
     }
 }
 
-void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential, bool remember_psswrd)
+void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential)
 {
     LLComboBox* user_combo = getChild<LLComboBox>("username_combo");
     user_combo->removeall();
@@ -1228,15 +1223,19 @@ void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential, bool rem
         }
         else
         {
-            setFields(credential, remember_psswrd);
+            setFields(credential);
         }
     }
     else
     {
         if (credential.notNull())
         {
-            user_combo->add(LLPanelLogin::getUserName(credential), credential->userID(), ADD_BOTTOM, TRUE);
-            setFields(credential, remember_psswrd);
+            const LLSD &ident = credential->getIdentifier();
+            if (ident.isMap() && ident.has("type"))
+            {
+                user_combo->add(LLPanelLogin::getUserName(credential), credential->userID(), ADD_BOTTOM, TRUE);
+                setFields(credential);
+            }
         }
     }
 }
diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h
index 3eb7b68949f1ed9b3d6a37c9d3454971231185b3..c9b8e1b6fcfdc4bc3ac2344f5eb39e0df7fb9198 100644
--- a/indra/newview/llpanellogin.h
+++ b/indra/newview/llpanellogin.h
@@ -96,7 +96,7 @@ class LLPanelLogin:
 	void onSelectServer();
 	void onLocationSLURL();
 
-	static void setFields(LLPointer<LLCredential> credential, bool remember_psswrd);
+	static void setFields(LLPointer<LLCredential> credential);
 
 	static void onClickConnect(void*);
 	static void onClickNewAccount(void*);
@@ -113,7 +113,7 @@ class LLPanelLogin:
 	boost::scoped_ptr<LLPanelLoginListener> mListener;
 
 	void updateLoginButtons();
-	void populateUserList(LLPointer<LLCredential> credential, bool remember_psswrd);
+	void populateUserList(LLPointer<LLCredential> credential);
 
 	void			(*mCallback)(S32 option, void *userdata);
 	void*			mCallbackData;
diff --git a/indra/newview/llpanelmediasettingsgeneral.cpp b/indra/newview/llpanelmediasettingsgeneral.cpp
index 352218984230d669a9e940e2156067efd4550084..9730f0f16d9df5f95b5a4815eb8ee42efaf28a5a 100644
--- a/indra/newview/llpanelmediasettingsgeneral.cpp
+++ b/indra/newview/llpanelmediasettingsgeneral.cpp
@@ -457,7 +457,7 @@ bool LLPanelMediaSettingsGeneral::navigateHomeSelectedFace(bool only_if_current_
 					if (!only_if_current_is_empty || (media_data->getCurrentURL().empty() && media_data->getAutoPlay()))
 					{
 						viewer_media_t media_impl =
-							LLViewerMedia::getMediaImplFromTextureID(object->getTE(face)->getMediaData()->getMediaID());
+							LLViewerMedia::getInstance()->getMediaImplFromTextureID(object->getTE(face)->getMediaData()->getMediaID());
 						if(media_impl)
 						{
 							media_impl->navigateHome();
diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp
index af28ff8e612049cab5367cf5b8916eb6fbb50a6d..b654e928e2effb2ae4cd04f0c10a71d648bab450 100644
--- a/indra/newview/llpanelnearbymedia.cpp
+++ b/indra/newview/llpanelnearbymedia.cpp
@@ -554,9 +554,10 @@ void LLPanelNearByMedia::refreshParcelItems()
 	// Only show "special parcel items" if "All" or "Within" filter
 	// (and if media is "enabled")
 	bool should_include = (choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL);
-	
+	LLViewerMedia* media_inst = LLViewerMedia::getInstance();
+
 	// First Parcel Media: add or remove it as necessary
-	if (gSavedSettings.getBOOL("AudioStreamingMedia") &&should_include && LLViewerMedia::hasParcelMedia())
+	if (gSavedSettings.getBOOL("AudioStreamingMedia") && should_include && media_inst->hasParcelMedia())
 	{
 		// Yes, there is parcel media.
 		if (NULL == mParcelMediaItem)
@@ -577,7 +578,7 @@ void LLPanelNearByMedia::refreshParcelItems()
 	if (NULL != mParcelMediaItem)
 	{
 		std::string name, url, tooltip;
-		getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, "");
+		getNameAndUrlHelper(LLViewerParcelMedia::getInstance()->getParcelMedia(), name, url, "");
 		if (name.empty() || name == url)
 		{
 			tooltip = url;
@@ -586,20 +587,20 @@ void LLPanelNearByMedia::refreshParcelItems()
 		{
 			tooltip = name + " : " + url;
 		}
-		LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia();
+		LLViewerMediaImpl *impl = LLViewerParcelMedia::getInstance()->getParcelMedia();
 		updateListItem(mParcelMediaItem,
 					   mParcelMediaName,
 					   tooltip,
 					   -2, // Proximity closer than anything else, before Parcel Audio
 					   impl == NULL || impl->isMediaDisabled(),
-					   impl != NULL && !LLViewerParcelMedia::getURL().empty(),
+					   impl != NULL && !LLViewerParcelMedia::getInstance()->getURL().empty(),
 					   impl != NULL && impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
 					   MEDIA_CLASS_ALL,
 					   "parcel media");
 	}
 	
 	// Next Parcel Audio: add or remove it as necessary (don't show if disabled in prefs)
-	if (should_include && LLViewerMedia::hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic"))
+	if (should_include && media_inst->hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic"))
 	{
 		// Yes, there is parcel audio.
 		if (NULL == mParcelAudioItem)
@@ -619,10 +620,10 @@ void LLPanelNearByMedia::refreshParcelItems()
 	// ... then update it
 	if (NULL != mParcelAudioItem)
 	{
-		bool is_playing = LLViewerMedia::isParcelAudioPlaying();
+		bool is_playing = media_inst->isParcelAudioPlaying();
 	
 		std::string url;
-        url = LLViewerMedia::getParcelAudioURL();
+		url = media_inst->getParcelAudioURL();
 
 		updateListItem(mParcelAudioItem,
 					   mParcelAudioName,
@@ -664,7 +665,8 @@ void LLPanelNearByMedia::refreshList()
 	refreshParcelItems();
 	
 	// Get the canonical list from LLViewerMedia
-	LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList();
+	LLViewerMedia* media_inst = LLViewerMedia::getInstance();
+	LLViewerMedia::impl_list impls = media_inst->getPriorityList();
 	LLViewerMedia::impl_list::iterator priority_iter;
 	
 	U32 enabled_count = 0;
@@ -717,17 +719,17 @@ void LLPanelNearByMedia::refreshList()
 	}	
 	mDisableAllCtrl->setEnabled((gSavedSettings.getBOOL("AudioStreamingMusic") || 
 		                         gSavedSettings.getBOOL("AudioStreamingMedia")) &&
-								(LLViewerMedia::isAnyMediaShowing() || 
-								 LLViewerMedia::isParcelMediaPlaying() ||
-								 LLViewerMedia::isParcelAudioPlaying()));
+								(media_inst->isAnyMediaShowing() || 
+								 media_inst->isParcelMediaPlaying() ||
+								 media_inst->isParcelAudioPlaying()));
 
 	mEnableAllCtrl->setEnabled( (gSavedSettings.getBOOL("AudioStreamingMusic") ||
 								gSavedSettings.getBOOL("AudioStreamingMedia")) &&
 							   (disabled_count > 0 ||
 								// parcel media (if we have it, and it isn't playing, enable "start")
-								(LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) ||
+								(media_inst->hasParcelMedia() && ! media_inst->isParcelMediaPlaying()) ||
 								// parcel audio (if we have it, and it isn't playing, enable "start")
-								(LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying())));
+								(media_inst->hasParcelAudio() && ! media_inst->isParcelAudioPlaying())));
 
 	// Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away.
 	std::vector<LLScrollListItem*> items = mMediaList->getAllData();
@@ -742,7 +744,7 @@ void LLPanelNearByMedia::refreshList()
 		if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID &&
 			row_id != PARCEL_AUDIO_LIST_ITEM_UUID)
 		{
-			LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
+			LLViewerMediaImpl* impl = media_inst->getMediaImplFromTextureID(row_id);
 			if(impl)
 			{
 				updateListItem(item, impl);
@@ -787,26 +789,26 @@ void LLPanelNearByMedia::updateColumns()
 
 void LLPanelNearByMedia::onClickEnableAll()
 {
-	LLViewerMedia::setAllMediaEnabled(true);
+	LLViewerMedia::getInstance()->setAllMediaEnabled(true);
 }
 
 void LLPanelNearByMedia::onClickDisableAll()
 {
-	LLViewerMedia::setAllMediaEnabled(false);
+	LLViewerMedia::getInstance()->setAllMediaEnabled(false);
 }
 
 void LLPanelNearByMedia::onClickEnableParcelMedia()
 {	
-	if ( ! LLViewerMedia::isParcelMediaPlaying() )
+	if ( ! LLViewerMedia::getInstance()->isParcelMediaPlaying() )
 	{
-		LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
+		LLViewerParcelMedia::getInstance()->play(LLViewerParcelMgr::getInstance()->getAgentParcel());
 	}
 }
 
 void LLPanelNearByMedia::onClickDisableParcelMedia()
 {	
 	// This actually unloads the impl, as opposed to "stop"ping the media
-	LLViewerParcelMedia::stop();
+	LLViewerParcelMedia::getInstance()->stop();
 }
 
 void LLPanelNearByMedia::onCheckItem(LLUICtrl* ctrl, const LLUUID &row_id)
@@ -843,7 +845,7 @@ bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled)
 		return true;
 	}
 	else {
-		LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
+		LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(row_id);
 		if(impl)
 		{
 			impl->setDisabled(disabled, true);
@@ -864,22 +866,22 @@ void LLPanelNearByMedia::onZoomMedia(void* user_data)
 
 void LLPanelNearByMedia::onClickParcelMediaPlay()
 {
-	LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
+	LLViewerParcelMedia::getInstance()->play(LLViewerParcelMgr::getInstance()->getAgentParcel());
 }
 
 void LLPanelNearByMedia::onClickParcelMediaStop()
 {	
-	if (LLViewerParcelMedia::getParcelMedia())
+	if (LLViewerParcelMedia::getInstance()->getParcelMedia())
 	{
 		// This stops the media playing, as opposed to unloading it like
 		// LLViewerParcelMedia::stop() does
-		LLViewerParcelMedia::getParcelMedia()->stop();
+		LLViewerParcelMedia::getInstance()->getParcelMedia()->stop();
 	}
 }
 
 void LLPanelNearByMedia::onClickParcelMediaPause()
 {
-	LLViewerParcelMedia::pause();
+	LLViewerParcelMedia::getInstance()->pause();
 }
 
 void LLPanelNearByMedia::onClickParcelAudioPlay()
@@ -900,7 +902,7 @@ void LLPanelNearByMedia::onClickParcelAudioPlay()
 	}
 	else
 	{
-		LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getParcelAudioURL());
+		LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getInstance()->getParcelAudioURL());
 	}
 }
 
@@ -992,16 +994,17 @@ void LLPanelNearByMedia::onMoreLess()
 void LLPanelNearByMedia::updateControls()
 {
 	LLUUID selected_media_id = mMediaList->getValue().asUUID();
+	LLViewerMedia* media_inst = LLViewerMedia::getInstance();
 	
 	if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
 	{
-		if (!LLViewerMedia::hasParcelAudio() || !gSavedSettings.getBOOL("AudioStreamingMusic"))
+		if (!media_inst->getInstance()->hasParcelAudio() || !gSavedSettings.getBOOL("AudioStreamingMusic"))
 		{
 			// disable controls if audio streaming music is disabled from preference
 			showDisabledControls();
 		}
 		else {
-			showTimeBasedControls(LLViewerMedia::isParcelAudioPlaying(),
+			showTimeBasedControls(media_inst->isParcelAudioPlaying(),
 							  false, // include_zoom
 							  false, // is_zoomed
 							  gSavedSettings.getBOOL("MuteMusic"), 
@@ -1010,13 +1013,13 @@ void LLPanelNearByMedia::updateControls()
 	}
 	else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID)
 	{
-		if (!LLViewerMedia::hasParcelMedia() || !gSavedSettings.getBOOL("AudioStreamingMedia"))
+		if (!media_inst->hasParcelMedia() || !gSavedSettings.getBOOL("AudioStreamingMedia"))
 		{
 			// disable controls if audio streaming media is disabled from preference
 			showDisabledControls();
 		}
 		else {
-			LLViewerMediaImpl* impl = LLViewerParcelMedia::getParcelMedia();
+			LLViewerMediaImpl* impl = LLViewerParcelMedia::getInstance()->getParcelMedia();
 			if (NULL == impl)
 			{
 				// Just means it hasn't started yet
@@ -1032,7 +1035,7 @@ void LLPanelNearByMedia::updateControls()
 			}
 			else {
 				// non-time-based parcel media
-				showBasicControls(LLViewerMedia::isParcelMediaPlaying(), 
+				showBasicControls(media_inst->isParcelMediaPlaying(), 
 							      false, 
 								  false, 
 								  impl->getVolume() == 0.0, 
@@ -1041,7 +1044,7 @@ void LLPanelNearByMedia::updateControls()
 		}
 	}
 	else {
-		LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
+		LLViewerMediaImpl* impl = media_inst->getMediaImplFromTextureID(selected_media_id);
 		
 		if (NULL == impl || !gSavedSettings.getBOOL("AudioStreamingMedia"))
 		{
@@ -1127,7 +1130,7 @@ void LLPanelNearByMedia::onClickSelectedMediaPlay()
 	if (selected_media_id != PARCEL_AUDIO_LIST_ITEM_UUID)
 	{
 		LLViewerMediaImpl *impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ?
-			((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
+			((LLViewerMediaImpl*)LLViewerParcelMedia::getInstance()->getParcelMedia()) : LLViewerMedia::getInstance()->getMediaImplFromTextureID(selected_media_id);
 		if (NULL != impl)
 		{
 			if (impl->isMediaTimeBased() && impl->isMediaPaused())
@@ -1138,7 +1141,7 @@ void LLPanelNearByMedia::onClickSelectedMediaPlay()
 			}
 			else if (impl->isParcelMedia())
 			{
-				LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
+				LLViewerParcelMedia::getInstance()->play(LLViewerParcelMgr::getInstance()->getAgentParcel());
 			}
 		}
 	}	
@@ -1156,7 +1159,7 @@ void LLPanelNearByMedia::onClickSelectedMediaPause()
 		onClickParcelMediaPause();
 	}
 	else {
-		LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
+		LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(selected_media_id);
 		if (NULL != impl && impl->isMediaTimeBased() && impl->isMediaPlaying())
 		{
 			impl->pause();
@@ -1173,7 +1176,7 @@ void LLPanelNearByMedia::onClickSelectedMediaMute()
 	}
 	else {
 		LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ?
-			((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
+			((LLViewerMediaImpl*)LLViewerParcelMedia::getInstance()->getParcelMedia()) : LLViewerMedia::getInstance()->getMediaImplFromTextureID(selected_media_id);
 		if (NULL != impl)
 		{
 			F32 volume = impl->getVolume();
@@ -1204,7 +1207,7 @@ void LLPanelNearByMedia::onCommitSelectedMediaVolume()
 	}
 	else {
 		LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ?
-			((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
+			((LLViewerMediaImpl*)LLViewerParcelMedia::getInstance()->getParcelMedia()) : LLViewerMedia::getInstance()->getMediaImplFromTextureID(selected_media_id);
 		if (NULL != impl)
 		{
 			impl->setVolume(mVolumeSlider->getValueF32());
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index 77bc99da832c181857448174524e8fae58f040bb..c39df3fe8bbe58a6ffd101afbe975fa883f29ef9 100644
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -84,7 +84,7 @@ class LLPickHandler : public LLCommandHandler,
 	bool handle(const LLSD& params, const LLSD& query_map,
 		LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnablePicks"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnablePicks"))
 		{
 			LLNotificationsUtil::add("NoPicks", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
@@ -198,7 +198,7 @@ class LLClassifiedHandler :
 	
 	bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableClassifieds"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableClassifieds"))
 		{
 			LLNotificationsUtil::add("NoClassifieds", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index 25961e005427ad85bc53d1ee971d2bc4f10f28d4..2ef82d0cf907c0702a9370e51eb03498e07a1f99 100644
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -97,7 +97,7 @@ class LLParcelHandler : public LLCommandHandler
 			return false;
 		}
 
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnablePlaceProfile"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnablePlaceProfile"))
 		{
 			LLNotificationsUtil::add("NoPlaceInfo", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index c74c2e0fd8bf7abc7a2120c2e0a33453ae61d2cc..3c74aed734ccdd7864fa7dc55387b99e48a2d382 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -267,7 +267,7 @@ void LLPanelPrimMediaControls::focusOnTarget()
 
 LLViewerMediaImpl* LLPanelPrimMediaControls::getTargetMediaImpl()
 {
-	return LLViewerMedia::getMediaImplFromTextureID(mTargetImplID);
+	return LLViewerMedia::getInstance()->getMediaImplFromTextureID(mTargetImplID);
 }
 
 LLViewerObject* LLPanelPrimMediaControls::getTargetObject()
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index 8afa35efa0b4066ab1e10b58d8af234cf792106f..5f13b223fbbf097096a59ff12f4373a27dc1b094 100644
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -110,7 +110,7 @@ class LLAgentHandler : public LLCommandHandler
 
 		if (verb == "pay")
 		{
-			if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAvatarPay"))
+			if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableAvatarPay"))
 			{
 				LLNotificationsUtil::add("NoAvatarPay", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 				return true;
diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp
index 23747a8efdebb025ada0d9a20c7de5ea8962cd4a..1a3e9461275d8454a2042a55f32ab32189eccd88 100644
--- a/indra/newview/llpanelsnapshotoptions.cpp
+++ b/indra/newview/llpanelsnapshotoptions.cpp
@@ -32,8 +32,6 @@
 
 #include "llfloatersnapshot.h" // FIXME: create a snapshot model
 #include "llfloaterreg.h"
-#include "llfloaterflickr.h"
-#include "llfloatertwitter.h"
 
 /**
  * Provides several ways to save a snapshot.
@@ -58,8 +56,6 @@ class LLPanelSnapshotOptions
 	void onSaveToEmail();
 	void onSaveToInventory();
 	void onSaveToComputer();
-	void onSendToTwitter();
-	void onSendToFlickr();
 
 	LLFloaterSnapshotBase* mSnapshotFloater;
 };
@@ -72,8 +68,7 @@ LLPanelSnapshotOptions::LLPanelSnapshotOptions()
 	mCommitCallbackRegistrar.add("Snapshot.SaveToEmail",		boost::bind(&LLPanelSnapshotOptions::onSaveToEmail,		this));
 	mCommitCallbackRegistrar.add("Snapshot.SaveToInventory",	boost::bind(&LLPanelSnapshotOptions::onSaveToInventory,	this));
 	mCommitCallbackRegistrar.add("Snapshot.SaveToComputer",		boost::bind(&LLPanelSnapshotOptions::onSaveToComputer,	this));
-	mCommitCallbackRegistrar.add("Snapshot.SendToTwitter",		boost::bind(&LLPanelSnapshotOptions::onSendToTwitter, this));
-	mCommitCallbackRegistrar.add("Snapshot.SendToFlickr",		boost::bind(&LLPanelSnapshotOptions::onSendToFlickr, this));
+
 	LLGlobalEconomy::getInstance()->addObserver(this);
 }
 
@@ -135,26 +130,3 @@ void LLPanelSnapshotOptions::onSaveToComputer()
 	openPanel("panel_snapshot_local");
 }
 
-void LLPanelSnapshotOptions::onSendToTwitter()
-{
-	LLFloaterReg::hideInstance("snapshot");
-
-	LLFloaterTwitter* twitter_floater = dynamic_cast<LLFloaterTwitter*>(LLFloaterReg::getInstance("twitter"));
-	if (twitter_floater)
-	{
-		twitter_floater->showPhotoPanel();
-	}
-	LLFloaterReg::showInstance("twitter");
-}
-
-void LLPanelSnapshotOptions::onSendToFlickr()
-{
-	LLFloaterReg::hideInstance("snapshot");
-
-	LLFloaterFlickr* flickr_floater = dynamic_cast<LLFloaterFlickr*>(LLFloaterReg::getInstance("flickr"));
-	if (flickr_floater)
-	{
-		flickr_floater->showPhotoPanel();
-	}
-	LLFloaterReg::showInstance("flickr");
-}
diff --git a/indra/newview/llpersistentnotificationstorage.cpp b/indra/newview/llpersistentnotificationstorage.cpp
index 264382ae8280be64506e877e961f2d57073d1ea3..f95ab9928d54737ca17b52b204568f2abdbbcc43 100644
--- a/indra/newview/llpersistentnotificationstorage.cpp
+++ b/indra/newview/llpersistentnotificationstorage.cpp
@@ -40,6 +40,7 @@ LLPersistentNotificationStorage::LLPersistentNotificationStorage():
 	  LLNotificationStorage("")
 	, mLoaded(false)
 {
+    initialize();
 }
 
 LLPersistentNotificationStorage::~LLPersistentNotificationStorage()
diff --git a/indra/newview/llpersistentnotificationstorage.h b/indra/newview/llpersistentnotificationstorage.h
index 40c9923c7412036cc0b26cf1cb5ab860e0cb4acc..1fb44872867d9c0b4e1c4801766297c1b463782d 100644
--- a/indra/newview/llpersistentnotificationstorage.h
+++ b/indra/newview/llpersistentnotificationstorage.h
@@ -43,7 +43,7 @@ class LLSD;
 // be a) serializable(implement LLNotificationResponderInterface),
 // b) registered with LLResponderRegistry (found in llpersistentnotificationstorage.cpp).
 
-class LLPersistentNotificationStorage : public LLSingleton<LLPersistentNotificationStorage>, public LLNotificationStorage
+class LLPersistentNotificationStorage : public LLParamSingleton<LLPersistentNotificationStorage>, public LLNotificationStorage
 {
 	LLSINGLETON(LLPersistentNotificationStorage);
 	~LLPersistentNotificationStorage();
@@ -53,11 +53,11 @@ class LLPersistentNotificationStorage : public LLSingleton<LLPersistentNotificat
 	void saveNotifications();
 	void loadNotifications();
 
-	void initialize();
-
 protected:
 
 private:
+	void initialize();
+
 	bool onPersistentChannelChanged(const LLSD& payload);
 	bool mLoaded;
 };
diff --git a/indra/newview/llpopupview.cpp b/indra/newview/llpopupview.cpp
index 153f0930c27ab5ee3b9af6545e9f8ce1fb4307ca..d1a9ca229fdcd067859ede6ccc876000bc323ed6 100644
--- a/indra/newview/llpopupview.cpp
+++ b/indra/newview/llpopupview.cpp
@@ -44,13 +44,13 @@ LLPopupView::LLPopupView(const LLPopupView::Params& p)
 : LLPanel(p)
 {
 	// register ourself as handler of UI popups
-	LLUI::setPopupFuncs(boost::bind(&LLPopupView::addPopup, this, _1), boost::bind(&LLPopupView::removePopup, this, _1), boost::bind(&LLPopupView::clearPopups, this));
+	LLUI::getInstance()->setPopupFuncs(boost::bind(&LLPopupView::addPopup, this, _1), boost::bind(&LLPopupView::removePopup, this, _1), boost::bind(&LLPopupView::clearPopups, this));
 }
 
 LLPopupView::~LLPopupView()
 {
 	// set empty callback function so we can't handle popups anymore
-	LLUI::setPopupFuncs(LLUI::add_popup_t(), LLUI::remove_popup_t(), LLUI::clear_popups_t());
+	LLUI::getInstance()->setPopupFuncs(LLUI::add_popup_t(), LLUI::remove_popup_t(), LLUI::clear_popups_t());
 }
 
 void LLPopupView::draw()
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index f1bb0bc27d011329cff83e7874a82ab2d1177021..d177384b5ac8c602b19d64e0b0c919d06aabac0f 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -885,7 +885,7 @@ bool LLScriptEdCore::handleSaveChangesDialog(const LLSD& notification, const LLS
 
 void LLScriptEdCore::onBtnHelp()
 {
-	LLUI::sHelpImpl->showTopic(HELP_LSL_PORTAL_TOPIC);
+	LLUI::getInstance()->mHelpImpl->showTopic(HELP_LSL_PORTAL_TOPIC);
 }
 
 void LLScriptEdCore::onBtnDynamicHelp()
diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp
index c17b86783d139ab1ded51ab9ee76e013f55a34e5..083a913ef8bb1479d0ad248d0a2209eebeb2f367 100644
--- a/indra/newview/llprogressview.cpp
+++ b/indra/newview/llprogressview.cpp
@@ -86,7 +86,7 @@ BOOL LLProgressView::postBuild()
 	mMediaCtrl->setVisible( false );		// hidden initially
 	mMediaCtrl->addObserver( this );		// watch events
 	
-	LLViewerMedia::setOnlyAudibleMediaTextureID(mMediaCtrl->getTextureID());
+	LLViewerMedia::getInstance()->setOnlyAudibleMediaTextureID(mMediaCtrl->getTextureID());
 
 	mCancelBtn = getChild<LLButton>("cancel_btn");
 	mCancelBtn->setClickedCallback(  LLProgressView::onCancelButtonClicked, NULL );
@@ -263,7 +263,7 @@ void LLProgressView::draw()
 		{
 			mFadeToWorldTimer.stop();
 
-			LLViewerMedia::setOnlyAudibleMediaTextureID(LLUUID::null);
+			LLViewerMedia::getInstance()->setOnlyAudibleMediaTextureID(LLUUID::null);
 
 			// Fade is complete, release focus
 			gFocusMgr.releaseFocusIfNeeded( this );
diff --git a/indra/newview/llsaveoutfitcombobtn.cpp b/indra/newview/llsaveoutfitcombobtn.cpp
index 32295cd96f29b3c5acf352b8accb1e571b4579fa..b1cb6d08d023d4b17dbd00b5c33f7f140bfb1503 100644
--- a/indra/newview/llsaveoutfitcombobtn.cpp
+++ b/indra/newview/llsaveoutfitcombobtn.cpp
@@ -56,7 +56,7 @@ LLSaveOutfitComboBtn::LLSaveOutfitComboBtn(LLPanel* parent, bool saveAsDefaultAc
 void LLSaveOutfitComboBtn::showSaveMenu()
 {
 	S32 x, y;
-	LLUI::getMousePositionLocal(mParent, &x, &y);
+	LLUI::getInstance()->getMousePositionLocal(mParent, &x, &y);
 
 	mSaveMenu->updateParent(LLMenuGL::sMenuContainer);
 	LLMenuGL::showPopup(mParent, mSaveMenu, x, y);
diff --git a/indra/newview/llshareavatarhandler.cpp b/indra/newview/llshareavatarhandler.cpp
index 6b4f1d3dc67859466c6f20cf82d1ad3c23bb293b..142e00c3f7e5203437cc1848cd51e5ccfd49edf7 100644
--- a/indra/newview/llshareavatarhandler.cpp
+++ b/indra/newview/llshareavatarhandler.cpp
@@ -40,7 +40,7 @@ class LLShareWithAvatarHandler : public LLCommandHandler
 	
 	bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableAvatarShare"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableAvatarShare"))
 		{
 			LLNotificationsUtil::add("NoAvatarShare", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index 4ebcffa55451b9841000ce26cacf10b591dc7d60..6e2b4a00fc036f299d15db7b5c7f76989d1fee0e 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -485,7 +485,7 @@ void LLSidepanelAppearance::fetchInventory()
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				LLViewerObject* attached_object = (*attachment_iter);
+				LLViewerObject* attached_object = attachment_iter->get();
 				if (!attached_object) continue;
 				const LLUUID& item_id = attached_object->getAttachmentItemID();
 				if (item_id.isNull()) continue;
diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp
index 0fa4c2b114fbc51a208d62f7a143ba0b0c932203..8e1f80abfc41a4c98ff6f4a73a40b9996279bcff 100644
--- a/indra/newview/llskinningutil.cpp
+++ b/indra/newview/llskinningutil.cpp
@@ -83,10 +83,6 @@ void dump_avatar_and_skin_state(const std::string& reason, LLVOAvatar *avatar, c
     }
 }
 
-void LLSkinningUtil::initClass()
-{
-}
-
 U32 LLSkinningUtil::getMaxJointCount()
 {
     U32 result = LL_MAX_JOINTS_PER_MESH_OBJECT;
diff --git a/indra/newview/llskinningutil.h b/indra/newview/llskinningutil.h
index ccc501adc0d7ca9958a8a82e1f1f2037e5ab920f..2c77e030aa525fd682020fffcc77ffbda0c912b2 100644
--- a/indra/newview/llskinningutil.h
+++ b/indra/newview/llskinningutil.h
@@ -34,7 +34,6 @@ class LLVolumeFace;
 
 namespace LLSkinningUtil
 {
-    void initClass();
     U32 getMaxJointCount();
     U32 getMeshJointCount(const LLMeshSkinInfo *skin);
     void scrubInvalidJoints(LLVOAvatar *avatar, LLMeshSkinInfo* skin);
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index 0bba495174cc39059668994e9bc37c4872b7ad31..b448caeb0b898ab2e12f426d75629963399868d1 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -34,8 +34,6 @@
 #include "lleconomy.h"
 #include "llfloaterperms.h"
 #include "llfloaterreg.h"
-#include "llfloaterflickr.h"
-#include "llfloatertwitter.h"
 #include "llimagefilter.h"
 #include "llimagefiltersmanager.h"
 #include "llimagebmp.h"
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 3771797929db32f4453052a1c0787bfc1dce5fdd..08012686f99c7795d2970976a3d523a35fcf5e2b 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -905,8 +905,13 @@ bool idle_startup()
 		LLFile::mkdir(gDirUtilp->getLindenUserDir());
 
 		// As soon as directories are ready initialize notification storages
-		LLPersistentNotificationStorage::getInstance()->initialize();
-		LLDoNotDisturbNotificationStorage::getInstance()->initialize();
+		if (!LLPersistentNotificationStorage::instanceExists())
+		{
+			// check existance since this part of code can be reached
+			// twice due to login failures
+			LLPersistentNotificationStorage::initParamSingleton();
+			LLDoNotDisturbNotificationStorage::initParamSingleton();
+		}
 
 		// Set PerAccountSettingsFile to the default value.
 		gSavedSettings.setString("PerAccountSettingsFile",
@@ -1239,8 +1244,6 @@ bool idle_startup()
 		LLSurface::initClasses();
 		display_startup();
 
-
-		LLFace::initClass();
 		display_startup();
 
 		LLDrawable::initClass();
@@ -1302,9 +1305,13 @@ bool idle_startup()
 		LLStartUp::initExperiences();
 
 		display_startup();
+
+		// If logging should be enebled, turns it on and loads history from disk
+		// Note: does not happen on init of singleton because preferences can use
+		// this instance without logging in
+		LLConversationLog::getInstance()->initLoggingState();
+
 		LLStartUp::setStartupState( STATE_MULTIMEDIA_INIT );
-		
-		LLConversationLog::getInstance();
 
 		return FALSE;
 	}
@@ -2878,9 +2885,6 @@ void LLStartUp::multimediaInit()
 	std::string msg = LLTrans::getString("LoginInitializingMultimedia");
 	set_startup_status(0.42f, msg.c_str(), gAgent.mMOTD.c_str());
 	display_startup();
-
-	// LLViewerMedia::initClass();
-	LLViewerParcelMedia::initClass();
 }
 
 void LLStartUp::fontInit()
@@ -2908,9 +2912,10 @@ void LLStartUp::initNameCache()
 
 	// Start cache in not-running state until we figure out if we have
 	// capabilities for display name lookup
-	LLAvatarNameCache::initClass(false,gSavedSettings.getBOOL("UsePeopleAPI"));
-	LLAvatarNameCache::setUseDisplayNames(gSavedSettings.getBOOL("UseDisplayNames"));
-	LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
+	LLAvatarNameCache* cache_inst = LLAvatarNameCache::getInstance();
+	cache_inst->setUsePeopleAPI(gSavedSettings.getBOOL("UsePeopleAPI"));
+	cache_inst->setUseDisplayNames(gSavedSettings.getBOOL("UseDisplayNames"));
+	cache_inst->setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
 }
 
 
@@ -2925,8 +2930,6 @@ void LLStartUp::initExperiences()
 
 void LLStartUp::cleanupNameCache()
 {
-	SUBSYSTEM_CLEANUP(LLAvatarNameCache);
-
 	delete gCacheName;
 	gCacheName = NULL;
 }
@@ -3615,7 +3618,7 @@ bool process_login_success_response()
 	if(!openid_url.empty())
 	{
 		std::string openid_token = response["openid_token"];
-		LLViewerMedia::openIDSetup(openid_url, openid_token);
+		LLViewerMedia::getInstance()->openIDSetup(openid_url, openid_token);
 	}
 
 	gMaxAgentGroups = DEFAULT_MAX_AGENT_GROUPS;
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index c4e09b6767a6e2132c2890a03017bc21c6565131..b8c227334da1ab21818d0fde9477abf3ead9c359 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -183,7 +183,7 @@ BOOL LLStatusBar::postBuild()
 	mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this );
 	mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this));
 
-	LLHints::registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle());
+	LLHints::getInstance()->registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle());
 
 	gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2));
 
@@ -318,16 +318,18 @@ void LLStatusBar::refresh()
 	// update the master volume button state
 	bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
 	mBtnVolume->setToggleState(mute_audio);
-	
+
+	LLViewerMedia* media_inst = LLViewerMedia::getInstance();
+
 	// Disable media toggle if there's no media, parcel media, and no parcel audio
 	// (or if media is disabled)
 	bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && 
-						  (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio());
+						  (media_inst->hasInWorldMedia() || media_inst->hasParcelMedia() || media_inst->hasParcelAudio());
 	mMediaToggle->setEnabled(button_enabled);
 	// Note the "sense" of the toggle is opposite whether media is playing or not
-	bool any_media_playing = (LLViewerMedia::isAnyMediaPlaying() || 
-							  LLViewerMedia::isParcelMediaPlaying() ||
-							  LLViewerMedia::isParcelAudioPlaying());
+	bool any_media_playing = (media_inst->isAnyMediaPlaying() || 
+							  media_inst->isParcelMediaPlaying() ||
+							  media_inst->isParcelAudioPlaying());
 	mMediaToggle->setValue(!any_media_playing);
 }
 
@@ -499,8 +501,8 @@ void LLStatusBar::onMouseEnterPresets()
 	mPanelPresetsPulldown->setShape(pulldown_rect);
 
 	// show the master presets pull-down
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelPresetsPulldown);
+	LLUI::getInstance()->clearPopups();
+	LLUI::getInstance()->addPopup(mPanelPresetsPulldown);
 	mPanelNearByMedia->setVisible(FALSE);
 	mPanelVolumePulldown->setVisible(FALSE);
 	mPanelPresetsPulldown->setVisible(TRUE);
@@ -523,8 +525,8 @@ void LLStatusBar::onMouseEnterVolume()
 
 
 	// show the master volume pull-down
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelVolumePulldown);
+	LLUI::getInstance()->clearPopups();
+	LLUI::getInstance()->addPopup(mPanelVolumePulldown);
 	mPanelPresetsPulldown->setVisible(FALSE);
 	mPanelNearByMedia->setVisible(FALSE);
 	mPanelVolumePulldown->setVisible(TRUE);
@@ -546,8 +548,8 @@ void LLStatusBar::onMouseEnterNearbyMedia()
 	
 	// show the master volume pull-down
 	mPanelNearByMedia->setShape(nearby_media_rect);
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelNearByMedia);
+	LLUI::getInstance()->clearPopups();
+	LLUI::getInstance()->addPopup(mPanelNearByMedia);
 
 	mPanelPresetsPulldown->setVisible(FALSE);
 	mPanelVolumePulldown->setVisible(FALSE);
@@ -576,7 +578,7 @@ void LLStatusBar::onClickMediaToggle(void* data)
 	LLStatusBar *status_bar = (LLStatusBar*)data;
 	// "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media
 	bool pause = status_bar->mMediaToggle->getValue();
-	LLViewerMedia::setAllMediaPaused(pause);
+	LLViewerMedia::getInstance()->setAllMediaPaused(pause);
 }
 
 BOOL can_afford_transaction(S32 cost)
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index f3bb5741914dc6260a3a520e64832d75c9c03291..e2deb7ce1d39c11919beb991b6f850ea38692cc4 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -838,6 +838,7 @@ LLTextureCache::LLTextureCache(bool threaded)
 	  mFastCachePoolp(NULL),
 	  mFastCachePadBuffer(NULL)
 {
+    mHeaderAPRFilePoolp = new LLVolatileAPRPool(); // is_local = true, because this pool is for headers, headers are under own mutex
 }
 
 LLTextureCache::~LLTextureCache()
@@ -846,6 +847,7 @@ LLTextureCache::~LLTextureCache()
 	writeUpdatedEntries() ;
 	delete mFastCachep;
 	delete mFastCachePoolp;
+	delete mHeaderAPRFilePoolp;
 	ll_aligned_free_16(mFastCachePadBuffer);
 }
 
@@ -1014,10 +1016,11 @@ void LLTextureCache::purgeCache(ELLPath location, bool remove_dir)
 		if(LLFile::isdir(mTexturesDirName))
 		{
 			std::string file_name = gDirUtilp->getExpandedFilename(location, entries_filename);
-			LLAPRFile::remove(file_name, getLocalAPRFilePool());
+			// mHeaderAPRFilePoolp because we are under header mutex, and can be in main thread
+			LLAPRFile::remove(file_name, mHeaderAPRFilePoolp);
 
 			file_name = gDirUtilp->getExpandedFilename(location, cache_filename);
-			LLAPRFile::remove(file_name, getLocalAPRFilePool());
+			LLAPRFile::remove(file_name, mHeaderAPRFilePoolp);
 
 			purgeAllTextures(true);
 		}
@@ -1094,7 +1097,7 @@ LLAPRFile* LLTextureCache::openHeaderEntriesFile(bool readonly, S32 offset)
 {
 	llassert_always(mHeaderAPRFile == NULL);
 	apr_int32_t flags = readonly ? APR_READ|APR_BINARY : APR_READ|APR_WRITE|APR_BINARY;
-	mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, getLocalAPRFilePool());
+	mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, mHeaderAPRFilePoolp);
 	if(offset > 0)
 	{
 		mHeaderAPRFile->seek(APR_SET, offset);
@@ -1117,10 +1120,10 @@ void LLTextureCache::readEntriesHeader()
 {
 	// mHeaderEntriesInfo initializes to default values so safe not to read it
 	llassert_always(mHeaderAPRFile == NULL);
-	if (LLAPRFile::isExist(mHeaderEntriesFileName, getLocalAPRFilePool()))
+	if (LLAPRFile::isExist(mHeaderEntriesFileName, mHeaderAPRFilePoolp))
 	{
 		LLAPRFile::readEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo),
-						  getLocalAPRFilePool());
+						  mHeaderAPRFilePoolp);
 	}
 	else //create an empty entries header.
 	{
@@ -1152,7 +1155,7 @@ void LLTextureCache::writeEntriesHeader()
 	if (!mReadOnly)
 	{
 		LLAPRFile::writeEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo),
-						   getLocalAPRFilePool());
+						   mHeaderAPRFilePoolp);
 	}
 }
 
@@ -1832,7 +1835,8 @@ void LLTextureCache::purgeTextures(bool validate)
 			if (uuididx == validate_idx)
 			{
  				LL_DEBUGS("TextureCache") << "Validating: " << filename << "Size: " << entries[idx].mBodySize << LL_ENDL;
-				S32 bodysize = LLAPRFile::size(filename, getLocalAPRFilePool());
+				// mHeaderAPRFilePoolp because this is under header mutex in main thread
+				S32 bodysize = LLAPRFile::size(filename, mHeaderAPRFilePoolp);
 				if (bodysize != entries[idx].mBodySize)
 				{
 					LL_WARNS("TextureCache") << "TEXTURE CACHE BODY HAS BAD SIZE: " << bodysize << " != " << entries[idx].mBodySize
@@ -2231,7 +2235,7 @@ void LLTextureCache::openFastCache(bool first_time)
 			{
 				mFastCachePadBuffer = (U8*)ll_aligned_malloc_16(TEXTURE_FAST_CACHE_ENTRY_SIZE);
 			}
-			mFastCachePoolp = new LLVolatileAPRPool();
+			mFastCachePoolp = new LLVolatileAPRPool(); // is_local= true by default, so not thread safe by default
 			if (LLAPRFile::isExist(mFastCacheFileName, mFastCachePoolp))
 			{
 				mFastCachep = new LLAPRFile(mFastCacheFileName, APR_READ|APR_WRITE|APR_BINARY, mFastCachePoolp) ;				
@@ -2315,7 +2319,9 @@ void LLTextureCache::removeCachedTexture(const LLUUID& id)
 		mTexturesSizeMap.erase(id);
 	}
 	mHeaderIDMap.erase(id);
-	LLAPRFile::remove(getTextureFileName(id), getLocalAPRFilePool());		
+	// We are inside header's mutex so mHeaderAPRFilePoolp is safe to use,
+	// but getLocalAPRFilePool() is not safe, it might be in use by worker
+	LLAPRFile::remove(getTextureFileName(id), mHeaderAPRFilePoolp);
 }
 
 //called after mHeaderMutex is locked.
@@ -2327,7 +2333,10 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
 	{
 		if (entry.mBodySize == 0)	// Always attempt to remove when mBodySize > 0.
 		{
-		  if (LLAPRFile::isExist(filename, getLocalAPRFilePool()))		// Sanity check. Shouldn't exist when body size is 0.
+		  // Sanity check. Shouldn't exist when body size is 0.
+		  // We are inside header's mutex so mHeaderAPRFilePoolp is safe to use,
+		  // but getLocalAPRFilePool() is not safe, it might be in use by worker
+		  if (LLAPRFile::isExist(filename, mHeaderAPRFilePoolp))
 		  {
 			  LL_WARNS("TextureCache") << "Entry has body size of zero but file " << filename << " exists. Deleting this file, too." << LL_ENDL;
 		  }
@@ -2347,7 +2356,7 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
 
 	if (file_maybe_exists)
 	{
-		LLAPRFile::remove(filename, getLocalAPRFilePool());		
+		LLAPRFile::remove(filename, mHeaderAPRFilePoolp);		
 	}
 }
 
diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h
index da59290930d34f3f7c2cae53eb9ddbd67c359ac7..6046f2b9df1808e4f0cfa53525f102fb78e330c1 100644
--- a/indra/newview/lltexturecache.h
+++ b/indra/newview/lltexturecache.h
@@ -139,7 +139,7 @@ class LLTextureCache : public LLWorkerThread
 	U32 getEntries() { return mHeaderEntriesInfo.mEntries; }
 	U32 getMaxEntries() { return sCacheMaxEntries; };
 	BOOL isInCache(const LLUUID& id) ;
-	BOOL isInLocal(const LLUUID& id) ;
+	BOOL isInLocal(const LLUUID& id) ; //not thread safe at the moment
 
 protected:
 	// Accessed by LLTextureCacheWorker
@@ -190,6 +190,11 @@ class LLTextureCache : public LLWorkerThread
 	LLMutex mFastCacheMutex;
 	LLAPRFile* mHeaderAPRFile;
 	LLVolatileAPRPool* mFastCachePoolp;
+
+	// mLocalAPRFilePoolp is not thread safe and is meant only for workers
+	// howhever mHeaderEntriesFileName is accessed not from workers' threads
+	// so it needs own pool (not thread safe by itself, relies onto header's mutex)
+	LLVolatileAPRPool*   mHeaderAPRFilePoolp;
 	
 	typedef std::map<handle_t, LLTextureCacheWorker*> handle_map_t;
 	handle_map_t mReaders;
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 8a2fc881a94c05240624266ccfbbb7071df2a7e1..e2bb904eff0ffdd003fad4596ee8e94cfde648ec 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -410,7 +410,7 @@ BOOL LLFloaterTexturePicker::postBuild()
 
 	mLocalScrollCtrl = getChild<LLScrollListCtrl>("l_name_list");
 	mLocalScrollCtrl->setCommitCallback(onLocalScrollCommit, this);
-	LLLocalBitmapMgr::feedScrollList(mLocalScrollCtrl);
+	LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl);
 
 	mNoCopyTextureSelected = FALSE;
 
@@ -743,7 +743,7 @@ void LLFloaterTexturePicker::onBtnSelect(void* userdata)
 		if (self->mLocalScrollCtrl->getVisible() && !self->mLocalScrollCtrl->getAllSelected().empty())
 		{
 			LLUUID temp_id = self->mLocalScrollCtrl->getFirstSelected()->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID();
-			local_id = LLLocalBitmapMgr::getWorldID(temp_id);
+			local_id = LLLocalBitmapMgr::getInstance()->getWorldID(temp_id);
 		}
 	}
 	
@@ -890,10 +890,10 @@ void LLFloaterTexturePicker::onModeSelect(LLUICtrl* ctrl, void *userdata)
 // static
 void LLFloaterTexturePicker::onBtnAdd(void* userdata)
 {
-	if (LLLocalBitmapMgr::addUnit() == true)
+	if (LLLocalBitmapMgr::getInstance()->addUnit() == true)
 	{
 		LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
-		LLLocalBitmapMgr::feedScrollList(self->mLocalScrollCtrl);
+		LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl);
 	}
 }
 
@@ -912,13 +912,13 @@ void LLFloaterTexturePicker::onBtnRemove(void* userdata)
 			if (list_item)
 			{
 				LLUUID tracking_id = list_item->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID();
-				LLLocalBitmapMgr::delUnit(tracking_id);
+				LLLocalBitmapMgr::getInstance()->delUnit(tracking_id);
 			}
 		}
 
 		self->getChild<LLButton>("l_rem_btn")->setEnabled(false);
 		self->getChild<LLButton>("l_upl_btn")->setEnabled(false);
-		LLLocalBitmapMgr::feedScrollList(self->mLocalScrollCtrl);
+		LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl);
 	}
 
 }
@@ -938,7 +938,7 @@ void LLFloaterTexturePicker::onBtnUpload(void* userdata)
 	   in the future, it might be a good idea to check the vector size and if more than one units is selected - opt for multi-image upload. */
 	
 	LLUUID tracking_id = (LLUUID)self->mLocalScrollCtrl->getSelectedItemLabel(LOCAL_TRACKING_ID_COLUMN);
-	std::string filename = LLLocalBitmapMgr::getFilename(tracking_id);
+	std::string filename = LLLocalBitmapMgr::getInstance()->getFilename(tracking_id);
 
 	if (!filename.empty())
 	{
@@ -961,7 +961,7 @@ void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata)
 	if (has_selection)
 	{
 		LLUUID tracking_id = (LLUUID)self->mLocalScrollCtrl->getSelectedItemLabel(LOCAL_TRACKING_ID_COLUMN); 
-		LLUUID inworld_id = LLLocalBitmapMgr::getWorldID(tracking_id);
+		LLUUID inworld_id = LLLocalBitmapMgr::getInstance()->getWorldID(tracking_id);
 		if (self->mSetImageAssetIDCallback)
 		{
 			self->mSetImageAssetIDCallback(inworld_id);
diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp
index b9b05966bc9e1ced2babfa6b987963271002c2c9..870e0d94f0c03518b6dda3e5924ea5382afe378a 100644
--- a/indra/newview/lltoast.cpp
+++ b/indra/newview/lltoast.cpp
@@ -430,7 +430,7 @@ void LLToast::setVisible(BOOL show)
 void LLToast::updateHoveredState()
 {
 	S32 x, y;
-	LLUI::getMousePositionScreen(&x, &y);
+	LLUI::getInstance()->getMousePositionScreen(&x, &y);
 
 	LLRect panel_rc = mWrapperPanel->calcScreenRect();
 	LLRect button_rc;
diff --git a/indra/newview/lltoastalertpanel.cpp b/indra/newview/lltoastalertpanel.cpp
index 8df83c64cd5eeb057c80c619c3732a0921abb1ae..f882fd31ee9439196bde7231e95c39b22b83cfa5 100644
--- a/indra/newview/lltoastalertpanel.cpp
+++ b/indra/newview/lltoastalertpanel.cpp
@@ -44,6 +44,7 @@
 #include "llrootview.h"
 #include "lltransientfloatermgr.h"
 #include "llviewercontrol.h" // for gSavedSettings
+#include "llweb.h"
 
 #include <boost/algorithm/string.hpp>
 
@@ -51,7 +52,6 @@ const S32 MAX_ALLOWED_MSG_WIDTH = 400;
 const F32 DEFAULT_BUTTON_DELAY = 0.5f;
 
 /*static*/ LLControlGroup* LLToastAlertPanel::sSettings = NULL;
-/*static*/ LLToastAlertPanel::URLLoader* LLToastAlertPanel::sURLLoader;
 
 //-----------------------------------------------------------------------------
 // Private methods
@@ -500,9 +500,16 @@ void LLToastAlertPanel::onButtonPressed( const LLSD& data, S32 button )
 	response[button_data->mButton->getName()] = true;
 
 	// If we declared a URL and chose the URL option, go to the url
-	if (!button_data->mURL.empty() && sURLLoader != NULL)
+	if (!button_data->mURL.empty())
 	{
-		sURLLoader->load(button_data->mURL, button_data->mURLExternal);
+		if (button_data->mURLExternal)
+		{
+			LLWeb::loadURLExternal(button_data->mURL);
+		}
+		else
+		{
+			LLWeb::loadURL(button_data->mURL);
+		}
 	}
 
 	mNotification->respond(response); // new notification reponse
diff --git a/indra/newview/lltoastalertpanel.h b/indra/newview/lltoastalertpanel.h
index 21310822c46e0242ac49c683a1a5961c400959a1..9b4e054bf13656618d40d188e50e386bc2e92ffb 100644
--- a/indra/newview/lltoastalertpanel.h
+++ b/indra/newview/lltoastalertpanel.h
@@ -52,20 +52,6 @@ class LLToastAlertPanel
 public:
 	typedef bool (*display_callback_t)(S32 modal);
 
-	class URLLoader
-	{
-	public:
-		virtual void load(const std::string& url, bool force_open_externally = 0) = 0;
-		virtual ~URLLoader()
-		{
-		}
-	};
-
-	static void setURLLoader(URLLoader* loader)
-	{
-		sURLLoader = loader;
-	}
-	
 public:
 	// User's responsibility to call show() after creating these.
 	LLToastAlertPanel( LLNotificationPtr notep, bool is_modal );
@@ -92,7 +78,6 @@ class LLToastAlertPanel
 	BOOL hasTitleBar() const;
 
 private:
-	static URLLoader* sURLLoader;
 	static LLControlGroup* sSettings;
 
 	struct ButtonData
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp
index 596951fdfb41d50053cbb0a9883c12fb247908e8..07f46c5fbe07e08669b25992412af8ab4d970162 100644
--- a/indra/newview/lltoolfocus.cpp
+++ b/indra/newview/lltoolfocus.cpp
@@ -293,12 +293,12 @@ BOOL LLToolCamera::handleMouseUp(S32 x, S32 y, MASK mask)
 				BOOL success = LLViewerCamera::getInstance()->projectPosAgentToScreen(focus_pos, mouse_pos);
 				if (success)
 				{
-					LLUI::setMousePositionScreen(mouse_pos.mX, mouse_pos.mY);
+					LLUI::getInstance()->setMousePositionScreen(mouse_pos.mX, mouse_pos.mY);
 				}
 			}
 			else if (mMouseSteering)
 			{
-				LLUI::setMousePositionScreen(mMouseDownX, mMouseDownY);
+				LLUI::getInstance()->setMousePositionScreen(mMouseDownX, mMouseDownY);
 			}
 			else
 			{
@@ -308,7 +308,7 @@ BOOL LLToolCamera::handleMouseUp(S32 x, S32 y, MASK mask)
 		else
 		{
 			// not a valid zoomable object
-			LLUI::setMousePositionScreen(mMouseDownX, mMouseDownY);
+			LLUI::getInstance()->setMousePositionScreen(mMouseDownX, mMouseDownY);
 		}
 
 		// calls releaseMouse() internally
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index 429664e743ed95dc32c53406c5a1b198bf1d622e..a4806ceaf64df5834687b2bbbe401f9778b62d86 100644
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -1006,7 +1006,7 @@ void LLToolGrabBase::onMouseCaptureLost()
 			// ...move cursor "naturally", as if it had moved when hidden
 			S32 x = mGrabPick.mMousePt.mX + mAccumDeltaX;
 			S32 y = mGrabPick.mMousePt.mY + mAccumDeltaY;
-			LLUI::setMousePositionScreen(x, y);
+			LLUI::getInstance()->setMousePositionScreen(x, y);
 		}
 		else if (mHasMoved)
 		{
@@ -1016,13 +1016,13 @@ void LLToolGrabBase::onMouseCaptureLost()
 			LLCoordGL gl_point;
 			if (LLViewerCamera::getInstance()->projectPosAgentToScreen(grab_point_agent, gl_point))
 			{
-				LLUI::setMousePositionScreen(gl_point.mX, gl_point.mY);
+				LLUI::getInstance()->setMousePositionScreen(gl_point.mX, gl_point.mY);
 			}
 		}
 		else
 		{
 			// ...move cursor back to click position
-			LLUI::setMousePositionScreen(mGrabPick.mMousePt.mX, mGrabPick.mMousePt.mY);
+			LLUI::getInstance()->setMousePositionScreen(mGrabPick.mMousePt.mX, mGrabPick.mMousePt.mY);
 		}
 
 		gViewerWindow->showCursor();
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index 6c1ae7159bca6dd12a8deb2dc6591570493455c9..aeb8bdc496dd4d3535f83a1165bf4ee310267b27 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -1162,7 +1162,7 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l
 				const LLMediaEntry* mep = has_media ? tep->getMediaData() : NULL;
 				if (mep)
 				{
-					viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+					viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
 					LLPluginClassMedia* media_plugin = NULL;
 					
 					if (media_impl.notNull() && (media_impl->hasMedia()))
@@ -1232,7 +1232,7 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l
 
 BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask)
 {
-	if (!LLUI::sSettingGroups["config"]->getBOOL("ShowHoverTips")) return TRUE;
+	if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("ShowHoverTips")) return TRUE;
 	if (!mHoverPick.isValid()) return TRUE;
 
 	LLViewerObject* hover_object = mHoverPick.getObject();
@@ -1337,7 +1337,7 @@ void LLToolPie::playCurrentMedia(const LLPickInfo& info)
 
 	LLPluginClassMedia* media_plugin = NULL;
 	
-	viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+	viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
 		
 	if(media_impl.notNull() && media_impl->hasMedia())
 	{
@@ -1389,7 +1389,7 @@ void LLToolPie::VisitHomePage(const LLPickInfo& info)
 	
 	LLPluginClassMedia* media_plugin = NULL;
 	
-	viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+	viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
 	
 	if(media_impl.notNull() && media_impl->hasMedia())
 	{
@@ -1489,19 +1489,19 @@ static void handle_click_action_play()
 	LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
 	if (!parcel) return;
 
-	LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
+	LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getInstance()->getStatus();
 	switch(status)
 	{
 		case LLViewerMediaImpl::MEDIA_PLAYING:
-			LLViewerParcelMedia::pause();
+			LLViewerParcelMedia::getInstance()->pause();
 			break;
 
 		case LLViewerMediaImpl::MEDIA_PAUSED:
-			LLViewerParcelMedia::start();
+			LLViewerParcelMedia::getInstance()->start();
 			break;
 
 		default:
-			LLViewerParcelMedia::play(parcel);
+			LLViewerParcelMedia::getInstance()->play(parcel);
 			break;
 	}
 }
@@ -1532,7 +1532,7 @@ bool LLToolPie::handleMediaClick(const LLPickInfo& pick)
     if (!mep)
         return false;
 
-    viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+    viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
 
     if (gSavedSettings.getBOOL("MediaOnAPrimUI"))
     {
@@ -1586,7 +1586,7 @@ bool LLToolPie::handleMediaDblClick(const LLPickInfo& pick)
     if (!mep)
         return false;
 
-    viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+    viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
 
     if (gSavedSettings.getBOOL("MediaOnAPrimUI"))
     {
@@ -1641,7 +1641,7 @@ bool LLToolPie::handleMediaHover(const LLPickInfo& pick)
 	if (mep
 		&& gSavedSettings.getBOOL("MediaOnAPrimUI"))
 	{		
-		viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID());
+		viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
 		
 		if(media_impl.notNull())
 		{
@@ -1679,7 +1679,7 @@ bool LLToolPie::handleMediaMouseUp()
 	if(mMediaMouseCaptureID.notNull())
 	{
 		// Face media needs to know the mouse went up.
-		viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mMediaMouseCaptureID);
+		viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mMediaMouseCaptureID);
 		if(media_impl)
 		{
 			// This will send a mouseUp event to the plugin using the last known mouse coordinate (from a mouseDown or mouseMove), which is what we want.
@@ -1708,7 +1708,7 @@ static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
 	if( face < 0 || face >= objectp->getNumTEs() ) return;
 		
 	// is media playing on this face?
-	if (LLViewerMedia::getMediaImplFromTextureID(objectp->getTE(face)->getID()) != NULL)
+	if (LLViewerMedia::getInstance()->getMediaImplFromTextureID(objectp->getTE(face)->getID()) != NULL)
 	{
 		handle_click_action_play();
 		return;
@@ -1738,7 +1738,7 @@ static ECursorType cursor_from_parcel_media(U8 click_action)
 
 	open_cursor = UI_CURSOR_TOOLMEDIAOPEN;
 
-	LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
+	LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getInstance()->getStatus();
 	switch(status)
 	{
 		case LLViewerMediaImpl::MEDIA_PLAYING:
diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp
deleted file mode 100644
index b2d2fa9d77fbbec1baa0cef58745a87b5ea1c77e..0000000000000000000000000000000000000000
--- a/indra/newview/lltwitterconnect.cpp
+++ /dev/null
@@ -1,576 +0,0 @@
-/** 
- * @file lltwitterconnect.h
- * @author Merov, Cho
- * @brief Connection to Twitter Service
- *
- * $LicenseInfo:firstyear=2013&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2013, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "lltwitterconnect.h"
-#include "llflickrconnect.h"
-
-#include "llagent.h"
-#include "llcallingcard.h"			// for LLAvatarTracker
-#include "llcommandhandler.h"
-#include "llnotificationsutil.h"
-#include "llurlaction.h"
-#include "llimagepng.h"
-#include "llimagejpeg.h"
-#include "lltrans.h"
-#include "llevents.h"
-#include "llviewerregion.h"
-
-#include "llfloaterwebcontent.h"
-#include "llfloaterreg.h"
-#include "llcorehttputil.h"
-
-boost::scoped_ptr<LLEventPump> LLTwitterConnect::sStateWatcher(new LLEventStream("TwitterConnectState"));
-boost::scoped_ptr<LLEventPump> LLTwitterConnect::sInfoWatcher(new LLEventStream("TwitterConnectInfo"));
-boost::scoped_ptr<LLEventPump> LLTwitterConnect::sContentWatcher(new LLEventStream("TwitterConnectContent"));
-
-// Local functions
-void log_twitter_connect_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description)
-{
-    // Note: 302 (redirect) is *not* an error that warrants logging
-    if (status != 302)
-    {
-		LL_WARNS("TwitterConnect") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << " (" << description << ")" << LL_ENDL;
-    }
-}
-
-void toast_user_for_twitter_success()
-{
-	LLSD args;
-    args["MESSAGE"] = LLTrans::getString("twitter_post_success");
-    LLNotificationsUtil::add("TwitterConnect", args);
-}
-
-class LLTwitterConnectHandler : public LLCommandHandler
-{
-public:
-    LLTwitterConnectHandler() : LLCommandHandler("fbc", UNTRUSTED_THROTTLE) {}
-
-    bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
-    {
-        if (tokens.size() >= 1)
-        {
-            if (tokens[0].asString() == "connect")
-            {
-                if (tokens.size() >= 2 && tokens[1].asString() == "twitter")
-                {
-                    // this command probably came from the twitter_web browser, so close it
-                    LLFloaterReg::hideInstance("twitter_web");
-
-                    // connect to twitter
-                    if (query_map.has("oauth_token"))
-                    {
-                        LLTwitterConnect::instance().connectToTwitter(query_map["oauth_token"], query_map.get("oauth_verifier"));
-                    }
-                    return true;
-                }
-                else if (tokens.size() >= 2 && tokens[1].asString() == "flickr")
-                {
-                    // this command probably came from the flickr_web browser, so close it
-                    LLFloaterReg::hideInstance("flickr_web");
-
-                    // connect to flickr
-                    if (query_map.has("oauth_token"))
-                    {
-                        LLFlickrConnect::instance().connectToFlickr(query_map["oauth_token"], query_map.get("oauth_verifier"));
-                    }
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-};
-LLTwitterConnectHandler gTwitterConnectHandler;
-
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLTwitterConnect::twitterConnectCoro(std::string requestToken, std::string oauthVerifier)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    LLSD body;
-    if (!requestToken.empty())
-        body["request_token"] = requestToken;
-    if (!oauthVerifier.empty())
-        body["oauth_verifier"] = oauthVerifier;
-
-    LLSD result = httpAdapter->putAndSuspend(httpRequest, getTwitterConnectURL("/connection"), body, httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (!status)
-    {
-        if ( status == LLCore::HttpStatus(HTTP_FOUND) )
-        {
-            std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION];
-            if (location.empty())
-            {
-                LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL;
-            }
-            else
-            {
-                openTwitterWeb(location);
-            }
-        }
-        else
-        {
-            LL_WARNS("TwitterConnect") << "Connection failed " << status.toString() << LL_ENDL;
-            setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED);
-            log_twitter_connect_error("Connect", status.getStatus(), status.toString(),
-                result.get("error_code"), result.get("error_description"));
-        }
-    }
-    else
-    {
-        LL_DEBUGS("TwitterConnect") << "Connect successful. " << LL_ENDL;
-        setConnectionState(LLTwitterConnect::TWITTER_CONNECTED);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-bool LLTwitterConnect::testShareStatus(LLSD &result)
-{
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (status)
-        return true;
-
-    if (status == LLCore::HttpStatus(HTTP_FOUND))
-    {
-        std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION];
-        if (location.empty())
-        {
-            LL_WARNS("TwitterConnect") << "Missing Location header " << LL_ENDL;
-        }
-        else
-        {
-            openTwitterWeb(location);
-        }
-    }
-    if (status == LLCore::HttpStatus(HTTP_NOT_FOUND))
-    {
-        LL_DEBUGS("TwitterConnect") << "Not connected. " << LL_ENDL;
-        connectToTwitter();
-    }
-    else
-    {
-        LL_WARNS("TwitterConnect") << "HTTP Status error " << status.toString() << LL_ENDL;
-        setConnectionState(LLTwitterConnect::TWITTER_POST_FAILED);
-        log_twitter_connect_error("Share", status.getStatus(), status.toString(),
-            result.get("error_code"), result.get("error_description"));
-    }
-    return false;
-}
-
-void LLTwitterConnect::twitterShareCoro(std::string route, LLSD share)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    LLSD result = httpAdapter->postAndSuspend(httpRequest, getTwitterConnectURL(route, true), share, httpOpts);
-
-    if (testShareStatus(result))
-    {
-        toast_user_for_twitter_success();
-        LL_DEBUGS("TwitterConnect") << "Post successful. " << LL_ENDL;
-        setConnectionState(LLTwitterConnect::TWITTER_POSTED);
-    }
-}
-
-void LLTwitterConnect::twitterShareImageCoro(LLPointer<LLImageFormatted> image, std::string status)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    std::string imageFormat;
-    if (dynamic_cast<LLImagePNG*>(image.get()))
-    {
-        imageFormat = "png";
-    }
-    else if (dynamic_cast<LLImageJPEG*>(image.get()))
-    {
-        imageFormat = "jpg";
-    }
-    else
-    {
-        LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL;
-        return;
-    }
-
-    // All this code is mostly copied from LLWebProfile::post()
-    const std::string boundary = "----------------------------0123abcdefab";
-
-    std::string contentType = "multipart/form-data; boundary=" + boundary;
-    httpHeaders->append("Content-Type", contentType.c_str());
-
-    LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // 
-    LLCore::BufferArrayStream body(raw.get());
-
-    // *NOTE: The order seems to matter.
-    body << "--" << boundary << "\r\n"
-        << "Content-Disposition: form-data; name=\"status\"\r\n\r\n"
-        << status << "\r\n";
-
-    body << "--" << boundary << "\r\n"
-        << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n"
-        << "Content-Type: image/" << imageFormat << "\r\n\r\n";
-
-    // Insert the image data.
-    // *FIX: Treating this as a string will probably screw it up ...
-    U8* image_data = image->getData();
-    for (S32 i = 0; i < image->getDataSize(); ++i)
-    {
-        body << image_data[i];
-    }
-
-    body << "\r\n--" << boundary << "--\r\n";
-
-    LLSD result = httpAdapter->postAndSuspend(httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders);
-
-    if (testShareStatus(result))
-    {
-        toast_user_for_twitter_success();
-        LL_DEBUGS("TwitterConnect") << "Post successful. " << LL_ENDL;
-        setConnectionState(LLTwitterConnect::TWITTER_POSTED);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLTwitterConnect::twitterDisconnectCoro()
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setFollowRedirects(false);
-
-    LLSD result = httpAdapter->deleteAndSuspend(httpRequest, getTwitterConnectURL("/connection"), httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND)))
-    {
-        LL_WARNS("TwitterConnect") << "Disconnect failed!" << LL_ENDL;
-        setConnectionState(LLTwitterConnect::TWITTER_DISCONNECT_FAILED);
-
-        log_twitter_connect_error("Disconnect", status.getStatus(), status.toString(),
-            result.get("error_code"), result.get("error_description"));
-    }
-    else
-    {
-        LL_DEBUGS("TwitterConnect") << "Disconnect successful. " << LL_ENDL;
-        clearInfo();
-        setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLTwitterConnect::twitterConnectedCoro(bool autoConnect)
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setFollowRedirects(false);
-    setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS);
-
-    LLSD result = httpAdapter->getAndSuspend(httpRequest, getTwitterConnectURL("/connection", true), httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (!status)
-    {
-        if (status == LLCore::HttpStatus(HTTP_NOT_FOUND))
-        {
-            LL_DEBUGS("TwitterConnect") << "Not connected. " << LL_ENDL;
-            if (autoConnect)
-            {
-                connectToTwitter();
-            }
-            else
-            {
-                setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED);
-            }
-        }
-        else
-        {
-            LL_WARNS("TwitterConnect") << "Failed to test connection:" << status.toTerseString() << LL_ENDL;
-
-            setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED);
-            log_twitter_connect_error("Connected", status.getStatus(), status.toString(),
-                result.get("error_code"), result.get("error_description"));
-        }
-    }
-    else
-    {
-        LL_DEBUGS("TwitterConnect") << "Connect successful. " << LL_ENDL;
-        setConnectionState(LLTwitterConnect::TWITTER_CONNECTED);
-    }
-
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-void LLTwitterConnect::twitterInfoCoro()
-{
-    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
-    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
-        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy));
-    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
-    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
-
-    httpOpts->setWantHeaders(true);
-    httpOpts->setFollowRedirects(false);
-
-    LLSD result = httpAdapter->getAndSuspend(httpRequest, getTwitterConnectURL("/info", true), httpOpts);
-
-    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
-    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
-    if (status == LLCore::HttpStatus(HTTP_FOUND))
-    {
-        std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION];
-        if (location.empty())
-        {
-            LL_WARNS("TwitterConnect") << "Missing Location header " << LL_ENDL;
-        }
-        else
-        {
-            openTwitterWeb(location);
-        }
-    }
-    else if (!status)
-    {
-        LL_WARNS("TwitterConnect") << "Twitter Info failed: " << status.toString() << LL_ENDL;
-        log_twitter_connect_error("Info", status.getStatus(), status.toString(),
-            result.get("error_code"), result.get("error_description"));
-    }
-    else
-    {
-        LL_INFOS("TwitterConnect") << "Twitter: Info received" << LL_ENDL;
-        result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS);
-        storeInfo(result);
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-LLTwitterConnect::LLTwitterConnect()
-:	mConnectionState(TWITTER_NOT_CONNECTED),
-	mConnected(false),
-	mInfo(),
-	mRefreshInfo(false),
-	mReadFromMaster(false)
-{
-}
-
-void LLTwitterConnect::openTwitterWeb(std::string url)
-{
-	LLFloaterWebContent::Params p;
-    p.url(url);
-    p.show_chrome(true);
-    p.allow_back_forward_navigation(false);
-    p.clean_browser(true);
-	LLFloater *floater = LLFloaterReg::showInstance("twitter_web", p);
-	//the internal web browser has a bug that prevents it from gaining focus unless a mouse event occurs first (it seems).
-	//So when showing the internal web browser, set focus to it's containing floater "twitter_web". When a mouse event 
-	//occurs on the "webbrowser" panel part of the floater, a mouse cursor will properly show and the "webbrowser" will gain focus.
-	//twitter_web floater contains the "webbrowser" panel.    JIRA: ACME-744
-	gFocusMgr.setKeyboardFocus( floater );
-
-	//LLUrlAction::openURLExternal(url);
-}
-
-std::string LLTwitterConnect::getTwitterConnectURL(const std::string& route, bool include_read_from_master)
-{
-    std::string url("");
-    LLViewerRegion *regionp = gAgent.getRegion();
-    if (regionp)
-    {
-		//url = "http://pdp15.lindenlab.com/twitter/agent/" + gAgentID.asString(); // TEMPORARY FOR TESTING - CHO
-        url = regionp->getCapability("TwitterConnect");
-        url += route;
-    
-        if (include_read_from_master && mReadFromMaster)
-        {
-            url += "?read_from_master=true";
-        }
-    }
-	return url;
-}
-
-void LLTwitterConnect::connectToTwitter(const std::string& request_token, const std::string& oauth_verifier)
-{
-    setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS);
-
-    LLCoros::instance().launch("LLTwitterConnect::twitterConnectCoro",
-        boost::bind(&LLTwitterConnect::twitterConnectCoro, this, request_token, oauth_verifier));
-}
-
-void LLTwitterConnect::disconnectFromTwitter()
-{
-    setConnectionState(LLTwitterConnect::TWITTER_DISCONNECTING);
-
-    LLCoros::instance().launch("LLTwitterConnect::twitterDisconnectCoro",
-        boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this));
-}
-
-void LLTwitterConnect::checkConnectionToTwitter(bool auto_connect)
-{
-    LLCoros::instance().launch("LLTwitterConnect::twitterConnectedCoro",
-        boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, auto_connect));
-}
-
-void LLTwitterConnect::loadTwitterInfo()
-{
-	if(mRefreshInfo)
-	{
-        LLCoros::instance().launch("LLTwitterConnect::twitterInfoCoro",
-            boost::bind(&LLTwitterConnect::twitterInfoCoro, this));
-	}
-}
-
-void LLTwitterConnect::uploadPhoto(const std::string& image_url, const std::string& status)
-{
-	LLSD body;
-	body["image"] = image_url;
-	body["status"] = status;
-
-    setConnectionState(LLTwitterConnect::TWITTER_POSTING);
-
-    LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro",
-        boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/photo", body));
-}
-
-void LLTwitterConnect::uploadPhoto(LLPointer<LLImageFormatted> image, const std::string& status)
-{
-    setConnectionState(LLTwitterConnect::TWITTER_POSTING);
-
-    LLCoros::instance().launch("LLTwitterConnect::twitterShareImageCoro",
-        boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, image, status));
-}
-
-void LLTwitterConnect::updateStatus(const std::string& status)
-{
-	LLSD body;
-	body["status"] = status;
-	
-    setConnectionState(LLTwitterConnect::TWITTER_POSTING);
-
-    LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro",
-        boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/status", body));
-}
-
-void LLTwitterConnect::storeInfo(const LLSD& info)
-{
-	mInfo = info;
-	mRefreshInfo = false;
-
-	sInfoWatcher->post(info);
-}
-
-const LLSD& LLTwitterConnect::getInfo() const
-{
-	return mInfo;
-}
-
-void LLTwitterConnect::clearInfo()
-{
-	mInfo = LLSD();
-}
-
-void LLTwitterConnect::setDataDirty()
-{
-	mRefreshInfo = true;
-}
-
-void LLTwitterConnect::setConnectionState(LLTwitterConnect::EConnectionState connection_state)
-{
-	if(connection_state == TWITTER_CONNECTED)
-	{
-		mReadFromMaster = true;
-		setConnected(true);
-		setDataDirty();
-	}
-	else if(connection_state == TWITTER_NOT_CONNECTED)
-	{
-		setConnected(false);
-	}
-	else if(connection_state == TWITTER_POSTED)
-	{
-		mReadFromMaster = false;
-	}
-
-	if (mConnectionState != connection_state)
-	{
-		// set the connection state before notifying watchers
-		mConnectionState = connection_state;
-
-		LLSD state_info;
-		state_info["enum"] = connection_state;
-		sStateWatcher->post(state_info);
-	}
-}
-
-void LLTwitterConnect::setConnected(bool connected)
-{
-	mConnected = connected;
-}
diff --git a/indra/newview/lltwitterconnect.h b/indra/newview/lltwitterconnect.h
deleted file mode 100644
index e77048cc35112390873121dd5dd4e2797ff8e674..0000000000000000000000000000000000000000
--- a/indra/newview/lltwitterconnect.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/** 
- * @file lltwitterconnect.h
- * @author Merov, Cho
- * @brief Connection to Twitter Service
- *
- * $LicenseInfo:firstyear=2013&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2013, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLTWITTERCONNECT_H
-#define LL_LLTWITTERCONNECT_H
-
-#include "llsingleton.h"
-#include "llimage.h"
-#include "llcoros.h"
-#include "lleventcoro.h"
-
-class LLEventPump;
-
-/**
- * @class LLTwitterConnect
- *
- * Manages authentication to, and interaction with, a web service allowing the
- * the viewer to post status updates and upload photos to Twitter.
- */
-class LLTwitterConnect : public LLSingleton<LLTwitterConnect>
-{
-	LLSINGLETON(LLTwitterConnect);
-	LOG_CLASS(LLTwitterConnect);
-public:
-    enum EConnectionState
-	{
-		TWITTER_NOT_CONNECTED = 0,
-		TWITTER_CONNECTION_IN_PROGRESS = 1,
-		TWITTER_CONNECTED = 2,
-		TWITTER_CONNECTION_FAILED = 3,
-		TWITTER_POSTING = 4,
-		TWITTER_POSTED = 5,
-		TWITTER_POST_FAILED = 6,
-		TWITTER_DISCONNECTING = 7,
-		TWITTER_DISCONNECT_FAILED = 8
-	};
-	
-	void connectToTwitter(const std::string& request_token = "", const std::string& oauth_verifier = "");	// Initiate the complete Twitter connection. Please use checkConnectionToTwitter() in normal use.
-	void disconnectFromTwitter();																			// Disconnect from the Twitter service.
-    void checkConnectionToTwitter(bool auto_connect = false);												// Check if an access token is available on the Twitter service. If not, call connectToTwitter().
-    
-	void loadTwitterInfo();
-	void uploadPhoto(const std::string& image_url, const std::string& status);
-	void uploadPhoto(LLPointer<LLImageFormatted> image, const std::string& status);
-	void updateStatus(const std::string& status);
-	
-	void storeInfo(const LLSD& info);
-	const LLSD& getInfo() const;
-	void clearInfo();
-	void setDataDirty();
-    
-    void setConnectionState(EConnectionState connection_state);
-	void setConnected(bool connected);
-	bool isConnected() { return mConnected; }
-	bool isTransactionOngoing() { return ((mConnectionState == TWITTER_CONNECTION_IN_PROGRESS) || (mConnectionState == TWITTER_POSTING) || (mConnectionState == TWITTER_DISCONNECTING)); }
-    EConnectionState getConnectionState() { return mConnectionState; }
-    
-    void openTwitterWeb(std::string url);
-
-private:
-
- 	std::string getTwitterConnectURL(const std::string& route = "", bool include_read_from_master = false);
-
-    EConnectionState mConnectionState;
-	BOOL mConnected;
-	LLSD mInfo;
-	bool mRefreshInfo;
-	bool mReadFromMaster;
-	
-	static boost::scoped_ptr<LLEventPump> sStateWatcher;
-	static boost::scoped_ptr<LLEventPump> sInfoWatcher;
-	static boost::scoped_ptr<LLEventPump> sContentWatcher;
-
-    bool testShareStatus(LLSD &result);
-    void twitterConnectCoro(std::string requestToken, std::string oauthVerifier);
-    void twitterDisconnectCoro();
-    void twitterConnectedCoro(bool autoConnect);
-    void twitterInfoCoro();
-    void twitterShareCoro(std::string route, LLSD share);
-    void twitterShareImageCoro(LLPointer<LLImageFormatted> image, std::string status);
-};
-
-#endif // LL_LLTWITTERCONNECT_H
diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp
index 6b2cd71d406ac4a493eb6de9dd66a6b9d2b2d2b5..956f5cf187acecbabdc369c56a9e253dc5f35d9e 100644
--- a/indra/newview/lluilistener.cpp
+++ b/indra/newview/lluilistener.cpp
@@ -84,8 +84,8 @@ void LLUIListener::getValue(const LLSD&event) const
 {
     LLSD reply = LLSD::emptyMap();
 
-    const LLView* root = LLUI::getRootView();
-    const LLView* view = LLUI::resolvePath(root, event["path"].asString());
+    const LLView* root = LLUI::getInstance()->getRootView();
+    const LLView* view = LLUI::getInstance()->resolvePath(root, event["path"].asString());
     const LLUICtrl* ctrl(dynamic_cast<const LLUICtrl*>(view));
 
     if (ctrl) 
diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp
index da31e4f54246beb9d90d9840fa26f96ed1875e40..a1670351f4005da600c0e90a9470dba1eadcd4b0 100644
--- a/indra/newview/llurldispatcher.cpp
+++ b/indra/newview/llurldispatcher.cpp
@@ -188,7 +188,7 @@ bool LLURLDispatcherImpl::dispatchRegion(const LLSLURL& slurl, const std::string
 	LLWorldMapMessage::getInstance()->sendNamedRegionRequest(slurl.getRegion(),
 									  LLURLDispatcherImpl::regionNameCallback,
 									  slurl.getSLURLString(),
-									  LLUI::sSettingGroups["config"]->getBOOL("SLURLTeleportDirectly"));	// don't teleport
+									  LLUI::getInstance()->mSettingGroups["config"]->getBOOL("SLURLTeleportDirectly"));	// don't teleport
 	return true;
 }
 
diff --git a/indra/newview/llurllineeditorctrl.cpp b/indra/newview/llurllineeditorctrl.cpp
index 8a6111485264b7ea297fab407f3c558365c5c2df..2b7e598a590cea853e8eb30d22efc0a635ac1f61 100644
--- a/indra/newview/llurllineeditorctrl.cpp
+++ b/indra/newview/llurllineeditorctrl.cpp
@@ -66,7 +66,7 @@ void LLURLLineEditor::cut()
 		if( need_to_rollback )
 		{
 			rollback.doRollback( this );
-			LLUI::reportBadKeystroke();
+			LLUI::getInstance()->reportBadKeystroke();
 		}
 		else
 		if( mKeystrokeCallback )
diff --git a/indra/newview/llurlwhitelist.cpp b/indra/newview/llurlwhitelist.cpp
index 3a7285974e4041381b069b8edce0453308c17461..b4d38f5d1e7f9e948d21c94de35d5f4425b5dba5 100644
--- a/indra/newview/llurlwhitelist.cpp
+++ b/indra/newview/llurlwhitelist.cpp
@@ -31,8 +31,6 @@
 #include <iostream>
 #include <fstream>
 
-LLUrlWhiteList* LLUrlWhiteList::sInstance = 0;
-
 ///////////////////////////////////////////////////////////////////////////////
 //
 LLUrlWhiteList::LLUrlWhiteList () :
@@ -49,29 +47,6 @@ LLUrlWhiteList::~LLUrlWhiteList ()
 {
 }
 
-///////////////////////////////////////////////////////////////////////////////
-
-//static
-void LLUrlWhiteList::initClass ()
-{
-    if ( ! sInstance )
-	{
-        sInstance = new LLUrlWhiteList ();
-	}
-}
-
-//static
-void LLUrlWhiteList::cleanupClass ()
-{
-	delete sInstance;
-	sInstance = NULL;
-}
-
-LLUrlWhiteList* LLUrlWhiteList::getInstance ()
-{
-	return sInstance;
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 //
 bool LLUrlWhiteList::load ()
diff --git a/indra/newview/llurlwhitelist.h b/indra/newview/llurlwhitelist.h
index b0969051a76afcabdef7a16a9ce5b61ab6647803..c2511b08fd8da4a9fec2220c8d00197453d45907 100644
--- a/indra/newview/llurlwhitelist.h
+++ b/indra/newview/llurlwhitelist.h
@@ -30,15 +30,11 @@
 
 #include <list>
 
-class LLUrlWhiteList
+class LLUrlWhiteList : public LLSingleton<LLUrlWhiteList>
 {
+	LLSINGLETON(LLUrlWhiteList);
+	~LLUrlWhiteList();
 	public:
-		virtual ~LLUrlWhiteList ();
-
-		static void initClass();
-		static void cleanupClass();
-		static LLUrlWhiteList* getInstance ();
-
 		bool load ();
 		bool save ();
 
@@ -51,9 +47,6 @@ class LLUrlWhiteList
 		bool getNext ( std::string& valueOut );
 
 	private:
-		LLUrlWhiteList ();
-		static LLUrlWhiteList* sInstance;
-
 		typedef std::vector < std::string > string_list_t ;
 
 		bool mLoaded;
diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp
index 7ce9d858dd89ee068bcd51a77fcb529098a8df0e..cb20801756162acdc62b78f58a3382fee5a25d95 100644
--- a/indra/newview/llvieweraudio.cpp
+++ b/indra/newview/llvieweraudio.cpp
@@ -463,24 +463,25 @@ void audio_update_volume(bool force_update)
 	F32 media_volume = gSavedSettings.getF32("AudioLevelMedia");
 	BOOL media_muted = gSavedSettings.getBOOL("MuteMedia");
 	media_volume = mute_volume * master_volume * media_volume;
-	LLViewerMedia::setVolume( media_muted ? 0.0f : media_volume );
+	LLViewerMedia::getInstance()->setVolume( media_muted ? 0.0f : media_volume );
 
-	// Voice
-	if (LLVoiceClient::getInstance())
+	// Voice, this is parametric singleton, it gets initialized when ready
+	if (LLVoiceClient::instanceExists())
 	{
 		F32 voice_volume = gSavedSettings.getF32("AudioLevelVoice");
 		voice_volume = mute_volume * master_volume * voice_volume;
 		BOOL voice_mute = gSavedSettings.getBOOL("MuteVoice");
-		LLVoiceClient::getInstance()->setVoiceVolume(voice_mute ? 0.f : voice_volume);
-		LLVoiceClient::getInstance()->setMicGain(voice_mute ? 0.f : gSavedSettings.getF32("AudioLevelMic"));
+		LLVoiceClient *voice_inst = LLVoiceClient::getInstance();
+		voice_inst->setVoiceVolume(voice_mute ? 0.f : voice_volume);
+		voice_inst->setMicGain(voice_mute ? 0.f : gSavedSettings.getF32("AudioLevelMic"));
 
 		if (!gViewerWindow->getActive() && (gSavedSettings.getBOOL("MuteWhenMinimized")))
 		{
-			LLVoiceClient::getInstance()->setMuteMic(true);
+			voice_inst->setMuteMic(true);
 		}
 		else
 		{
-			LLVoiceClient::getInstance()->setMuteMic(false);
+			voice_inst->setMuteMic(false);
 		}
 	}
 }
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index a3d946c4d43e3cd6e6dfdf5a50201ff3db134b31..6df849674f26b56349b38b5ce5d4553ce43a1363 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1508,9 +1508,10 @@ void render_ui_2d()
 
 	if (gSavedSettings.getBOOL("RenderUIBuffer"))
 	{
-		if (LLUI::sDirty)
+		LLUI* ui_inst = LLUI::getInstance();
+		if (ui_inst->mDirty)
 		{
-			LLUI::sDirty = FALSE;
+			ui_inst->mDirty = FALSE;
 			LLRect t_rect;
 
 			gPipeline.mUIScreen.bindTarget();
@@ -1518,25 +1519,25 @@ void render_ui_2d()
 			{
 				static const S32 pad = 8;
 
-				LLUI::sDirtyRect.mLeft -= pad;
-				LLUI::sDirtyRect.mRight += pad;
-				LLUI::sDirtyRect.mBottom -= pad;
-				LLUI::sDirtyRect.mTop += pad;
+				ui_inst->mDirtyRect.mLeft -= pad;
+				ui_inst->mDirtyRect.mRight += pad;
+				ui_inst->mDirtyRect.mBottom -= pad;
+				ui_inst->mDirtyRect.mTop += pad;
 
 				LLGLEnable scissor(GL_SCISSOR_TEST);
-				static LLRect last_rect = LLUI::sDirtyRect;
+				static LLRect last_rect = ui_inst->mDirtyRect;
 
 				//union with last rect to avoid mouse poop
-				last_rect.unionWith(LLUI::sDirtyRect);
+				last_rect.unionWith(ui_inst->mDirtyRect);
 								
-				t_rect = LLUI::sDirtyRect;
-				LLUI::sDirtyRect = last_rect;
+				t_rect = ui_inst->mDirtyRect;
+				ui_inst->mDirtyRect = last_rect;
 				last_rect = t_rect;
 			
-				last_rect.mLeft = LLRect::tCoordType(last_rect.mLeft / LLUI::getScaleFactor().mV[0]);
-				last_rect.mRight = LLRect::tCoordType(last_rect.mRight / LLUI::getScaleFactor().mV[0]);
-				last_rect.mTop = LLRect::tCoordType(last_rect.mTop / LLUI::getScaleFactor().mV[1]);
-				last_rect.mBottom = LLRect::tCoordType(last_rect.mBottom / LLUI::getScaleFactor().mV[1]);
+				last_rect.mLeft = LLRect::tCoordType(last_rect.mLeft / ui_inst->getScaleFactor().mV[0]);
+				last_rect.mRight = LLRect::tCoordType(last_rect.mRight / ui_inst->getScaleFactor().mV[0]);
+				last_rect.mTop = LLRect::tCoordType(last_rect.mTop / ui_inst->getScaleFactor().mV[1]);
+				last_rect.mBottom = LLRect::tCoordType(last_rect.mBottom / ui_inst->getScaleFactor().mV[1]);
 
 				LLRect clip_rect(last_rect);
 				
@@ -1548,7 +1549,7 @@ void render_ui_2d()
 			gPipeline.mUIScreen.flush();
 			gGL.setColorMask(true, false);
 
-			LLUI::sDirtyRect = t_rect;
+			ui_inst->mDirtyRect = t_rect;
 		}
 
 		LLGLDisable cull(GL_CULL_FACE);
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 846a8e62a15393499b5fff1755805ffef731d813..bbd5251ed234243e70afdc5d8cc49cde096af575 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -67,7 +67,6 @@
 #include "llfloaterexperiences.h"
 #include "llfloaterexperiencepicker.h"
 #include "llfloaterevent.h"
-#include "llfloaterflickr.h"
 #include "llfloaterfonttest.h"
 #include "llfloaterforgetuser.h"
 #include "llfloatergesture.h"
@@ -133,7 +132,6 @@
 #include "llfloatertos.h"
 #include "llfloatertoybox.h"
 #include "llfloatertranslationsettings.h"
-#include "llfloatertwitter.h"
 #include "llfloateruipreview.h"
 #include "llfloatervoiceeffect.h"
 #include "llfloaterwebcontent.h"
@@ -354,11 +352,6 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
 	LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
 
-	LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-	LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-	
-	LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>);
-	LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>);
 	LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>);
 	
 	LLFloaterUIPreviewUtil::registerFloater();
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 394af27dc6ff452ffc7d88a16b06a3277e6b4063..6ff02ffe66b3999b13c011993e35e31f2376b5ee 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -238,7 +238,7 @@ class LLInventoryHandler : public LLCommandHandler
 			return false;
 		}
 
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableInventory"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableInventory"))
 		{
 				LLNotificationsUtil::add("NoInventory", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 				return true;
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp
index cf9243a8719a61329977f7f19475e979fa69b073..8a597ed7e65147c5c862ec3ed41b645f31b56944 100644
--- a/indra/newview/llviewerjointattachment.cpp
+++ b/indra/newview/llviewerjointattachment.cpp
@@ -225,7 +225,7 @@ void LLViewerJointAttachment::removeObject(LLViewerObject *object)
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-		LLViewerObject *attached_object = (*iter);
+		LLViewerObject *attached_object = iter->get();
 		if (attached_object == object)
 		{
 			break;
@@ -327,7 +327,7 @@ void LLViewerJointAttachment::setAttachmentVisibility(BOOL visible)
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-		LLViewerObject *attached_obj = (*iter);
+		LLViewerObject *attached_obj = iter->get();
 		if (!attached_obj || attached_obj->mDrawable.isNull() || 
 			!(attached_obj->mDrawable->getSpatialBridge()))
 			continue;
@@ -366,7 +366,7 @@ S32 LLViewerJointAttachment::getNumAnimatedObjects() const
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-        const LLViewerObject *attached_object = *iter;
+        const LLViewerObject *attached_object = iter->get();
         if (attached_object->isAnimatedObject())
         {
             count++;
@@ -384,7 +384,7 @@ void LLViewerJointAttachment::clampObjectPosition()
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-		if (LLViewerObject *attached_object = (*iter))
+		if (LLViewerObject *attached_object = iter->get())
 		{
 			// *NOTE: object can drift when hitting maximum radius
 			LLVector3 attachmentPos = attached_object->getPosition();
@@ -406,7 +406,7 @@ void LLViewerJointAttachment::calcLOD()
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-		if (LLViewerObject *attached_object = (*iter))
+		if (LLViewerObject *attached_object = iter->get())
 		{
 			maxarea = llmax(maxarea,attached_object->getMaxScale() * attached_object->getMidScale());
 			LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
@@ -445,7 +445,7 @@ BOOL LLViewerJointAttachment::isObjectAttached(const LLViewerObject *viewer_obje
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-		const LLViewerObject* attached_object = (*iter);
+		const LLViewerObject* attached_object = iter->get();
 		if (attached_object == viewer_object)
 		{
 			return TRUE;
@@ -460,7 +460,7 @@ const LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &o
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-		const LLViewerObject* attached_object = (*iter);
+		const LLViewerObject* attached_object = iter->get();
 		if (attached_object->getAttachmentItemID() == object_id)
 		{
 			return attached_object;
@@ -475,7 +475,7 @@ LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &object_
 		 iter != mAttachedObjects.end();
 		 ++iter)
 	{
-		LLViewerObject* attached_object = (*iter);
+		LLViewerObject* attached_object = iter->get();
 		if (attached_object->getAttachmentItemID() == object_id)
 		{
 			return attached_object;
diff --git a/indra/newview/llviewerjointattachment.h b/indra/newview/llviewerjointattachment.h
index 9641ab4208c81a7b8d41c05dc1ce21539961322f..e5edf2c06b6d974f6a25b30dd2be71997e983d6a 100644
--- a/indra/newview/llviewerjointattachment.h
+++ b/indra/newview/llviewerjointattachment.h
@@ -95,7 +95,7 @@ class LLViewerJointAttachment :
 	LLViewerObject *getAttachedObject(const LLUUID &object_id);
 
 	// list of attachments for this joint
-	typedef std::vector<LLViewerObject *> attachedobjs_vec_t;
+	typedef std::vector<LLPointer<LLViewerObject> > attachedobjs_vec_t;
 	attachedobjs_vec_t mAttachedObjects;
 
 protected:
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 0fcc88556fd2a0018e00c86a0a6e512008113d85..99b54f66d35e0c014b0bde0b9c41087520c21388 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -78,11 +78,6 @@
 #include <boost/bind.hpp>	// for SkinFolder listener
 #include <boost/signals2.hpp>
 
-/*static*/ const char* LLViewerMedia::SHOW_MEDIA_ON_OTHERS_SETTING = "MediaShowOnOthers";
-/*static*/ const char* LLViewerMedia::SHOW_MEDIA_WITHIN_PARCEL_SETTING = "MediaShowWithinParcel";
-/*static*/ const char* LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING = "MediaShowOutsideParcel";
-
-
 class LLMediaFilePicker : public LLFilePickerThread // deletes itself when done
 {
 public:
@@ -191,9 +186,6 @@ LLViewerMediaObserver::~LLViewerMediaObserver()
 }
 
 
-LLURL LLViewerMedia::sOpenIDURL;
-std::string LLViewerMedia::sOpenIDCookie;
-LLPluginClassMedia* LLViewerMedia::sSpareBrowserMediaSource = NULL;
 static LLViewerMedia::impl_list sViewerMediaImplList;
 static LLViewerMedia::impl_id_map sViewerMediaTextureIDMap;
 static LLTimer sMediaCreateTimer;
@@ -203,8 +195,6 @@ static bool sForceUpdate = false;
 static LLUUID sOnlyAudibleTextureID = LLUUID::null;
 static F64 sLowestLoadableImplInterest = 0.0f;
 static bool sAnyMediaShowing = false;
-static bool sAnyMediaPlaying = false;
-static boost::signals2::connection sTeleportFinishConnection;
 
 //////////////////////////////////////////////////////////////////////////////////////////
 static void add_media_impl(LLViewerMediaImpl* media)
@@ -230,7 +220,7 @@ static void remove_media_impl(LLViewerMediaImpl* media)
 
 class LLViewerMediaMuteListObserver : public LLMuteListObserver
 {
-	/* virtual */ void onChange()  { LLViewerMedia::muteListChanged();}
+	/* virtual */ void onChange()  { LLViewerMedia::getInstance()->muteListChanged();}
 };
 
 static LLViewerMediaMuteListObserver sViewerMediaMuteListObserver;
@@ -239,9 +229,40 @@ static bool sViewerMediaMuteListObserverInitialized = false;
 
 //////////////////////////////////////////////////////////////////////////////////////////
 // LLViewerMedia
-
 //////////////////////////////////////////////////////////////////////////////////////////
+
+/*static*/ const char* LLViewerMedia::AUTO_PLAY_MEDIA_SETTING = "ParcelMediaAutoPlayEnable";
+/*static*/ const char* LLViewerMedia::SHOW_MEDIA_ON_OTHERS_SETTING = "MediaShowOnOthers";
+/*static*/ const char* LLViewerMedia::SHOW_MEDIA_WITHIN_PARCEL_SETTING = "MediaShowWithinParcel";
+/*static*/ const char* LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING = "MediaShowOutsideParcel";
+
+LLViewerMedia::LLViewerMedia():
+mAnyMediaShowing(false),
+mAnyMediaPlaying(false),
+mSpareBrowserMediaSource(NULL)
+{
+}
+
+LLViewerMedia::~LLViewerMedia()
+{
+    gIdleCallbacks.deleteFunction(LLViewerMedia::onIdle, NULL);
+    mTeleportFinishConnection.disconnect();
+    if (mSpareBrowserMediaSource != NULL)
+    {
+        delete mSpareBrowserMediaSource;
+        mSpareBrowserMediaSource = NULL;
+    }
+}
+
 // static
+void LLViewerMedia::initSingleton()
+{
+    gIdleCallbacks.addFunction(LLViewerMedia::onIdle, NULL);
+    mTeleportFinishConnection = LLViewerParcelMgr::getInstance()->
+        setTeleportFinishedCallback(boost::bind(&LLViewerMedia::onTeleportFinished, this));
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
 viewer_media_t LLViewerMedia::newMediaImpl(
 											 const LLUUID& texture_id,
 											 S32 media_width,
@@ -368,7 +389,6 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 LLViewerMediaImpl* LLViewerMedia::getMediaImplFromTextureID(const LLUUID& texture_id)
 {
 	LLViewerMediaImpl* result = NULL;
@@ -384,7 +404,6 @@ LLViewerMediaImpl* LLViewerMedia::getMediaImplFromTextureID(const LLUUID& textur
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 std::string LLViewerMedia::getCurrentUserAgent()
 {
 	// Don't use user-visible string to avoid
@@ -411,7 +430,6 @@ std::string LLViewerMedia::getCurrentUserAgent()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::updateBrowserUserAgent()
 {
 	std::string user_agent = getCurrentUserAgent();
@@ -431,7 +449,6 @@ void LLViewerMedia::updateBrowserUserAgent()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::handleSkinCurrentChanged(const LLSD& /*newvalue*/)
 {
 	// gSavedSettings is already updated when this function is called.
@@ -440,7 +457,6 @@ bool LLViewerMedia::handleSkinCurrentChanged(const LLSD& /*newvalue*/)
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::textureHasMedia(const LLUUID& texture_id)
 {
 	impl_list::iterator iter = sViewerMediaImplList.begin();
@@ -458,7 +474,6 @@ bool LLViewerMedia::textureHasMedia(const LLUUID& texture_id)
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::setVolume(F32 volume)
 {
 	if(volume != sGlobalVolume || sForceUpdate)
@@ -478,14 +493,12 @@ void LLViewerMedia::setVolume(F32 volume)
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 F32 LLViewerMedia::getVolume()
 {
 	return sGlobalVolume;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::muteListChanged()
 {
 	// When the mute list changes, we need to check mute status on all impls.
@@ -500,7 +513,6 @@ void LLViewerMedia::muteListChanged()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::isInterestingEnough(const LLVOVolume *object, const F64 &object_interest)
 {
 	bool result = false;
@@ -535,6 +547,7 @@ LLViewerMedia::impl_list &LLViewerMedia::getPriorityList()
 	return sViewerMediaImplList;
 }
 
+// static
 // This is the predicate function used to sort sViewerMediaImplList by priority.
 bool LLViewerMedia::priorityComparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2)
 {
@@ -629,7 +642,12 @@ static LLTrace::BlockTimerStatHandle FTM_MEDIA_MISC("Misc");
 
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
+void LLViewerMedia::onIdle(void *dummy_arg)
+{
+    LLViewerMedia::getInstance()->updateMedia(dummy_arg);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
 void LLViewerMedia::updateMedia(void *dummy_arg)
 {
 	LL_RECORD_BLOCK_TIME(FTM_MEDIA_UPDATE);
@@ -642,8 +660,8 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	// removing it for now.
 	//createSpareBrowserMediaSource();
 
-	sAnyMediaShowing = false;
-	sAnyMediaPlaying = false;
+	mAnyMediaShowing = false;
+	mAnyMediaPlaying = false;
 
 	impl_list::iterator iter = sViewerMediaImplList.begin();
 	impl_list::iterator end = sViewerMediaImplList.end();
@@ -659,10 +677,10 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	}
 
 	// Let the spare media source actually launch
-	if(sSpareBrowserMediaSource)
+	if(mSpareBrowserMediaSource)
 	{
 		LL_RECORD_BLOCK_TIME(FTM_MEDIA_SPARE_IDLE);
-		sSpareBrowserMediaSource->idle();
+		mSpareBrowserMediaSource->idle();
 	}
 
 	{
@@ -854,7 +872,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 			if (!pimpl->getUsedInUI() && pimpl->hasMedia() && (pimpl->isMediaPlaying() || !pimpl->isMediaTimeBased()))
 			{
 				// consider visible non-timebased media as playing
-				sAnyMediaPlaying = true;
+				mAnyMediaPlaying = true;
 			}
 
 		}
@@ -899,21 +917,18 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::isAnyMediaShowing()
 {
-	return sAnyMediaShowing;
+	return mAnyMediaShowing;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::isAnyMediaPlaying()
 {
-    return sAnyMediaPlaying;
+    return mAnyMediaPlaying;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::setAllMediaEnabled(bool val)
 {
 	// Set "tentative" autoplay first.  We need to do this here or else
@@ -938,7 +953,7 @@ void LLViewerMedia::setAllMediaEnabled(bool val)
 	{
 		if (!LLViewerMedia::isParcelMediaPlaying() && LLViewerMedia::hasParcelMedia())
 		{
-			LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
+			LLViewerParcelMedia::getInstance()->play(LLViewerParcelMgr::getInstance()->getAgentParcel());
 		}
 
 		static LLCachedControl<bool> audio_streaming_music(gSavedSettings, "AudioStreamingMusic", true);
@@ -960,7 +975,7 @@ void LLViewerMedia::setAllMediaEnabled(bool val)
 	}
 	else {
 		// This actually unloads the impl, as opposed to "stop"ping the media
-		LLViewerParcelMedia::stop();
+		LLViewerParcelMedia::getInstance()->stop();
 		if (gAudiop)
 		{
 			LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade();
@@ -969,7 +984,6 @@ void LLViewerMedia::setAllMediaEnabled(bool val)
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::setAllMediaPaused(bool val)
 {
     // Set "tentative" autoplay first.  We need to do this here or else
@@ -1012,7 +1026,7 @@ void LLViewerMedia::setAllMediaPaused(bool val)
     {
         if (!LLViewerMedia::isParcelMediaPlaying() && LLViewerMedia::hasParcelMedia())
         {
-            LLViewerParcelMedia::play(agent_parcel);
+            LLViewerParcelMedia::getInstance()->play(LLViewerParcelMgr::getInstance()->getAgentParcel());
         }
 
         static LLCachedControl<bool> audio_streaming_music(gSavedSettings, "AudioStreamingMusic", true);
@@ -1034,7 +1048,7 @@ void LLViewerMedia::setAllMediaPaused(bool val)
     }
     else {
         // This actually unloads the impl, as opposed to "stop"ping the media
-        LLViewerParcelMedia::stop();
+        LLViewerParcelMedia::getInstance()->stop();
         if (gAudiop)
         {
             LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade();
@@ -1049,19 +1063,25 @@ void LLViewerMedia::setAllMediaPaused(bool val)
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::isParcelMediaPlaying()
 {
-	return (LLViewerMedia::hasParcelMedia() && LLViewerParcelMedia::getParcelMedia() && LLViewerParcelMedia::getParcelMedia()->hasMedia());
+    viewer_media_t media = LLViewerParcelMedia::getInstance()->getParcelMedia();
+    return (LLViewerMedia::hasParcelMedia() && media && media->hasMedia());
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::isParcelAudioPlaying()
 {
 	return (LLViewerMedia::hasParcelAudio() && gAudiop && LLAudioEngine::AUDIO_PLAYING == gAudiop->isInternetStreamPlaying());
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////
+// static
+void LLViewerMedia::authSubmitCallback(const LLSD& notification, const LLSD& response)
+{
+    LLViewerMedia::getInstance()->onAuthSubmit(notification, response);
+}
+
 void LLViewerMedia::onAuthSubmit(const LLSD& notification, const LLSD& response)
 {
 	LLViewerMediaImpl *impl = LLViewerMedia::getMediaImplFromTextureID(notification["payload"]["media_id"]);
@@ -1083,7 +1103,6 @@ void LLViewerMedia::onAuthSubmit(const LLSD& notification, const LLSD& response)
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::clearAllCookies()
 {
 	// Clear all cookies for all plugins
@@ -1100,7 +1119,6 @@ void LLViewerMedia::clearAllCookies()
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::clearAllCaches()
 {
 	// Clear all plugins' caches
@@ -1114,7 +1132,6 @@ void LLViewerMedia::clearAllCaches()
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::setCookiesEnabled(bool enabled)
 {
 	// Set the "cookies enabled" flag for all loaded plugins
@@ -1131,7 +1148,6 @@ void LLViewerMedia::setCookiesEnabled(bool enabled)
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::setProxyConfig(bool enable, const std::string &host, int port)
 {
 	// Set the proxy config for all loaded plugins
@@ -1148,10 +1164,6 @@ void LLViewerMedia::setProxyConfig(bool enable, const std::string &host, int por
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
-/////////////////////////////////////////////////////////////////////////////////////////
-//// static
-
 LLSD LLViewerMedia::getHeaders()
 {
 	LLSD headers = LLSD::emptyMap();
@@ -1159,14 +1171,13 @@ LLSD LLViewerMedia::getHeaders()
 	// *TODO: Should this be 'application/llsd+xml' ?
 	// *TODO: Should this even be set at all?   This header is only not overridden in 'GET' methods.
 	headers[HTTP_OUT_HEADER_CONTENT_TYPE] = HTTP_CONTENT_XML;
-	headers[HTTP_OUT_HEADER_COOKIE] = sOpenIDCookie;
+	headers[HTTP_OUT_HEADER_COOKIE] = mOpenIDCookie;
 	headers[HTTP_OUT_HEADER_USER_AGENT] = getCurrentUserAgent();
 
 	return headers;
 }
 
  /////////////////////////////////////////////////////////////////////////////////////////
- // static
 bool LLViewerMedia::parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path, bool& httponly, bool& secure)
 {
 	std::size_t name_pos = raw_cookie.find_first_of("=");
@@ -1189,13 +1200,14 @@ bool LLViewerMedia::parseRawCookie(const std::string raw_cookie, std::string& na
 	return false;
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////
 LLCore::HttpHeaders::ptr_t LLViewerMedia::getHttpHeaders()
 {
     LLCore::HttpHeaders::ptr_t headers(new LLCore::HttpHeaders);
 
     headers->append(HTTP_OUT_HEADER_ACCEPT, "*/*");
     headers->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML);
-    headers->append(HTTP_OUT_HEADER_COOKIE, sOpenIDCookie);
+    headers->append(HTTP_OUT_HEADER_COOKIE, mOpenIDCookie);
     headers->append(HTTP_OUT_HEADER_USER_AGENT, getCurrentUserAgent());
 
     return headers;
@@ -1203,10 +1215,9 @@ LLCore::HttpHeaders::ptr_t LLViewerMedia::getHttpHeaders()
 
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::setOpenIDCookie(const std::string& url)
 {
-	if(!sOpenIDCookie.empty())
+	if(!mOpenIDCookie.empty())
 	{
         std::string profileUrl = getProfileURL("");
 
@@ -1215,7 +1226,7 @@ void LLViewerMedia::setOpenIDCookie(const std::string& url)
 	}
 }
 
-/*static*/
+//static
 void LLViewerMedia::getOpenIDCookieCoro(std::string url)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
@@ -1237,7 +1248,7 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url)
     // The LLURL can give me the 'authority', which is of the form: [username[:password]@]hostname[:port]
     // We want just the hostname for the cookie code, but LLURL doesn't seem to have a way to extract that.
     // We therefore do it here.
-    std::string authority = sOpenIDURL.mAuthority;
+    std::string authority = getInstance()->mOpenIDURL.mAuthority;
     std::string::size_type hostStart = authority.find('@');
     if (hostStart == std::string::npos)
     {   // no username/password
@@ -1254,7 +1265,8 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url)
     {   // no port
         hostEnd = authority.size();
     }
-
+    
+	LLViewerMedia* inst = getInstance();
 	if (url.length())
 	{
 		LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild<LLMediaCtrl>("destination_guide_contents");
@@ -1266,8 +1278,8 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url)
 			std::string cookie_path = "";
 			bool httponly = true;
 			bool secure = true;
-			if (parseRawCookie(sOpenIDCookie, cookie_name, cookie_value, cookie_path, httponly, secure) &&
-                media_instance->getMediaPlugin())
+			if (inst->parseRawCookie(inst->mOpenIDCookie, cookie_name, cookie_value, cookie_path, httponly, secure) &&
+				media_instance->getMediaPlugin())
 			{
 				// MAINT-5711 - inexplicably, the CEF setCookie function will no longer set the cookie if the 
 				// url and domain are not the same. This used to be my.sl.com and id.sl.com respectively and worked.
@@ -1276,7 +1288,7 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url)
 				// (Feels like there must be a less dirty way to construct a URL from component LLURL parts)
 				// MAINT-6392 - Rider: Do not change, however, the original URI requested, since it is used further
 				// down.
-                std::string cefUrl(std::string(sOpenIDURL.mURI) + "://" + std::string(sOpenIDURL.mAuthority));
+				std::string cefUrl(std::string(inst->mOpenIDURL.mURI) + "://" + std::string(inst->mOpenIDURL.mAuthority));
 
 				media_instance->getMediaPlugin()->setCookie(cefUrl, cookie_name, cookie_value, cookie_host, cookie_path, httponly, secure);
 			}
@@ -1289,11 +1301,11 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url)
 
 	// Do a web profile get so we can store the cookie 
     httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*");
-    httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sOpenIDCookie);
-    httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, getCurrentUserAgent());
+    httpHeaders->append(HTTP_OUT_HEADER_COOKIE, inst->mOpenIDCookie);
+    httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, inst->getCurrentUserAgent());
 
     LL_DEBUGS("MediaAuth") << "Requesting " << url << LL_ENDL;
-    LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL;
+    LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << inst->mOpenIDCookie << "]" << LL_ENDL;
     
     LLSD result = httpAdapter->getRawAndSuspend(httpRequest, url, httpOpts, httpHeaders);
 
@@ -1322,7 +1334,6 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url)
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::openIDSetup(const std::string &openidUrl, const std::string &openidToken)
 {
 	LL_DEBUGS("MediaAuth") << "url = \"" << openidUrl << "\", token = \"" << openidToken << "\"" << LL_ENDL;
@@ -1331,7 +1342,6 @@ void LLViewerMedia::openIDSetup(const std::string &openidUrl, const std::string
         boost::bind(&LLViewerMedia::openIDSetupCoro, openidUrl, openidToken));
 }
 
-/*static*/
 void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidToken)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
@@ -1346,10 +1356,10 @@ void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidTok
 	// post the token to the url 
     // the responder will need to extract the cookie(s).
     // Save the OpenID URL for later -- we may need the host when adding the cookie.
-    sOpenIDURL.init(openidUrl.c_str());
+    getInstance()->mOpenIDURL.init(openidUrl.c_str());
 	
     // We shouldn't ever do this twice, but just in case this code gets repurposed later, clear existing cookies.
-    sOpenIDCookie.clear();
+    getInstance()->mOpenIDCookie.clear();
 
     httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*");
     httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/x-www-form-urlencoded");
@@ -1381,24 +1391,22 @@ void LLViewerMedia::openIDSetupCoro(std::string openidUrl, std::string openidTok
     const std::string& cookie = resultHeaders[HTTP_IN_HEADER_SET_COOKIE].asString();
 
 	// *TODO: What about bad status codes?  Does this destroy previous cookies?
-    LLViewerMedia::openIDCookieResponse(openidUrl, cookie);
+    LLViewerMedia::getInstance()->openIDCookieResponse(openidUrl, cookie);
     LL_DEBUGS("MediaAuth") << "OpenID cookie set." << LL_ENDL;
 			
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::openIDCookieResponse(const std::string& url, const std::string &cookie)
 {
 	LL_DEBUGS("MediaAuth") << "Cookie received: \"" << cookie << "\"" << LL_ENDL;
 
-	sOpenIDCookie += cookie;
+	mOpenIDCookie += cookie;
 
 	setOpenIDCookie(url);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::proxyWindowOpened(const std::string &target, const std::string &uuid)
 {
 	if(uuid.empty())
@@ -1414,7 +1422,6 @@ void LLViewerMedia::proxyWindowOpened(const std::string &target, const std::stri
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::proxyWindowClosed(const std::string &uuid)
 {
 	if(uuid.empty())
@@ -1430,28 +1437,26 @@ void LLViewerMedia::proxyWindowClosed(const std::string &uuid)
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::createSpareBrowserMediaSource()
 {
 	// If we don't have a spare browser media source, create one.
 	// However, if PluginAttachDebuggerToPlugins is set then don't spawn a spare
 	// SLPlugin process in order to not be confused by an unrelated gdb terminal
 	// popping up at the moment we start a media plugin.
-	if (!sSpareBrowserMediaSource && !gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"))
+	if (!mSpareBrowserMediaSource && !gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"))
 	{
 		// The null owner will keep the browser plugin from fully initializing
 		// (specifically, it keeps LLPluginClassMedia from negotiating a size change,
 		// which keeps MediaPluginWebkit::initBrowserWindow from doing anything until we have some necessary data, like the background color)
-		sSpareBrowserMediaSource = LLViewerMediaImpl::newSourceFromMediaType(HTTP_CONTENT_TEXT_HTML, NULL, 0, 0, 1.0);
+		mSpareBrowserMediaSource = LLViewerMediaImpl::newSourceFromMediaType(HTTP_CONTENT_TEXT_HTML, NULL, 0, 0, 1.0);
 	}
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// static
 LLPluginClassMedia* LLViewerMedia::getSpareBrowserMediaSource()
 {
-	LLPluginClassMedia* result = sSpareBrowserMediaSource;
-	sSpareBrowserMediaSource = NULL;
+	LLPluginClassMedia* result = mSpareBrowserMediaSource;
+	mSpareBrowserMediaSource = NULL;
 	return result;
 };
 
@@ -1473,50 +1478,24 @@ bool LLViewerMedia::hasInWorldMedia()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::hasParcelMedia()
 {
-	return !LLViewerParcelMedia::getURL().empty();
+	return !LLViewerParcelMedia::getInstance()->getURL().empty();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 bool LLViewerMedia::hasParcelAudio()
 {
 	return !LLViewerMedia::getParcelAudioURL().empty();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 std::string LLViewerMedia::getParcelAudioURL()
 {
 	return LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
-void LLViewerMedia::initClass()
-{
-	gIdleCallbacks.addFunction(LLViewerMedia::updateMedia, NULL);
-	sTeleportFinishConnection = LLViewerParcelMgr::getInstance()->
-		setTeleportFinishedCallback(boost::bind(&LLViewerMedia::onTeleportFinished));
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-// static
-void LLViewerMedia::cleanupClass()
-{
-	gIdleCallbacks.deleteFunction(LLViewerMedia::updateMedia, NULL);
-	sTeleportFinishConnection.disconnect();
-	if (sSpareBrowserMediaSource != NULL)
-	{
-		delete sSpareBrowserMediaSource;
-		sSpareBrowserMediaSource = NULL;
-	}
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::onTeleportFinished()
 {
 	// On teleport, clear this setting (i.e. set it to true)
@@ -1525,9 +1504,7 @@ void LLViewerMedia::onTeleportFinished()
 	LLViewerMediaImpl::sMimeTypesFailed.clear();
 }
 
-
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerMedia::setOnlyAudibleMediaTextureID(const LLUUID& texture_id)
 {
 	sOnlyAudibleTextureID = texture_id;
@@ -1719,7 +1696,7 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_
 	if ((plugin_basename == "media_plugin_cef") &&
         !gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins") && !clean_browser)
 	{
-		media_source = LLViewerMedia::getSpareBrowserMediaSource();
+		media_source = LLViewerMedia::getInstance()->getSpareBrowserMediaSource();
 		if(media_source)
 		{
 			media_source->setOwner(owner);
@@ -1795,7 +1772,7 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_
 			media_source->enableMediaPluginDebugging( media_plugin_debugging_enabled  || clean_browser);
 
 			// need to set agent string here before instance created
-			media_source->setBrowserUserAgent(LLViewerMedia::getCurrentUserAgent());
+			media_source->setBrowserUserAgent(LLViewerMedia::getInstance()->getCurrentUserAgent());
 
 			media_source->setTarget(target);
 
@@ -1866,7 +1843,7 @@ bool LLViewerMediaImpl::initializePlugin(const std::string& media_type)
 		media_source->setDisableTimeout(gSavedSettings.getBOOL("DebugPluginDisableTimeout"));
 		media_source->setLoop(mMediaLoop);
 		media_source->setAutoScale(mMediaAutoScale);
-		media_source->setBrowserUserAgent(LLViewerMedia::getCurrentUserAgent());
+		media_source->setBrowserUserAgent(LLViewerMedia::getInstance()->getCurrentUserAgent());
 		media_source->focus(mHasFocus);
 		media_source->setBackgroundColor(mBackgroundColor);
 
@@ -2099,7 +2076,7 @@ void LLViewerMediaImpl::updateVolume()
 	if(mMediaSource)
 	{
 		// always scale the volume by the global media volume
-		F32 volume = mRequestedVolume * LLViewerMedia::getVolume();
+		F32 volume = mRequestedVolume * LLViewerMedia::getInstance()->getVolume();
 
 		if (mProximityCamera > 0)
 		{
@@ -3373,7 +3350,7 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
 			auth_request_params.substitutions = args;
 
 			auth_request_params.payload = LLSD().with("media_id", mTextureId);
-			auth_request_params.functor.function = boost::bind(&LLViewerMedia::onAuthSubmit, _1, _2);
+			auth_request_params.functor.function = boost::bind(&LLViewerMedia::authSubmitCallback, _1, _2);
 			LLNotifications::instance().add(auth_request_params);
 		};
 		break;
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index 9896399774b81eedbbe47cdbfaa8b012a8cd81f9..9467a138f03733227dcbcf4b401b1d6fb32cbfe4 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -70,12 +70,16 @@ class LLViewerMediaEventEmitter
 
 class LLViewerMediaImpl;
 
-class LLViewerMedia
+class LLViewerMedia: public LLSingleton<LLViewerMedia>
 {
+	LLSINGLETON(LLViewerMedia);
+	~LLViewerMedia();
+	void initSingleton();
 	LOG_CLASS(LLViewerMedia);
+
 public:
-	
 	// String to get/set media autoplay in gSavedSettings
+    static const char* AUTO_PLAY_MEDIA_SETTING;
 	static const char* SHOW_MEDIA_ON_OTHERS_SETTING;
 	static const char* SHOW_MEDIA_WITHIN_PARCEL_SETTING;
 	static const char* SHOW_MEDIA_OUTSIDE_PARCEL_SETTING;
@@ -87,91 +91,93 @@ class LLViewerMedia
 	// Special case early init for just web browser component
 	// so we can show login screen.  See .cpp file for details. JC
 	
-	static viewer_media_t newMediaImpl(const LLUUID& texture_id,
+	viewer_media_t newMediaImpl(const LLUUID& texture_id,
 									   S32 media_width = 0, 
 									   S32 media_height = 0, 
 									   U8 media_auto_scale = false,
 									   U8 media_loop = false);
 	
-	static viewer_media_t updateMediaImpl(LLMediaEntry* media_entry, const std::string& previous_url, bool update_from_self);
-	static LLViewerMediaImpl* getMediaImplFromTextureID(const LLUUID& texture_id);
-	static std::string getCurrentUserAgent();
-	static void updateBrowserUserAgent();
-	static bool handleSkinCurrentChanged(const LLSD& /*newvalue*/);
-	static bool textureHasMedia(const LLUUID& texture_id);
-	static void setVolume(F32 volume);
+	viewer_media_t updateMediaImpl(LLMediaEntry* media_entry, const std::string& previous_url, bool update_from_self);
+	LLViewerMediaImpl* getMediaImplFromTextureID(const LLUUID& texture_id);
+	std::string getCurrentUserAgent();
+	void updateBrowserUserAgent();
+	bool handleSkinCurrentChanged(const LLSD& /*newvalue*/);
+	bool textureHasMedia(const LLUUID& texture_id);
+	void setVolume(F32 volume);
 	
 	// Is any media currently "showing"?  Includes Parcel Media.  Does not include media in the UI.
-	static bool isAnyMediaShowing();
+	bool isAnyMediaShowing();
 	// Shows if any media is playing, counts visible non time based media as playing. Does not include media in the UI.
-	static bool isAnyMediaPlaying();
+	bool isAnyMediaPlaying();
 	// Set all media enabled or disabled, depending on val.   Does not include media in the UI.
-	static void setAllMediaEnabled(bool val);
+	void setAllMediaEnabled(bool val);
 	// Set all media paused(stopped for non time based) or playing, depending on val.   Does not include media in the UI.
-	static void setAllMediaPaused(bool val);
+	void setAllMediaPaused(bool val);
 
-	static void updateMedia(void* dummy_arg = NULL);
-	
-	static void initClass();
-	static void cleanupClass();
-	
-	static F32 getVolume();	
-	static void muteListChanged();
-	static bool isInterestingEnough(const LLVOVolume* object, const F64 &object_interest);
+	static void onIdle(void* dummy_arg = NULL); // updateMedia wrapper
+	void updateMedia(void* dummy_arg = NULL);
+
+	F32 getVolume();	
+	void muteListChanged();
+	bool isInterestingEnough(const LLVOVolume* object, const F64 &object_interest);
 	
 	// Returns the priority-sorted list of all media impls.
-	static impl_list &getPriorityList();
+	impl_list &getPriorityList();
 	
 	// This is the comparitor used to sort the list.
 	static bool priorityComparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2);
 	
 	// These are just helper functions for the convenience of others working with media
-	static bool hasInWorldMedia();
-	static std::string getParcelAudioURL();
-	static bool hasParcelMedia();
-	static bool hasParcelAudio();
-	static bool isParcelMediaPlaying();
-	static bool isParcelAudioPlaying();
-	
-	static void onAuthSubmit(const LLSD& notification, const LLSD& response);
+	bool hasInWorldMedia();
+	std::string getParcelAudioURL();
+	bool hasParcelMedia();
+	bool hasParcelAudio();
+	bool isParcelMediaPlaying();
+	bool isParcelAudioPlaying();
+
+	static void authSubmitCallback(const LLSD& notification, const LLSD& response);
 
 	// Clear all cookies for all plugins
-	static void clearAllCookies();
+	void clearAllCookies();
 	
 	// Clear all plugins' caches
-	static void clearAllCaches();
+	void clearAllCaches();
 	
 	// Set the "cookies enabled" flag for all loaded plugins
-	static void setCookiesEnabled(bool enabled);
+	void setCookiesEnabled(bool enabled);
 	
 	// Set the proxy config for all loaded plugins
-	static void setProxyConfig(bool enable, const std::string &host, int port);
+	void setProxyConfig(bool enable, const std::string &host, int port);
 	
-	static void openIDSetup(const std::string &openid_url, const std::string &openid_token);
-	static void openIDCookieResponse(const std::string& url, const std::string &cookie);
+	void openIDSetup(const std::string &openid_url, const std::string &openid_token);
+	void openIDCookieResponse(const std::string& url, const std::string &cookie);
 	
-	static void proxyWindowOpened(const std::string &target, const std::string &uuid);
-	static void proxyWindowClosed(const std::string &uuid);
+	void proxyWindowOpened(const std::string &target, const std::string &uuid);
+	void proxyWindowClosed(const std::string &uuid);
 	
-	static void createSpareBrowserMediaSource();
-	static LLPluginClassMedia* getSpareBrowserMediaSource();
+	void createSpareBrowserMediaSource();
+	LLPluginClassMedia* getSpareBrowserMediaSource();
 
-	static void setOnlyAudibleMediaTextureID(const LLUUID& texture_id);
+	void setOnlyAudibleMediaTextureID(const LLUUID& texture_id);
 
-	static LLSD getHeaders();
-    static LLCore::HttpHeaders::ptr_t getHttpHeaders();
+	LLSD getHeaders();
+	LLCore::HttpHeaders::ptr_t getHttpHeaders();
 	
 private:
-	static bool parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path, bool& httponly, bool& secure);
-	static void setOpenIDCookie(const std::string& url);
-	static void onTeleportFinished();
-
-    static void openIDSetupCoro(std::string openidUrl, std::string openidToken);
-    static void getOpenIDCookieCoro(std::string url);
-
-	static LLURL sOpenIDURL;
-	static std::string sOpenIDCookie;
-	static LLPluginClassMedia* sSpareBrowserMediaSource;
+	void onAuthSubmit(const LLSD& notification, const LLSD& response);
+	bool parseRawCookie(const std::string raw_cookie, std::string& name, std::string& value, std::string& path, bool& httponly, bool& secure);
+	void setOpenIDCookie(const std::string& url);
+	void onTeleportFinished();
+
+	static void openIDSetupCoro(std::string openidUrl, std::string openidToken);
+	static void getOpenIDCookieCoro(std::string url);
+
+	bool mAnyMediaShowing;
+	bool mAnyMediaPlaying;
+	LLURL mOpenIDURL;
+	std::string mOpenIDCookie;
+	LLPluginClassMedia* mSpareBrowserMediaSource;
+	boost::signals2::connection mTeleportFinishConnection;
 };
 
 // Implementation functions not exported into header file
diff --git a/indra/newview/llviewermediafocus.cpp b/indra/newview/llviewermediafocus.cpp
index b86d678196239ea784b15ba92ca7c77f8db7b886..69ab0a71af459ecc9abe6e44ddd16faac300ddb4 100644
--- a/indra/newview/llviewermediafocus.cpp
+++ b/indra/newview/llviewermediafocus.cpp
@@ -339,12 +339,12 @@ BOOL LLViewerMediaFocus::handleKey(KEY key, MASK mask, BOOL called_from_parent)
 			clearFocus();
 		}
 		
-		if ( KEY_F1 == key && LLUI::sHelpImpl && mMediaControls.get())
+		if ( KEY_F1 == key && LLUI::getInstance()->mHelpImpl && mMediaControls.get())
 		{
 			std::string help_topic;
 			if (mMediaControls.get()->findHelpTopic(help_topic))
 			{
-				LLUI::sHelpImpl->showTopic(help_topic);
+				LLUI::getInstance()->mHelpImpl->showTopic(help_topic);
 			}
 		}
 	}
@@ -532,7 +532,7 @@ bool LLViewerMediaFocus::isHoveringOverFace(LLPointer<LLViewerObject> objectp, S
 
 LLViewerMediaImpl* LLViewerMediaFocus::getFocusedMediaImpl()
 {
-	return LLViewerMedia::getMediaImplFromTextureID(mFocusedImplID);
+	return LLViewerMedia::getInstance()->getMediaImplFromTextureID(mFocusedImplID);
 }
 
 LLViewerObject* LLViewerMediaFocus::getFocusedObject()
@@ -542,7 +542,7 @@ LLViewerObject* LLViewerMediaFocus::getFocusedObject()
 
 LLViewerMediaImpl* LLViewerMediaFocus::getHoverMediaImpl()
 {
-	return LLViewerMedia::getMediaImplFromTextureID(mHoverImplID);
+	return LLViewerMedia::getInstance()->getMediaImplFromTextureID(mHoverImplID);
 }
 
 LLViewerObject* LLViewerMediaFocus::getHoverObject()
@@ -552,7 +552,7 @@ LLViewerObject* LLViewerMediaFocus::getHoverObject()
 
 void LLViewerMediaFocus::focusZoomOnMedia(LLUUID media_id)
 {
-	LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(media_id);
+	LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(media_id);
 	
 	if(impl)
 	{	
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 8ef37b91439647e7161cc42180058580debed5be..f859ced3425d0c82e943cf31b8d69f0a73967e93 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -6275,7 +6275,7 @@ void dump_inventory(void*)
 
 void handle_dump_followcam(void*)
 {
-	LLFollowCamMgr::dump();
+	LLFollowCamMgr::getInstance()->dump();
 }
 
 void handle_viewer_enable_message_log(void*)
@@ -6837,7 +6837,7 @@ class LLAttachmentDetachFromPoint : public view_listener_t
 				 iter != attachment->mAttachedObjects.end();
 				 iter++)
 			{
-				LLViewerObject *attached_object = (*iter);
+				LLViewerObject *attached_object = iter->get();
 				ids_to_remove.push_back(attached_object->getAttachmentItemID());
 			}
         }
@@ -6863,7 +6863,7 @@ static bool onEnableAttachmentLabel(LLUICtrl* ctrl, const LLSD& data)
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				const LLViewerObject* attached_object = (*attachment_iter);
+				const LLViewerObject* attached_object = attachment_iter->get();
 				if (attached_object)
 				{
 					LLViewerInventoryItem* itemp = gInventory.getItem(attached_object->getAttachmentItemID());
@@ -6976,7 +6976,7 @@ class LLAttachmentEnableDrop : public view_listener_t
 				{
 					// make sure item is in your inventory (it could be a delayed attach message being sent from the sim)
 					// so check to see if the item is in the inventory already
-					item = gInventory.getItem((*attachment_iter)->getAttachmentItemID());
+					item = gInventory.getItem(attachment_iter->get()->getAttachmentItemID());
 					if (!item)
 					{
 						// Item does not exist, make an observer to enable the pie menu 
@@ -7358,7 +7358,7 @@ void handle_dump_attachments(void*)
 			 attachment_iter != attachment->mAttachedObjects.end();
 			 ++attachment_iter)
 		{
-			LLViewerObject *attached_object = (*attachment_iter);
+			LLViewerObject *attached_object = attachment_iter->get();
 			BOOL visible = (attached_object != NULL &&
 							attached_object->mDrawable.notNull() && 
 							!attached_object->mDrawable->isRenderType(0));
@@ -8653,7 +8653,6 @@ class LLWorldPostProcess : public view_listener_t
 
 void handle_flush_name_caches()
 {
-	SUBSYSTEM_CLEANUP(LLAvatarNameCache);
 	if (gCacheName) gCacheName->clear();
 }
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 3998a6af15ebda3f74d1bb8418081e0d76a67c2b..3dd2f402fee9e8e632b22f4671ee3357a80f5d5a 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4266,7 +4266,7 @@ void process_clear_follow_cam_properties(LLMessageSystem *mesgsys, void **user_d
 
 	mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, source_id);
 
-	LLFollowCamMgr::removeFollowCamParams(source_id);
+	LLFollowCamMgr::getInstance()->removeFollowCamParams(source_id);
 }
 
 void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_data)
@@ -4298,7 +4298,7 @@ void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_dat
 		switch(type)
 		{
 		case FOLLOWCAM_PITCH:
-			LLFollowCamMgr::setPitch(source_id, value);
+			LLFollowCamMgr::getInstance()->setPitch(source_id, value);
 			break;
 		case FOLLOWCAM_FOCUS_OFFSET_X:
 			focus_offset.mV[VX] = value;
@@ -4313,29 +4313,29 @@ void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_dat
 			settingFocusOffset = true;
 			break;
 		case FOLLOWCAM_POSITION_LAG:
-			LLFollowCamMgr::setPositionLag(source_id, value);
+			LLFollowCamMgr::getInstance()->setPositionLag(source_id, value);
 			break;
 		case FOLLOWCAM_FOCUS_LAG:
-			LLFollowCamMgr::setFocusLag(source_id, value);
+			LLFollowCamMgr::getInstance()->setFocusLag(source_id, value);
 			break;
 		case FOLLOWCAM_DISTANCE:
-			LLFollowCamMgr::setDistance(source_id, value);
+			LLFollowCamMgr::getInstance()->setDistance(source_id, value);
 			break;
 		case FOLLOWCAM_BEHINDNESS_ANGLE:
-			LLFollowCamMgr::setBehindnessAngle(source_id, value);
+			LLFollowCamMgr::getInstance()->setBehindnessAngle(source_id, value);
 			break;
 		case FOLLOWCAM_BEHINDNESS_LAG:
-			LLFollowCamMgr::setBehindnessLag(source_id, value);
+			LLFollowCamMgr::getInstance()->setBehindnessLag(source_id, value);
 			break;
 		case FOLLOWCAM_POSITION_THRESHOLD:
-			LLFollowCamMgr::setPositionThreshold(source_id, value);
+			LLFollowCamMgr::getInstance()->setPositionThreshold(source_id, value);
 			break;
 		case FOLLOWCAM_FOCUS_THRESHOLD:
-			LLFollowCamMgr::setFocusThreshold(source_id, value);
+			LLFollowCamMgr::getInstance()->setFocusThreshold(source_id, value);
 			break;
 		case FOLLOWCAM_ACTIVE:
 			//if 1, set using followcam,. 
-			LLFollowCamMgr::setCameraActive(source_id, value != 0.f);
+			LLFollowCamMgr::getInstance()->setCameraActive(source_id, value != 0.f);
 			break;
 		case FOLLOWCAM_POSITION_X:
 			settingPosition = true;
@@ -4362,10 +4362,10 @@ void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_dat
 			focus.mV[ 2 ] = value;
 			break;
 		case FOLLOWCAM_POSITION_LOCKED:
-			LLFollowCamMgr::setPositionLocked(source_id, value != 0.f);
+			LLFollowCamMgr::getInstance()->setPositionLocked(source_id, value != 0.f);
 			break;
 		case FOLLOWCAM_FOCUS_LOCKED:
-			LLFollowCamMgr::setFocusLocked(source_id, value != 0.f);
+			LLFollowCamMgr::getInstance()->setFocusLocked(source_id, value != 0.f);
 			break;
 
 		default:
@@ -4375,15 +4375,15 @@ void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_dat
 
 	if ( settingPosition )
 	{
-		LLFollowCamMgr::setPosition(source_id, position);
+		LLFollowCamMgr::getInstance()->setPosition(source_id, position);
 	}
 	if ( settingFocus )
 	{
-		LLFollowCamMgr::setFocus(source_id, focus);
+		LLFollowCamMgr::getInstance()->setFocus(source_id, focus);
 	}
 	if ( settingFocusOffset )
 	{
-		LLFollowCamMgr::setFocusOffset(source_id, focus_offset);
+		LLFollowCamMgr::getInstance()->setFocusOffset(source_id, focus_offset);
 	}
 }
 //end Ventrella 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bc0a151670bd5a5920c63bb018ceaff63b6d08f1..05230c17e0421bae9dd161c4b33cc44bd669c97e 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -487,7 +487,7 @@ void LLViewerObject::markDead()
 
 		if (flagCameraSource())
 		{
-			LLFollowCamMgr::removeFollowCamParams(mID);
+			LLFollowCamMgr::getInstance()->removeFollowCamParams(mID);
 		}
 
 		sNumZombieObjects++;
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 2bf04dc20476e8517f62acd2988f4ee9cca465bf..63e48d1dd090e18cb5e208654e91d96e2dce85ce 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1921,7 +1921,7 @@ void LLViewerObjectList::generatePickList(LLCamera &camera)
 						 attachment_iter != attachment->mAttachedObjects.end();
 						 ++attachment_iter)
 					{
-						if (LLViewerObject* attached_object = (*attachment_iter))
+						if (LLViewerObject* attached_object = attachment_iter->get())
 						{
 							mSelectPickList.insert(attached_object);
 							LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
diff --git a/indra/newview/llviewerparcelmedia.cpp b/indra/newview/llviewerparcelmedia.cpp
index d31fc0d6069c92b791e1c1f8fe93ca901a415420..b1b5275f826bcb510df5c3cf8f019e23468eb120 100644
--- a/indra/newview/llviewerparcelmedia.cpp
+++ b/indra/newview/llviewerparcelmedia.cpp
@@ -45,31 +45,22 @@
 #include "llviewertexture.h"
 #include "llcorehttputil.h"
 
-// Static Variables
 
-S32 LLViewerParcelMedia::sMediaParcelLocalID = 0;
-LLUUID LLViewerParcelMedia::sMediaRegionID;
-viewer_media_t LLViewerParcelMedia::sMediaImpl;
-
-
-// static
-void LLViewerParcelMedia::initClass()
+LLViewerParcelMedia::LLViewerParcelMedia():
+mMediaParcelLocalID(0)
 {
 	LLMessageSystem* msg = gMessageSystem;
-	msg->setHandlerFunc("ParcelMediaCommandMessage", processParcelMediaCommandMessage );
-	msg->setHandlerFunc("ParcelMediaUpdate", processParcelMediaUpdate );
-	LLViewerParcelMediaAutoPlay::initClass();
+	msg->setHandlerFunc("ParcelMediaCommandMessage", parcelMediaCommandMessageHandler );
+	msg->setHandlerFunc("ParcelMediaUpdate", parcelMediaUpdateHandler );
 }
 
-//static 
-void LLViewerParcelMedia::cleanupClass()
+LLViewerParcelMedia::~LLViewerParcelMedia()
 {
 	// This needs to be destroyed before global destructor time.
-	sMediaImpl = NULL;
+	mMediaImpl = NULL;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-// static
 void LLViewerParcelMedia::update(LLParcel* parcel)
 {
 	if (/*LLViewerMedia::hasMedia()*/ true)
@@ -79,7 +70,7 @@ void LLViewerParcelMedia::update(LLParcel* parcel)
 		{
 			if(!gAgent.getRegion())
 			{
-				sMediaRegionID = LLUUID() ;
+				mMediaRegionID = LLUUID() ;
 				stop() ;
 				LL_DEBUGS("Media") << "no agent region, bailing out." << LL_ENDL;
 				return ;				
@@ -89,11 +80,11 @@ void LLViewerParcelMedia::update(LLParcel* parcel)
 			S32 parcelid = parcel->getLocalID();						
 
 			LLUUID regionid = gAgent.getRegion()->getRegionID();
-			if (parcelid != sMediaParcelLocalID || regionid != sMediaRegionID)
+			if (parcelid != mMediaParcelLocalID || regionid != mMediaRegionID)
 			{
 				LL_DEBUGS("Media") << "New parcel, parcel id = " << parcelid << ", region id = " << regionid << LL_ENDL;
-				sMediaParcelLocalID = parcelid;
-				sMediaRegionID = regionid;
+				mMediaParcelLocalID = parcelid;
+				mMediaRegionID = regionid;
 			}
 
 			std::string mediaUrl = std::string ( parcel->getMediaURL () );
@@ -108,19 +99,19 @@ void LLViewerParcelMedia::update(LLParcel* parcel)
 			LLStringUtil::trim(mediaUrl);
 			
 			// If no parcel media is playing, nothing left to do
-			if(sMediaImpl.isNull())
+			if(mMediaImpl.isNull())
 
 			{
 				return;
 			}
 
 			// Media is playing...has something changed?
-			else if (( sMediaImpl->getMediaURL() != mediaUrl )
-				|| ( sMediaImpl->getMediaTextureID() != parcel->getMediaID() )
-				|| ( sMediaImpl->getMimeType() != parcel->getMediaType() ))
+			else if (( mMediaImpl->getMediaURL() != mediaUrl )
+				|| ( mMediaImpl->getMediaTextureID() != parcel->getMediaID() )
+				|| ( mMediaImpl->getMimeType() != parcel->getMediaType() ))
 			{
 				// Only play if the media types are the same.
-				if(sMediaImpl->getMimeType() == parcel->getMediaType())
+				if(mMediaImpl->getMimeType() == parcel->getMediaType())
 				{
 					play(parcel);
 				}
@@ -176,30 +167,30 @@ void LLViewerParcelMedia::play(LLParcel* parcel)
 	S32 media_width = parcel->getMediaWidth();
 	S32 media_height = parcel->getMediaHeight();
 
-	if(sMediaImpl)
+	if(mMediaImpl)
 	{
 		// If the url and mime type are the same, call play again
-		if(sMediaImpl->getMediaURL() == media_url 
-			&& sMediaImpl->getMimeType() == mime_type
-			&& sMediaImpl->getMediaTextureID() == placeholder_texture_id)
+		if(mMediaImpl->getMediaURL() == media_url 
+			&& mMediaImpl->getMimeType() == mime_type
+			&& mMediaImpl->getMediaTextureID() == placeholder_texture_id)
 		{
 			LL_DEBUGS("Media") << "playing with existing url " << media_url << LL_ENDL;
 
-			sMediaImpl->play();
+			mMediaImpl->play();
 		}
 		// Else if the texture id's are the same, navigate and rediscover type
 		// MBW -- This causes other state from the previous parcel (texture size, autoscale, and looping) to get re-used incorrectly.
 		// It's also not really necessary -- just creating a new instance is fine.
-//		else if(sMediaImpl->getMediaTextureID() == placeholder_texture_id)
+//		else if(mMediaImpl->getMediaTextureID() == placeholder_texture_id)
 //		{
-//			sMediaImpl->navigateTo(media_url, mime_type, true);
+//			mMediaImpl->navigateTo(media_url, mime_type, true);
 //		}
 		else
 		{
 			// Since the texture id is different, we need to generate a new impl
 
 			// Delete the old one first so they don't fight over the texture.
-			sMediaImpl = NULL;
+			mMediaImpl = NULL;
 			
 			// A new impl will be created below.
 		}
@@ -208,19 +199,19 @@ void LLViewerParcelMedia::play(LLParcel* parcel)
 	// Don't ever try to play if the media type is set to "none/none"
 	if(stricmp(mime_type.c_str(), LLMIMETypes::getDefaultMimeType().c_str()) != 0)
 	{
-		if(!sMediaImpl)
+		if(!mMediaImpl)
 		{
 			LL_DEBUGS("Media") << "new media impl with mime type " << mime_type << ", url " << media_url << LL_ENDL;
 
 			// There is no media impl, make a new one
-			sMediaImpl = LLViewerMedia::newMediaImpl(
+			mMediaImpl = LLViewerMedia::getInstance()->newMediaImpl(
 				placeholder_texture_id,
 				media_width, 
 				media_height, 
 				media_auto_scale,
 				media_loop);
-			sMediaImpl->setIsParcelMedia(true);
-			sMediaImpl->navigateTo(media_url, mime_type, true);
+			mMediaImpl->setIsParcelMedia(true);
+			mMediaImpl->navigateTo(media_url, mime_type, true);
 		}
 
 		//LLFirstUse::useMedia();
@@ -232,7 +223,7 @@ void LLViewerParcelMedia::play(LLParcel* parcel)
 // static
 void LLViewerParcelMedia::stop()
 {
-	if(sMediaImpl.isNull())
+	if(mMediaImpl.isNull())
 	{
 		return;
 	}
@@ -241,27 +232,27 @@ void LLViewerParcelMedia::stop()
 	LLViewerMediaFocus::getInstance()->clearFocus();
 
 	// This will unload & kill the media instance.
-	sMediaImpl = NULL;
+	mMediaImpl = NULL;
 }
 
 // static
 void LLViewerParcelMedia::pause()
 {
-	if(sMediaImpl.isNull())
+	if(mMediaImpl.isNull())
 	{
 		return;
 	}
-	sMediaImpl->pause();
+	mMediaImpl->pause();
 }
 
 // static
 void LLViewerParcelMedia::start()
 {
-	if(sMediaImpl.isNull())
+	if(mMediaImpl.isNull())
 	{
 		return;
 	}
-	sMediaImpl->start();
+	mMediaImpl->start();
 
 	//LLFirstUse::useMedia();
 
@@ -271,17 +262,17 @@ void LLViewerParcelMedia::start()
 // static
 void LLViewerParcelMedia::seek(F32 time)
 {
-	if(sMediaImpl.isNull())
+	if(mMediaImpl.isNull())
 	{
 		return;
 	}
-	sMediaImpl->seek(time);
+	mMediaImpl->seek(time);
 }
 
 // static
 void LLViewerParcelMedia::focus(bool focus)
 {
-	sMediaImpl->focus(focus);
+	mMediaImpl->focus(focus);
 }
 
 // static
@@ -289,9 +280,9 @@ LLPluginClassMediaOwner::EMediaStatus LLViewerParcelMedia::getStatus()
 {	
 	LLPluginClassMediaOwner::EMediaStatus result = LLPluginClassMediaOwner::MEDIA_NONE;
 	
-	if(sMediaImpl.notNull() && sMediaImpl->hasMedia())
+	if(mMediaImpl.notNull() && mMediaImpl->hasMedia())
 	{
-		result = sMediaImpl->getMediaPlugin()->getStatus();
+		result = mMediaImpl->getMediaPlugin()->getStatus();
 	}
 	
 	return result;
@@ -300,15 +291,15 @@ LLPluginClassMediaOwner::EMediaStatus LLViewerParcelMedia::getStatus()
 // static
 std::string LLViewerParcelMedia::getMimeType()
 {
-	return sMediaImpl.notNull() ? sMediaImpl->getMimeType() : LLMIMETypes::getDefaultMimeType();
+	return mMediaImpl.notNull() ? mMediaImpl->getMimeType() : LLMIMETypes::getDefaultMimeType();
 }
 
 //static 
 std::string LLViewerParcelMedia::getURL()
 {
 	std::string url;
-	if(sMediaImpl.notNull())
-		url = sMediaImpl->getMediaURL();
+	if(mMediaImpl.notNull())
+		url = mMediaImpl->getMediaURL();
 	
 	if(stricmp(LLViewerParcelMgr::getInstance()->getAgentParcel()->getMediaType().c_str(), LLMIMETypes::getDefaultMimeType().c_str()) != 0)
 	{
@@ -325,19 +316,24 @@ std::string LLViewerParcelMedia::getURL()
 //static 
 std::string LLViewerParcelMedia::getName()
 {
-	if(sMediaImpl.notNull())
-		return sMediaImpl->getName();
+	if(mMediaImpl.notNull())
+		return mMediaImpl->getName();
 	return "";
 }
 
 viewer_media_t LLViewerParcelMedia::getParcelMedia()
 {
-	return sMediaImpl;
+	return mMediaImpl;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 // static
-void LLViewerParcelMedia::processParcelMediaCommandMessage( LLMessageSystem *msg, void ** )
+void LLViewerParcelMedia::parcelMediaCommandMessageHandler(LLMessageSystem *msg, void **)
+{
+    getInstance()->processParcelMediaCommandMessage(msg);
+}
+
+void LLViewerParcelMedia::processParcelMediaCommandMessage( LLMessageSystem *msg)
 {
 	// extract the agent id
 	//	LLUUID agent_id;
@@ -392,7 +388,7 @@ void LLViewerParcelMedia::processParcelMediaCommandMessage( LLMessageSystem *msg
 
 	if (flags & (1<<PARCEL_MEDIA_COMMAND_TIME))
 	{
-		if(sMediaImpl.isNull())
+		if(mMediaImpl.isNull())
 		{
 			LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
 			play(parcel);
@@ -403,7 +399,12 @@ void LLViewerParcelMedia::processParcelMediaCommandMessage( LLMessageSystem *msg
 
 //////////////////////////////////////////////////////////////////////////////////////////
 // static
-void LLViewerParcelMedia::processParcelMediaUpdate( LLMessageSystem *msg, void ** )
+void LLViewerParcelMedia::parcelMediaUpdateHandler(LLMessageSystem *msg, void **)
+{
+    getInstance()->processParcelMediaUpdate(msg);
+}
+
+void LLViewerParcelMedia::processParcelMediaUpdate( LLMessageSystem *msg)
 {
 	LLUUID media_id;
 	std::string media_url;
diff --git a/indra/newview/llviewerparcelmedia.h b/indra/newview/llviewerparcelmedia.h
index 534f65b4193795f4f045e0eaffa73f7d6e31c04d..779a65bdf83a5cb239b485e2379bc21ec2675658 100644
--- a/indra/newview/llviewerparcelmedia.h
+++ b/indra/newview/llviewerparcelmedia.h
@@ -37,50 +37,53 @@ class LLViewerParcelMediaNavigationObserver;
 // This class understands land parcels, network traffic, LSL media
 // transport commands, and talks to the LLViewerMedia class to actually
 // do playback.  It allows us to remove code from LLViewerParcelMgr.
-class LLViewerParcelMedia : public LLViewerMediaObserver
+class LLViewerParcelMedia : public LLViewerMediaObserver, public LLSingleton<LLViewerParcelMedia>
 {
+	LLSINGLETON(LLViewerParcelMedia);
+	~LLViewerParcelMedia();
 	LOG_CLASS(LLViewerParcelMedia);
-	public:
-		static void initClass();
-		static void cleanupClass();
-
-		static void update(LLParcel* parcel);
-			// called when the agent's parcel has a new URL, or the agent has
-			// walked on to a new parcel with media
-
-		static void play(LLParcel* parcel);
-			// user clicked play button in media transport controls
-
-		static void stop();
-			// user clicked stop button in media transport controls
-
-		static void pause();
-		static void start();
-			// restart after pause - no need for all the setup
-
-		static void focus(bool focus);
-
-		static void seek(F32 time);
-		    // jump to timecode time
-
-		static LLPluginClassMediaOwner::EMediaStatus getStatus();
-		static std::string getMimeType();
-		static std::string getURL();
-		static std::string getName();
-		static viewer_media_t getParcelMedia();
-
-		static void processParcelMediaCommandMessage( LLMessageSystem *msg, void ** );
-		static void processParcelMediaUpdate( LLMessageSystem *msg, void ** );
-		static void sendMediaNavigateMessage(const std::string& url);
-		
-		// inherited from LLViewerMediaObserver
-		virtual void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event);
-
-	public:
-		static S32 sMediaParcelLocalID;
-		static LLUUID sMediaRegionID;
-		// HACK: this will change with Media on a Prim
-		static viewer_media_t sMediaImpl;
+public:
+	void update(LLParcel* parcel);
+	// called when the agent's parcel has a new URL, or the agent has
+	// walked on to a new parcel with media
+
+	void play(LLParcel* parcel);
+	// user clicked play button in media transport controls
+
+	void stop();
+	// user clicked stop button in media transport controls
+
+	void pause();
+	void start();
+	// restart after pause - no need for all the setup
+
+	void focus(bool focus);
+
+	void seek(F32 time);
+	// jump to timecode time
+
+	LLPluginClassMediaOwner::EMediaStatus getStatus();
+	std::string getMimeType();
+	std::string getURL();
+	std::string getName();
+	viewer_media_t getParcelMedia();
+	bool hasParcelMedia() { return mMediaImpl.notNull(); }
+
+	static void parcelMediaCommandMessageHandler( LLMessageSystem *msg, void ** );
+	static void parcelMediaUpdateHandler( LLMessageSystem *msg, void ** );
+	void sendMediaNavigateMessage(const std::string& url);
+
+	// inherited from LLViewerMediaObserver
+	virtual void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event);
+
+private:
+	void processParcelMediaCommandMessage(LLMessageSystem *msg);
+	void processParcelMediaUpdate(LLMessageSystem *msg);
+
+	S32 mMediaParcelLocalID;
+	LLUUID mMediaRegionID;
+	// HACK: this will change with Media on a Prim
+	viewer_media_t mMediaImpl;
 };
 
 
diff --git a/indra/newview/llviewerparcelmediaautoplay.cpp b/indra/newview/llviewerparcelmediaautoplay.cpp
index b4dc6932beb2129763cc7ed57b030362b27e08ec..36c7d436f6abaa131b9a9f1c89d7548ba95cf43e 100644
--- a/indra/newview/llviewerparcelmediaautoplay.cpp
+++ b/indra/newview/llviewerparcelmediaautoplay.cpp
@@ -54,29 +54,10 @@ LLViewerParcelMediaAutoPlay::LLViewerParcelMediaAutoPlay() :
 {
 }
 
-static LLViewerParcelMediaAutoPlay *sAutoPlay = NULL;
-
-// static
-void LLViewerParcelMediaAutoPlay::initClass()
-{
-	if (!sAutoPlay)
-		sAutoPlay = new LLViewerParcelMediaAutoPlay;
-}
-
-// static
-void LLViewerParcelMediaAutoPlay::cleanupClass()
-{
-	if (sAutoPlay)
-		delete sAutoPlay;
-}
-
 // static
 void LLViewerParcelMediaAutoPlay::playStarted()
 {
-	if (sAutoPlay)
-	{
-		sAutoPlay->mPlayed = TRUE;
-	}
+    LLSingleton<LLViewerParcelMediaAutoPlay>::getInstance()->mPlayed = TRUE;
 }
 
 BOOL LLViewerParcelMediaAutoPlay::tick()
@@ -125,7 +106,7 @@ BOOL LLViewerParcelMediaAutoPlay::tick()
 		(mTimeInParcel > AUTOPLAY_TIME) &&		// and if we've been here for so many seconds
 		(!this_media_url.empty()) &&			// and if the parcel has media
 		(stricmp(this_media_type.c_str(), LLMIMETypes::getDefaultMimeType().c_str()) != 0) &&
-		(LLViewerParcelMedia::sMediaImpl.isNull()))	// and if the media is not already playing
+		(!LLViewerParcelMedia::getInstance()->hasParcelMedia()))	// and if the media is not already playing
 	{
 		if (this_media_texture_id.notNull())	// and if the media texture is good
 		{
@@ -153,7 +134,7 @@ BOOL LLViewerParcelMediaAutoPlay::tick()
 								break;
 							case 1:
 								// Play, default value for ParcelMediaAutoPlayEnable
-								LLViewerParcelMedia::play(this_parcel);
+								LLViewerParcelMedia::getInstance()->play(this_parcel);
 								break;
 							case 2:
 							default:
@@ -188,7 +169,7 @@ void LLViewerParcelMediaAutoPlay::onStartMusicResponse(const LLUUID &region_id,
         // make sure we are still there
         if (parcel->getLocalID() == parcel_id && gAgent.getRegion()->getRegionID() == region_id)
         {
-            LLViewerParcelMedia::play(parcel);
+            LLViewerParcelMedia::getInstance()->play(parcel);
         }
     }
 }
diff --git a/indra/newview/llviewerparcelmediaautoplay.h b/indra/newview/llviewerparcelmediaautoplay.h
index a404f60da105812d640aaad76d346619d78a4eab..cf8e9a97e76149346c1ab932bf930a795de9b40d 100644
--- a/indra/newview/llviewerparcelmediaautoplay.h
+++ b/indra/newview/llviewerparcelmediaautoplay.h
@@ -31,13 +31,11 @@
 #include "lluuid.h"
 
 // timer to automatically play media
-class LLViewerParcelMediaAutoPlay : LLEventTimer
+class LLViewerParcelMediaAutoPlay : LLEventTimer, public LLSingleton<LLViewerParcelMediaAutoPlay>
 {
- public:
-	LLViewerParcelMediaAutoPlay();
+	LLSINGLETON(LLViewerParcelMediaAutoPlay);
+public:
 	virtual BOOL tick();
-	static void initClass();
-	static void cleanupClass();
 	static void playStarted();
 
  private:
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index 86cdf96e21a2c68033a86a283586e0429da9fb62..d91d0abb991ecb81f4b7e5457a50935f48531287 100644
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -1823,7 +1823,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
 	else
 	{
 		// Check for video
-		LLViewerParcelMedia::update(parcel);
+		LLViewerParcelMedia::getInstance()->update(parcel);
 
 		// Then check for music
 		if (gAudiop)
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 5b227c641bcaf6273feae67e39119fedff736edb..75e707aaa392e0473cf8f15dd5ed4c23079c1405 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2895,8 +2895,6 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
 	capabilityNames.append("EstateAccess");
 	capabilityNames.append("EstateChangeInfo");
 	capabilityNames.append("EventQueueGet");
-	capabilityNames.append("FlickrConnect");
-	capabilityNames.append("TwitterConnect");
 
 	capabilityNames.append("FetchLib2");
 	capabilityNames.append("FetchLibDescendents2");
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 7d2d6e25c79ed08d8314408e49bfb49bae9c76a1..0e181bf53d838d8d35190e4a287e5ff4e4ec3594 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -239,7 +239,7 @@ class LLEmbeddedItemSegment : public LLTextSegment
 
 	/*virtual*/ BOOL			handleHover(S32 x, S32 y, MASK mask)
 	{
-		LLUI::getWindow()->setCursor(UI_CURSOR_HAND);
+		LLUI::getInstance()->getWindow()->setCursor(UI_CURSOR_HAND);
 		return TRUE;
 	}
 	virtual BOOL				handleToolTip(S32 x, S32 y, MASK mask )
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 93562cfab23b9d4becf9afbf5831328b4df14d91..305f891a86a2ee3c80dce32563f56462a0d38060 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -3459,7 +3459,7 @@ void LLViewerMediaTexture::setMediaImpl()
 {
 	if(!mMediaImplp)
 	{
-		mMediaImplp = LLViewerMedia::getMediaImplFromTextureID(mID);
+		mMediaImplp = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mID);
 	}
 }
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 1e2b2c37d06f0bcbb2af83398861b0af1cb5134d..a92c804442a1a44f55af8d6111cacd4f6ded97fd 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -966,7 +966,7 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 			mWindow->releaseMouse();
 
 		// Indicate mouse was active
-		LLUI::resetMouseIdleTimer();
+		LLUI::getInstance()->resetMouseIdleTimer();
 
 		// Don't let the user move the mouse out of the window until mouse up.
 		if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() )
@@ -1331,7 +1331,7 @@ void LLViewerWindow::handleMouseMove(LLWindow *window,  LLCoordGL pos, MASK mask
 
 	if (mouse_point != mCurrentMousePoint)
 	{
-		LLUI::resetMouseIdleTimer();
+		LLUI::getInstance()->resetMouseIdleTimer();
 	}
 
 	saveLastMouse(mouse_point);
@@ -1837,8 +1837,6 @@ LLViewerWindow::LLViewerWindow(const Params& p)
 	//
 	LL_DEBUGS("Window") << "Loading feature tables." << LL_ENDL;
 
-	LLFeatureManager::getInstance()->init();
-
 	// Initialize OpenGL Renderer
 	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
 		!gGLManager.mHasVertexBufferObject)
@@ -1893,7 +1891,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
 	rvp.mouse_opaque(false);
 	rvp.follows.flags(FOLLOWS_NONE);
 	mRootView = LLUICtrlFactory::create<LLRootView>(rvp);
-	LLUI::setRootView(mRootView);
+	LLUI::getInstance()->setRootView(mRootView);
 
 	// Make avatar head look forward at start
 	mCurrentMousePoint.mX = getWindowWidthScaled() / 2;
@@ -2456,7 +2454,7 @@ void LLViewerWindow::setNormalControlsVisible( BOOL visible )
 		gStatusBar->setEnabled( visible );	
 	}
 	
-	LLNavigationBar* navbarp = LLUI::getRootView()->findChild<LLNavigationBar>("navigation_bar");
+	LLNavigationBar* navbarp = LLUI::getInstance()->getRootView()->findChild<LLNavigationBar>("navigation_bar");
 	if (navbarp)
 	{
 		// when it's time to show navigation bar we need to ensure that the user wants to see it
@@ -2566,7 +2564,7 @@ void LLViewerWindow::draw()
 
 	if (!gSavedSettings.getBOOL("RenderUIBuffer"))
 	{
-		LLUI::sDirtyRect = getWindowRectScaled();
+		LLUI::getInstance()->mDirtyRect = getWindowRectScaled();
 	}
 
 	// HACK for timecode debugging
@@ -2967,7 +2965,7 @@ BOOL LLViewerWindow::handleUnicodeChar(llwchar uni_char, MASK mask)
 
 void LLViewerWindow::handleScrollWheel(S32 clicks)
 {
-	LLUI::resetMouseIdleTimer();
+	LLUI::getInstance()->resetMouseIdleTimer();
 	
 	LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
 	if( mouse_captor )
@@ -3017,7 +3015,7 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
 
 void LLViewerWindow::handleScrollHWheel(S32 clicks)
 {
-    LLUI::resetMouseIdleTimer();
+    LLUI::getInstance()->resetMouseIdleTimer();
 
     LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
     if (mouse_captor)
@@ -3089,7 +3087,7 @@ void LLViewerWindow::moveCursorToCenter()
 		S32 x = getWorldViewWidthScaled() / 2;
 		S32 y = getWorldViewHeightScaled() / 2;
 	
-		LLUI::setMousePositionScreen(x, y);
+		LLUI::getInstance()->setMousePositionScreen(x, y);
 		
 		//on a forced move, all deltas get zeroed out to prevent jumping
 		mCurrentMousePoint.set(x,y);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index ee350594c7719ddb45c5e2e2c62fde65f43b53ca..af4d1a28b50cc3e1f37f1d71c3332ef86aaaad13 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1378,7 +1378,7 @@ void LLVOAvatar::calculateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
 				 ++attachment_iter)
 			{
                     // Don't we need to look at children of attached_object as well?
-				const LLViewerObject* attached_object = (*attachment_iter);
+                const LLViewerObject* attached_object = attachment_iter->get();
 				if (attached_object && !attached_object->isHUDAttachment())
 				{
                         const LLVOVolume *vol = dynamic_cast<const LLVOVolume*>(attached_object);
@@ -1801,7 +1801,7 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a&
 					 attachment_iter != attachment->mAttachedObjects.end();
 					 ++attachment_iter)
 				{
-					LLViewerObject* attached_object = (*attachment_iter);
+					LLViewerObject* attached_object = attachment_iter->get();
 					
 					if (attached_object && !attached_object->isDead() && attachment->getValid())
 					{
@@ -1865,7 +1865,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector
 					attachment_iter != attachment->mAttachedObjects.end();
 					++attachment_iter)
 			{
-				LLViewerObject* attached_object = (*attachment_iter);
+				LLViewerObject* attached_object = attachment_iter->get();
 					
 				if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent))
 				{
@@ -2691,7 +2691,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				LLViewerObject* attached_object = (*attachment_iter);
+				LLViewerObject* attached_object = attachment_iter->get();
 				BOOL visibleAttachment = visible || (attached_object && 
 													 !(attached_object->mDrawable->getSpatialBridge() &&
 													   attached_object->mDrawable->getSpatialBridge()->getRadius() < 2.0));
@@ -4572,7 +4572,7 @@ void LLVOAvatar::updateVisibility()
 					 attachment_iter != attachment->mAttachedObjects.end();
 					 ++attachment_iter)
 				{
-					if (LLViewerObject *attached_object = (*attachment_iter))
+					if (LLViewerObject *attached_object = attachment_iter->get())
 					{
 						if(attached_object->mDrawable->isVisible())
 						{
@@ -6005,7 +6005,7 @@ void LLVOAvatar::rebuildAttachmentOverrides()
             for (LLViewerJointAttachment::attachedobjs_vec_t::iterator at_it = attachment_pt->mAttachedObjects.begin();
 				 at_it != attachment_pt->mAttachedObjects.end(); ++at_it)
             {
-                LLViewerObject *vo = *at_it;
+                LLViewerObject *vo = at_it->get();
                 // Attached animated objects affect joints in their control
                 // avs, not the avs to which they are attached.
                 if (vo && !vo->isAnimatedObject())
@@ -6056,7 +6056,7 @@ void LLVOAvatar::updateAttachmentOverrides()
             for (LLViewerJointAttachment::attachedobjs_vec_t::iterator at_it = attachment_pt->mAttachedObjects.begin();
 				 at_it != attachment_pt->mAttachedObjects.end(); ++at_it)
             {
-                LLViewerObject *vo = *at_it;
+                LLViewerObject *vo = at_it->get();
                 // Attached animated objects affect joints in their control
                 // avs, not the avs to which they are attached.
                 if (vo && !vo->isAnimatedObject())
@@ -7159,29 +7159,33 @@ void LLVOAvatar::lazyAttach()
 	for (U32 i = 0; i < mPendingAttachment.size(); i++)
 	{
 		LLPointer<LLViewerObject> cur_attachment = mPendingAttachment[i];
-		if (cur_attachment->mDrawable)
+		// Object might have died while we were waiting for drawable
+		if (!cur_attachment->isDead())
 		{
-			if (isSelf())
+			if (cur_attachment->mDrawable)
 			{
-				const LLUUID& item_id = cur_attachment->getAttachmentItemID();
-				LLViewerInventoryItem *item = gInventory.getItem(item_id);
-				LL_DEBUGS("Avatar") << "ATT attaching object "
-									<< (item ? item->getName() : "UNKNOWN") << " id " << item_id << LL_ENDL;
+				if (isSelf())
+				{
+					const LLUUID& item_id = cur_attachment->getAttachmentItemID();
+					LLViewerInventoryItem *item = gInventory.getItem(item_id);
+					LL_DEBUGS("Avatar") << "ATT attaching object "
+						<< (item ? item->getName() : "UNKNOWN") << " id " << item_id << LL_ENDL;
+				}
+				if (!attachObject(cur_attachment))
+				{	// Drop it
+					LL_WARNS() << "attachObject() failed for "
+						<< cur_attachment->getID()
+						<< " item " << cur_attachment->getAttachmentItemID()
+						<< LL_ENDL;
+					// MAINT-3312 backout
+					//still_pending.push_back(cur_attachment);
+				}
 			}
-			if (!attachObject(cur_attachment))
-			{	// Drop it
-				LL_WARNS() << "attachObject() failed for " 
-					<< cur_attachment->getID()
-					<< " item " << cur_attachment->getAttachmentItemID()
-					<< LL_ENDL;
-				// MAINT-3312 backout
-				//still_pending.push_back(cur_attachment);
+			else
+			{
+				still_pending.push_back(cur_attachment);
 			}
 		}
-		else
-		{
-			still_pending.push_back(cur_attachment);
-		}
 	}
 
 	mPendingAttachment = still_pending;
@@ -7201,7 +7205,7 @@ void LLVOAvatar::resetHUDAttachments()
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				const LLViewerObject* attached_object = (*attachment_iter);
+				const LLViewerObject* attached_object = attachment_iter->get();
 				if (attached_object && attached_object->mDrawable.notNull())
 				{
 					gPipeline.markMoved(attached_object->mDrawable);
@@ -7389,7 +7393,7 @@ void LLVOAvatar::getOffObject()
 	if (sit_object)
 	{
 		stopMotionFromSource(sit_object->getID());
-		LLFollowCamMgr::setCameraActive(sit_object->getID(), FALSE);
+		LLFollowCamMgr::getInstance()->setCameraActive(sit_object->getID(), FALSE);
 
 		LLViewerObject::const_child_list_t& child_list = sit_object->getChildren();
 		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
@@ -7398,7 +7402,7 @@ void LLVOAvatar::getOffObject()
 			LLViewerObject* child_objectp = *iter;
 
 			stopMotionFromSource(child_objectp->getID());
-			LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE);
+			LLFollowCamMgr::getInstance()->setCameraActive(child_objectp->getID(), FALSE);
 		}
 	}
 
@@ -7531,7 +7535,7 @@ LLViewerObject *	LLVOAvatar::findAttachmentByID( const LLUUID & target_id ) cons
 			 attachment_iter != attachment->mAttachedObjects.end();
 			 ++attachment_iter)
 		{
-			LLViewerObject *attached_object = (*attachment_iter);
+			LLViewerObject *attached_object = attachment_iter->get();
 			if (attached_object &&
 				attached_object->getID() == target_id)
 			{
@@ -7966,7 +7970,7 @@ void LLVOAvatar::updateMeshVisibility()
 				attachment_iter != attachment->mAttachedObjects.end();
 				++attachment_iter)
 			{
-				LLViewerObject *objectp = (*attachment_iter);
+				LLViewerObject *objectp = attachment_iter->get();
 				if (objectp)
 				{
 					for (int face_index = 0; face_index < objectp->getNumTEs(); face_index++)
@@ -8283,7 +8287,7 @@ void LLVOAvatar::updateMeshTextures()
 			attachment_iter != attachment->mAttachedObjects.end();
 			++attachment_iter)
 		{
-			LLViewerObject* attached_object = (*attachment_iter);
+			LLViewerObject* attached_object = attachment_iter->get();
 			if (attached_object && !attached_object->isDead())
 			{
 				attached_object->refreshBakeTexture();
@@ -8521,7 +8525,7 @@ LLBBox LLVOAvatar::getHUDBBox() const
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				const LLViewerObject* attached_object = (*attachment_iter);
+				const LLViewerObject* attached_object = attachment_iter->get();
 				if (attached_object == NULL)
 				{
 					LL_WARNS() << "HUD attached object is NULL!" << LL_ENDL;
@@ -9887,7 +9891,7 @@ void LLVOAvatar::getAssociatedVolumes(std::vector<LLVOVolume*>& volumes)
 		for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attach_iter = attachment->mAttachedObjects.begin();
 			 attach_iter != attach_end; ++attach_iter)
 		{
-			LLViewerObject* attached_object =  *attach_iter;
+			LLViewerObject* attached_object =  attach_iter->get();
             LLVOVolume *volume = dynamic_cast<LLVOVolume*>(attached_object);
             if (volume)
             {
@@ -10405,7 +10409,7 @@ void LLVOAvatar::calculateUpdateRenderComplexity()
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				const LLViewerObject* attached_object = (*attachment_iter);
+                const LLViewerObject* attached_object = attachment_iter->get();
                 accountRenderComplexityForObject(attached_object, max_attachment_complexity,
                                                  textures, cost, hud_complexity_list);
 			}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 986ce60ae63d063b4c37b2b217ca5d9ea47116bf..16b27fd1445cd3283639c6087b3d50e7d5396f2a 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -1208,7 +1208,7 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 		// the simulator should automatically handle permission revocation
 		
 		stopMotionFromSource(attachment_id);
-		LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE);
+		LLFollowCamMgr::getInstance()->setCameraActive(viewer_object->getID(), FALSE);
 		
 		LLViewerObject::const_child_list_t& child_list = viewer_object->getChildren();
 		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
@@ -1220,7 +1220,7 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 			// permissions revocation
 			
 			stopMotionFromSource(child_objectp->getID());
-			LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE);
+			LLFollowCamMgr::getInstance()->setCameraActive(child_objectp->getID(), FALSE);
 		}
 		
 		// Make sure the inventory is in sync with the avatar.
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index fb28d9bdb5ab31422705ab7c89c652aef1ae9273..07660ca6ac16efc94a662da152592ef40c066abf 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -1045,9 +1045,9 @@ const char* object_cache_dirname = "objectcache";
 const char* header_filename = "object.cache";
 
 
-LLVOCache::LLVOCache():
+LLVOCache::LLVOCache(bool read_only) :
 	mInitialized(false),
-	mReadOnly(true),
+	mReadOnly(read_only),
 	mNumEntries(0),
 	mCacheSize(1)
 {
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 594d38249bd07cdb5548414dd6ade6862aa2ab35..6c95541c1169469c092587cb76344539d1e54fe9 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -221,9 +221,9 @@ class LLVOCachePartition : public LLViewerOctreePartition, public LLTrace::MemTr
 //
 //Note: LLVOCache is not thread-safe
 //
-class LLVOCache : public LLSingleton<LLVOCache>
+class LLVOCache : public LLParamSingleton<LLVOCache>
 {
-	LLSINGLETON(LLVOCache);
+	LLSINGLETON(LLVOCache, bool read_only);
 	~LLVOCache() ;
 
 private:
@@ -259,15 +259,14 @@ class LLVOCache : public LLSingleton<LLVOCache>
 	typedef std::map<U64, HeaderEntryInfo*> handle_entry_map_t;
 
 public:
-	void initCache(ELLPath location, U32 size, U32 cache_version) ;
+	// We need this init to be separate from constructor, since we might construct cache, purge it, then init.
+	void initCache(ELLPath location, U32 size, U32 cache_version);
 	void removeCache(ELLPath location, bool started = false) ;
 
 	void readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) ;
 	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled);
 	void removeEntry(U64 handle) ;
 
-	void setReadOnly(bool read_only) {mReadOnly = read_only;} 
-
 	U32 getCacheEntries() { return mNumEntries; }
 	U32 getCacheEntriesMax() { return mCacheSize; }
 
diff --git a/indra/newview/llvoicecallhandler.cpp b/indra/newview/llvoicecallhandler.cpp
index 2050dab689abd1d2c88cfa2f8a8222abeea04792..1e993d13843aaf3af2c93fa95ebd55508ee0f36b 100644
--- a/indra/newview/llvoicecallhandler.cpp
+++ b/indra/newview/llvoicecallhandler.cpp
@@ -40,7 +40,7 @@ class LLVoiceCallAvatarHandler : public LLCommandHandler
 	
 	bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web)
 	{
-		if (!LLUI::sSettingGroups["config"]->getBOOL("EnableVoiceCall"))
+		if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableVoiceCall"))
 		{
 			LLNotificationsUtil::add("NoVoiceCall", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit"));
 			return true;
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index bce399a9406158f4fc847db7fa5b49d507699b46..cc590fc947cf1b42d192942d468fda53656a963e 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -116,7 +116,7 @@ std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserv
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
-LLVoiceClient::LLVoiceClient()
+LLVoiceClient::LLVoiceClient(LLPumpIO *pump)
 	:
 	mVoiceModule(NULL),
 	m_servicePump(NULL),
@@ -133,6 +133,7 @@ LLVoiceClient::LLVoiceClient()
 	mDisableMic(false)
 {
 	updateSettings();
+	init(pump);
 }
 
 //---------------------------------------------------
diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h
index fbc85fd9779bcdbe1bb6cfc16a9a58979d225abe..3d04e1f0dbe0c6c0e45734a2140ddc42753cddf7 100644
--- a/indra/newview/llvoiceclient.h
+++ b/indra/newview/llvoiceclient.h
@@ -310,9 +310,9 @@ class LLVoiceEffectInterface
 };
 
 
-class LLVoiceClient: public LLSingleton<LLVoiceClient>
+class LLVoiceClient: public LLParamSingleton<LLVoiceClient>
 {
-	LLSINGLETON(LLVoiceClient);
+	LLSINGLETON(LLVoiceClient, LLPumpIO *pump);
 	LOG_CLASS(LLVoiceClient);
 	~LLVoiceClient();
 
@@ -320,7 +320,6 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient>
 	typedef boost::signals2::signal<void(void)> micro_changed_signal_t;
 	micro_changed_signal_t mMicroChangedSignal;
 
-	void init(LLPumpIO *pump);	// Call this once at application startup (creates connector)
 	void terminate();	// Call this to clean up during shutdown
 	
 	const LLVoiceVersionInfo getVersion();
@@ -472,6 +471,8 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient>
 	// Returns NULL if voice effects are not supported, or not enabled.
 	LLVoiceEffectInterface* getVoiceEffectInterface() const;
 	//@}
+private:
+	void init(LLPumpIO *pump);
 
 protected:
 	LLVoiceModuleInterface* mVoiceModule;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 33a9c771eab5c5e55c21df7ba60b8c7398804e2a..0a1efd564f6a7446c8eaebf58bcdc4b457996db5 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -189,7 +189,7 @@ class LLMediaDataClientObjectImpl : public LLMediaDataClientObject
 	
 	virtual bool isInterestingEnough() const
 		{
-			return LLViewerMedia::isInterestingEnough(mObject, getMediaInterest());
+			return LLViewerMedia::getInstance()->isInterestingEnough(mObject, getMediaInterest());
 		}
 
 	virtual std::string getCapabilityUrl(const std::string &name) const
@@ -2705,7 +2705,7 @@ void LLVOVolume::syncMediaData(S32 texture_index, const LLSD &media_data, bool m
 			LLUUID updating_agent = LLTextureEntry::getAgentIDFromMediaVersionString(getMediaURL());
 			update_from_self = (updating_agent == gAgent.getID());
 		}
-		viewer_media_t media_impl = LLViewerMedia::updateMediaImpl(mep, previous_url, update_from_self);
+		viewer_media_t media_impl = LLViewerMedia::getInstance()->updateMediaImpl(mep, previous_url, update_from_self);
 			
 		addMediaImpl(media_impl, texture_index) ;
 	}
diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp
index 61ec02957e2176ba4dea256d04f139725fc61333..a34c5826edcd55c34aa00bcb3929011bad563753 100644
--- a/indra/newview/llweb.cpp
+++ b/indra/newview/llweb.cpp
@@ -39,7 +39,6 @@
 #include "lllogininstance.h"
 #include "llparcel.h"
 #include "llsd.h"
-#include "lltoastalertpanel.h"
 #include "llui.h"
 #include "lluri.h"
 #include "llversioninfo.h"
@@ -57,32 +56,6 @@
 bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async );
 
 
-class URLLoader : public LLToastAlertPanel::URLLoader
-{
-	virtual void load(const std::string& url , bool force_open_externally)
-	{
-		if (force_open_externally)
-		{
-			LLWeb::loadURLExternal(url);
-		}
-		else
-		{
-			LLWeb::loadURL(url);
-		}
-	}
-};
-static URLLoader sAlertURLLoader;
-
-
-// static
-void LLWeb::initClass()
-{
-	LLToastAlertPanel::setURLLoader(&sAlertURLLoader);
-}
-
-
-
-
 // static
 void LLWeb::loadURL(const std::string& url, const std::string& target, const std::string& uuid)
 {
@@ -121,7 +94,7 @@ void LLWeb::loadURLExternal(const std::string& url, const std::string& uuid)
 void LLWeb::loadURLExternal(const std::string& url, bool async, const std::string& uuid)
 {
 	// Act like the proxy window was closed, since we won't be able to track targeted windows in the external browser.
-	LLViewerMedia::proxyWindowClosed(uuid);
+	LLViewerMedia::getInstance()->proxyWindowClosed(uuid);
 	
 	if(gSavedSettings.getBOOL("DisableExternalBrowser"))
 	{
diff --git a/indra/newview/llweb.h b/indra/newview/llweb.h
index 7149ce9baf49b265f1de93ee560b40faa7e03296..0426f00f278efba7204830af86d1fba570046d66 100644
--- a/indra/newview/llweb.h
+++ b/indra/newview/llweb.h
@@ -46,8 +46,6 @@ class LLWeb
 		BROWSER_INT_LL_EXT_OTHERS = 1,
 		BROWSER_INTERNAL_ONLY = 2
 	};
-
-	static void initClass();
 	
 	/// Load the given url in the operating system's web browser, async if we want to return immediately
 	/// before browser has spawned
diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp
index 8dcef2c7cdae9e393bb5beabd83cac1b1b798b2a..569f479a16cde785517c473b078fab3989f672ad 100644
--- a/indra/newview/llwebprofile.cpp
+++ b/indra/newview/llwebprofile.cpp
@@ -83,7 +83,7 @@ void LLWebProfile::setAuthCookie(const std::string& cookie)
 LLCore::HttpHeaders::ptr_t LLWebProfile::buildDefaultHeaders()
 {
     LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
-    LLSD headers = LLViewerMedia::getHeaders();
+    LLSD headers = LLViewerMedia::getInstance()->getHeaders();
 
     for (LLSD::map_iterator it = headers.beginMap(); it != headers.endMap(); ++it)
     {
diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp
index 5367262bb6cfe3094187fffa8868c5393b1d8e52..9e4297baafc13a903d8ae97dc6436cd11d8aed51 100644
--- a/indra/newview/llwindowlistener.cpp
+++ b/indra/newview/llwindowlistener.cpp
@@ -69,7 +69,7 @@ LLWindowListener::LLWindowListener(LLViewerWindow *window, const KeyboardGetter&
 	std::string buttonExplain =
 		"(button values \"LEFT\", \"MIDDLE\", \"RIGHT\")\n";
 	std::string paramsExplain =
-		"[\"path\"] is as for LLUI::resolvePath(), described in\n"
+		"[\"path\"] is as for LLUI::getInstance()->resolvePath(), described in\n"
 		"http://bitbucket.org/lindenlab/viewer-release/src/tip/indra/llui/llui.h\n"
 		"If you omit [\"path\"], you must specify both [\"x\"] and [\"y\"].\n"
 		"If you specify [\"path\"] without both [\"x\"] and [\"y\"], will synthesize (x, y)\n"
@@ -209,7 +209,7 @@ void LLWindowListener::getInfo(LLSD const & evt)
 	if (evt.has("path"))
 	{
 		std::string path(evt["path"]);
-		LLView * target_view = LLUI::resolvePath(LLUI::getRootView(), path);
+		LLView * target_view = LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), path);
 		if (target_view != 0)
 		{
 			response.setResponse(target_view->getInfo());
@@ -230,7 +230,7 @@ void LLWindowListener::getInfo(LLSD const & evt)
 void LLWindowListener::getPaths(LLSD const & request)
 {
 	Response response(LLSD(), request);
-	LLView *root(LLUI::getRootView()), *base(NULL);
+	LLView *root(LLUI::getInstance()->getRootView()), *base(NULL);
 	// Capturing request["under"] as string means we conflate the case in
 	// which there is no ["under"] key with the case in which its value is the
 	// empty string. That seems to make sense to me.
@@ -243,7 +243,7 @@ void LLWindowListener::getPaths(LLSD const & request)
 	}
 	else
 	{
-		base = LLUI::resolvePath(root, under);
+		base = LLUI::getInstance()->resolvePath(root, under);
 		if (! base)
 		{
 			return response.error(STRINGIZE(request["op"].asString() << " request "
@@ -268,7 +268,7 @@ void LLWindowListener::keyDown(LLSD const & evt)
 	if (evt.has("path"))
 	{
 		std::string path(evt["path"]);
-		LLView * target_view = LLUI::resolvePath(LLUI::getRootView(), path);
+		LLView * target_view = LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), path);
 		if (target_view == 0) 
 		{
 			response.error(STRINGIZE(evt["op"].asString() << " request "
@@ -303,7 +303,7 @@ void LLWindowListener::keyUp(LLSD const & evt)
 	if (evt.has("path"))
 	{
 		std::string path(evt["path"]);
-		LLView * target_view = LLUI::resolvePath(LLUI::getRootView(), path);
+		LLView * target_view = LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), path);
 		if (target_view == 0 )
 		{
 			response.error(STRINGIZE(evt["op"].asString() << " request "
@@ -407,8 +407,8 @@ static void mouseEvent(const MouseFunc& func, const LLSD& request)
 	}
 	else // ! path.empty()
 	{
-		LLView* root   = LLUI::getRootView();
-		LLView* target = LLUI::resolvePath(root, path);
+		LLView* root   = LLUI::getInstance()->getRootView();
+		LLView* target = LLUI::getInstance()->resolvePath(root, path);
 		if (! target)
 		{
 			return response.error(STRINGIZE(request["op"].asString() << " request "
diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp
index 853da80e9e57db2f7d25cbd6c37a77a2bb117ce0..a6df0792233581c1aabe4c1c268298b99a0003c4 100644
--- a/indra/newview/llworldmapview.cpp
+++ b/indra/newview/llworldmapview.cpp
@@ -1622,7 +1622,7 @@ BOOL LLWorldMapView::handleMouseUp( S32 x, S32 y, MASK mask )
 			LLRect clip_rect = getRect();
 			clip_rect.stretch(-8);
 			clip_rect.clipPointToRect(mMouseDownX, mMouseDownY, local_x, local_y);
-			LLUI::setMousePositionLocal(this, local_x, local_y);
+			LLUI::getInstance()->setMousePositionLocal(this, local_x, local_y);
 
 			// finish the pan
 			mPanning = FALSE;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index eb2d3bf8737714a4e9a16764cbb8c667a7425e3f..e28272e10beefe662dc960af8d40f2be1c19c410 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -11434,7 +11434,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 				 attachment_iter != attachment->mAttachedObjects.end();
 				 ++attachment_iter)
 			{
-				if (LLViewerObject* attached_object = (*attachment_iter))
+				if (LLViewerObject* attached_object = attachment_iter->get())
 				{
 					markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
 				}
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index 9b18dbc2e26a069e38081b37da7ccad791d91908..17340e08585929ca9758b3d307532a37bab13af1 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -133,7 +133,6 @@ with the same filename but different name
   <texture name="Command_Chat_Icon"         file_name="toolbar_icons/chat.png"         preload="true" />
   <texture name="Command_Compass_Icon"      file_name="toolbar_icons/land.png"         preload="true" />
   <texture name="Command_Destinations_Icon" file_name="toolbar_icons/destinations.png" preload="true" />
-  <texture name="Command_Flickr_Icon"       file_name="toolbar_icons/flickr.png"       preload="true" />
   <texture name="Command_Gestures_Icon"     file_name="toolbar_icons/gestures.png"     preload="true" />
   <texture name="Command_Grid_Status_Icon"  file_name="toolbar_icons/grid_status.png"  preload="true" />
   <texture name="Command_HowTo_Icon"        file_name="toolbar_icons/howto.png"        preload="true" />
@@ -153,7 +152,6 @@ with the same filename but different name
   <texture name="Command_Search_Icon"       file_name="toolbar_icons/search.png"       preload="true" />
   <texture name="Command_Snapshot_Icon"     file_name="toolbar_icons/snapshot.png"     preload="true" />
   <texture name="Command_Speak_Icon"        file_name="toolbar_icons/speak.png"        preload="true" />
-  <texture name="Command_Twitter_Icon"      file_name="toolbar_icons/twitter.png"      preload="true" />
   <texture name="Command_View_Icon"         file_name="toolbar_icons/view.png"         preload="true" />
   <texture name="Command_Voice_Icon"        file_name="toolbar_icons/nearbyvoice.png"  preload="true" />
   <texture name="Caret_Bottom_Icon"         file_name="toolbar_icons/caret_bottom.png" preload="true" scale.left="1" scale.top="23" scale.right="15" scale.bottom="1" />
diff --git a/indra/newview/skins/default/xui/en/floater_flickr.xml b/indra/newview/skins/default/xui/en/floater_flickr.xml
deleted file mode 100644
index 3b9c4894c17076fb3bfe3d525f57a3e5d2ca29c0..0000000000000000000000000000000000000000
--- a/indra/newview/skins/default/xui/en/floater_flickr.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
-<floater
-  positioning="cascading"
-  can_close="true"
-  can_resize="false"
-  help_topic="floater_flickr"
-  layout="topleft"
-  name="floater_flickr"
-  save_rect="true"
-  single_instance="true"
-  reuse_instance="true"
-  title="SHARE TO FLICKR"
-  height="590"
-  width="272">
-  <panel
-   height="590"
-   width="272"
-   visible="true"
-   name="background"
-   follows="all"
-   top="0"
-   left="0">
-   <tab_container
-     name="tabs"
-     tab_group="1"
-     tab_min_width="70"
-     tab_height="21"
-     tab_position="top"
-     top="7"
-     height="555"
-     follows="all"
-     halign="center">
-     <panel
-       filename="panel_flickr_photo.xml"
-       class="llflickrphotopanel"
-       follows="all"
-       label="PHOTO"
-       name="panel_flickr_photo"/>
-     <panel
-       filename="panel_flickr_account.xml"
-       class="llflickraccountpanel"
-       follows="all"
-       label="ACCOUNT"
-       name="panel_flickr_account"/>     
-    </tab_container>
-    <panel
-     name="connection_status_panel"
-     follows="left|bottom|right"
-     height="24">
-     <text
-      name="connection_error_text"
-      type="string"
-      follows="left|bottom|right"
-      bottom="-5"
-      left="10"
-      width="250"
-      height="20"
-      wrap="true"
-      halign="left"
-      valign="center"
-      text_color="DrYellow"
-      font="SansSerif">
-      Error
-     </text>
-     <loading_indicator
-      follows="left|bottom|right"
-      height="24"
-      width="24"
-      name="connection_loading_indicator"
-      top_delta="-2"
-      left="10"
-      visible="true"/>
-     <text
-      name="connection_loading_text"
-      type="string"
-      follows="left|bottom|right"
-      top_delta="2"
-      left_pad="5"
-      width="250"
-      height="20"
-      wrap="true"
-      halign="left"
-      valign="center"
-      text_color="EmphasisColor"
-      font="SansSerif">
-      Loading...
-    </text>
-  </panel>
- </panel>
-</floater>
diff --git a/indra/newview/skins/default/xui/en/floater_forget_user.xml b/indra/newview/skins/default/xui/en/floater_forget_user.xml
index f2e894733fced87a59d0b4a3d7ccd3b22093c666..86228d49ee5433162f7430b016e107fd9d56e5a5 100644
--- a/indra/newview/skins/default/xui/en/floater_forget_user.xml
+++ b/indra/newview/skins/default/xui/en/floater_forget_user.xml
@@ -35,6 +35,5 @@
      name="delete_data"
      top_pad="5"
      width="260"
-     initial_value="1"
-     tooltip="Deletes local files: chat history, last session screenshot, browser cookies, teleport history, toolbar settings, e t c"/>
+     tool_tip="Deletes local files: chat history, last session screenshot, browser cookies, teleport history, toolbar settings, e t c"/>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_twitter.xml b/indra/newview/skins/default/xui/en/floater_twitter.xml
deleted file mode 100644
index 5e8dfb8a527a151a82717f32f2188c988a0a2f56..0000000000000000000000000000000000000000
--- a/indra/newview/skins/default/xui/en/floater_twitter.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
-<floater
-  positioning="cascading"
-  can_close="true"
-  can_resize="false"
-  help_topic="floater_twitter"
-  layout="topleft"
-  name="floater_twitter"
-  save_rect="true"
-  single_instance="true"
-  reuse_instance="true"
-  title="TWITTER"
-  height="462"
-  width="272">
-   <tab_container
-     name="tabs"
-     tab_group="1"
-     tab_min_width="70"
-     tab_height="21"
-     tab_position="top"
-     top="7"
-     height="457"
-     halign="center">
-     <panel
-       filename="panel_twitter_photo.xml"
-       class="lltwitterphotopanel"
-       follows="all"
-       label="COMPOSE"
-       name="panel_twitter_photo"/>
-     <panel
-       filename="panel_twitter_account.xml"
-       class="lltwitteraccountpanel"
-       follows="all"
-       label="ACCOUNT"
-       name="panel_twitter_account"/>     
-    </tab_container>
-     <text
-      name="connection_error_text"
-      type="string"
-      follows="left|bottom|right"
-      bottom="-5"
-      left="10"
-      width="252"
-      height="20"
-      wrap="true"
-      halign="left"
-      valign="center"
-      text_color="DrYellow"
-      font="SansSerif">
-      Error
-     </text>
-     <loading_indicator
-      follows="left|bottom|right"
-      height="24"
-      width="24"
-      name="connection_loading_indicator"
-      top_delta="-2"
-      left="10"
-      visible="true"/>
-     <text
-      name="connection_loading_text"
-      type="string"
-      follows="left|bottom|right"
-      top_delta="2"
-      left_pad="5"
-      width="223"
-      height="20"
-      wrap="true"
-      halign="left"
-      valign="center"
-      text_color="EmphasisColor"
-      font="SansSerif">
-      Loading...
-    </text>
-</floater>
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index af185d43b0edca0d0b3c75941851de378d7fa331..04b5d808ecb01947993e21fc097eccf693d5c465 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -311,21 +311,6 @@
              parameter="conversation" />
         </menu_item_check>
         <menu_item_separator/>
-      <menu_item_call
-        label="Twitter..."
-        name="Twitter">
-        <menu_item_call.on_click
-          function="Floater.Toggle"
-          parameter="twitter"/>
-      </menu_item_call>
-      <menu_item_call
-        label="Flickr..."
-        name="Flickr">
-        <menu_item_call.on_click
-          function="Floater.Toggle"
-          parameter="flickr"/>
-      </menu_item_call>
-        <menu_item_separator/>
         <menu
          label="Voice morphing"
          name="VoiceMorphing"
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index a757a4beaabf542c308553642be086f02708faad..1c72aec700719d1eb65cafa530db6fe174cefa68 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -6809,20 +6809,6 @@ Please select at least one type of content to search (General, Moderate, or Adul
 [MESSAGE]
   </notification>
 
-  <notification
-   icon="notify.tga"
-   name="FlickrConnect"
-   type="notifytip">
-    [MESSAGE]
-  </notification>
-
-  <notification
-   icon="notify.tga"
-   name="TwitterConnect"
-   type="notifytip">
-    [MESSAGE]
-  </notification>
-
   <notification
    icon="notify.tga"
    name="PaymentReceived"
diff --git a/indra/newview/skins/default/xui/en/panel_flickr_account.xml b/indra/newview/skins/default/xui/en/panel_flickr_account.xml
deleted file mode 100644
index 5c2f33578004e5d81f7a6baf2062a017e6844063..0000000000000000000000000000000000000000
--- a/indra/newview/skins/default/xui/en/panel_flickr_account.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<panel
-	 height="540"
-	 width="272"
-	 layout="topleft"
-   name="panel_flickr_account">
-  <string
-      name="flickr_connected"
-      value="You are connected to Flickr as:" />
-  <string
-      name="flickr_disconnected"
-      value="Not connected to Flickr" />
-  <text
-   layout="topleft"
-   length="1"
-   follows="top|left"
-   font="SansSerif"
-   height="16"
-   left="10"
-   name="account_caption_label"
-   top="5"
-   type="string">
-    Not connected to Flickr.
-  </text>
-  <text
-   layout="topleft"
-   top_pad="2"
-   length="1"
-   follows="top|left"
-   font="SansSerif"
-   height="16"
-   left="10"
-   name="account_name_label"
-   parse_urls="true"
-   type="string"/>
-  <panel
-    layout="topleft"
-    name="panel_buttons"
-    height="345"
-    left="0">
-    <button
-     layout="topleft"
-     follows="left|top|right"
-     top_pad="9"
-     visible="true"
-	 left="10"
-	 right="-10"
-     height="23"
-     label="Connect..."
-     name="connect_btn"
-     width="210">
-      <commit_callback function="SocialSharing.Connect"/>
-    </button>
-
-    <button
-     layout="topleft"
-     follows="left|top|right"
-     top_delta="0"
-	 left="10"
-	 right="-10"
-     height="23"
-     label="Disconnect"
-     name="disconnect_btn"
-     width="210"
-     visible="false">
-      <commit_callback function="SocialSharing.Disconnect"/>
-    </button>
-    <text
-      layout="topleft"
-      length="1"
-      follows="top|left"
-      height="16"
-      left="10"
-      name="account_learn_more_label"
-      top_pad="5"
-      type="string">
-      [http://community.secondlife.com/t5/English-Knowledge-Base/Second-Life-Share-Flickr/ta-p/2435609 Learn about posting to Flickr]
-    </text>
-  </panel>
-</panel>
diff --git a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml b/indra/newview/skins/default/xui/en/panel_flickr_photo.xml
deleted file mode 100644
index 7fb2291423bd1e838870563872f1e80bfd049f39..0000000000000000000000000000000000000000
--- a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml
+++ /dev/null
@@ -1,259 +0,0 @@
-    <panel
-      height="540"
-      width="272"
-	  follows="all"
-      layout="topleft"
-      name="panel_flickr_photo">
-            <combo_box
-             control_name="FlickrPhotoResolution"
-             follows="left|top"
-			 layout="topleft"
-             top="7"
-             left="10"
-             name="resolution_combobox"
-             tool_tip="Image resolution"
-             height="21"
-             width="124">
-              <combo_box.item
-               label="Current Window"
-               name="CurrentWindow"
-               value="[i0,i0]" />
-              <combo_box.item
-               label="640x480"
-               name="640x480"
-               value="[i640,i480]" />
-              <combo_box.item
-               label="800x600"
-               name="800x600"
-               value="[i800,i600]" />
-              <combo_box.item
-               label="1024x768"
-               name="1024x768"
-               value="[i1024,i768]" />
-            </combo_box>
-            <combo_box
-               control_name="FlickrPhotoFilters"
-               follows="left|top"
-			   layout="topleft"
-               name="filters_combobox"
-               tool_tip="Image filters"
-               top_delta="0"
-               left_pad="4"
-               height="21"
-               width="124">
-                <combo_box.item
-                 label="No Filter"
-                 name="NoFilter"
-                 value="NoFilter" />
-            </combo_box>
-            <panel
-                height="150"
-                width="250"
-                visible="true"
-                name="thumbnail_placeholder"
-                top_pad="5"
-                follows="left|top|right"
-				layout="topleft"
-				right="-10"
-                left="10">
-            </panel>
-			<text
-                follows="left|top"
-				layout="topleft"
-                font="SansSerif"
-                text_color="EmphasisColor"
-                height="14"
-                top_pad="2"
-                left="10"
-                length="1"
-                halign="center"
-                name="working_lbl"
-                translate="false"
-                type="string"
-                visible="true"
-                width="251">
-                Refreshing...
-            </text>
-			<view_border 
-			 bevel_style="in"
-			 follows="left|top"
-			 layout="topleft"
-			 height="1"
-			 left="10"
-			 name="refresh_border"
-			 width="250"
-			 top_pad="0"/>
-            <button
-             follows="left|top"
-			 layout="topleft"
-             height="23"
-             label="Refresh"
-             left="10"
-             top_pad="5"
-             name="new_snapshot_btn"
-             tool_tip="Click to refresh"
-             visible="true"
-             width="100" >
-             <button.commit_callback
-               function="SocialSharing.RefreshPhoto" />
-            </button>
-            <button
-                follows="right|top"
-				layout="topleft"
-                height="23"
-                label="Preview"
-                right="-10"
-                top_delta="0"
-                name="big_preview_btn"
-                tool_tip="Click to toggle preview"
-                is_toggle="true"
-                visible="true"
-                width="100" >
-                <button.commit_callback
-                function="SocialSharing.BigPreview" />
-            </button>
-            <text
-             length="1"
-             follows="top|left|right"
-			 layout="topleft"
-             font="SansSerif"
-             height="16"
-             left="10"
-             name="title_label"
-             top_pad="10"
-             type="string">
-              Title:
-            </text>
-            <line_editor
-             follows="left|top"
-			 layout="topleft"
-             height="20"
-             width="250"
-             left="10"
-             length="1"
-             max_length="256"
-             name="photo_title"
-             type="string">
-            </line_editor>
-            <text
-             length="1"
-             follows="top|left|right"
-			 layout="topleft"
-             font="SansSerif"
-             height="16"
-             left="10"
-			 right="-10"
-             name="description_label"
-             top_pad="10"
-			 width="25"
-             type="string">
-              Description:
-            </text>
-            <text_editor
-             follows="left|top"
-			 layout="topleft"
-             height="50"
-             width="249"
-             left="10"
-             length="1"
-             max_length="700"
-             name="photo_description"
-             spellcheck="true"
-             type="string"
-             word_wrap="true">
-            </text_editor>
-            <check_box
-             follows="left|top"
-			 layout="topleft"
-             initial_value="true"
-             label="Include SL location at end of description"
-             name="add_location_cb"
-              left="9"
-              height="16"
-             top_pad="8"/>
-            <text
-             length="1"
-             follows="top|left"
-			 layout="topleft"
-             font="SansSerif"
-             height="16"
-             left="10"
-             name="tags_label"
-             top_pad="6"
-             type="string">
-              Tags:
-            </text>
-            <text
-              length="1"
-              follows="top|left"
-			  layout="topleft"
-              font="SansSerifSmall"
-              text_color="White_50"
-              height="30"
-              name="tags_help_label"
-              left="51"
-              top_pad="-16"
-              type="string">
-Separate tags with spaces
-Use "" for multi-word tags
-            </text>
-            <text_editor
-             follows="left|top"
-			 layout="topleft"
-             height="50"
-             width="249"
-             left="10"
-             length="1"
-             max_length="700"
-             name="photo_tags"
-             type="string"
-             word_wrap="true">
-            </text_editor>
-            <combo_box
-             control_name="FlickrPhotoRating"
-             follows="left|top"
-			 layout="topleft"
-             top_pad="7"
-             left="10"
-             name="rating_combobox"
-             tool_tip="Flickr content rating"
-             height="21"
-             width="250">
-              <combo_box.item
-               label="Safe Flickr rating"
-               name="SafeRating"
-               value="1" />
-              <combo_box.item
-               label="Moderate Flickr rating"
-               name="ModerateRating"
-               value="2" />
-              <combo_box.item
-               label="Restricted Flickr rating"
-               name="RestrictedRating"
-               value="3" />
-            </combo_box>
-          <button
-           follows="left|top"
-		   layout="topleft"
-           top_pad="7"
-           left="10"
-           height="23"
-           label="Share"
-           name="post_photo_btn"
-           width="100">
-            <button.commit_callback
-             function="SocialSharing.SendPhoto" />
-          </button>
-          <button
-               follows="right|top"
-			   layout="topleft"
-               height="23"
-               label="Cancel"
-               name="cancel_photo_btn"
-               right="-10"
-               top_delta="0"
-               width="100">
-            <button.commit_callback
-             function="SocialSharing.Cancel" />
-          </button>
-    </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_login.xml b/indra/newview/skins/default/xui/en/panel_login.xml
index d601b36ce55b6ce1f4fc58b17e7f4a7d85ae89f9..766406e1d8f74bb0baa5b2e0a70b1d34bff76b20 100644
--- a/indra/newview/skins/default/xui/en/panel_login.xml
+++ b/indra/newview/skins/default/xui/en/panel_login.xml
@@ -137,7 +137,7 @@
     label="Remember me"
     check_button.bottom="3"
     name="remember_name"
-    tooltip="Already recorded user can be forgotten from preferences."
+    tool_tip="Already remembered user can be forgotten from Me &gt; Preferences &gt; Advanced &gt; Remembered Usernames."
     width="145" />
   <check_box
     control_name="RememberPassword"
diff --git a/indra/newview/skins/default/xui/en/panel_snapshot_options.xml b/indra/newview/skins/default/xui/en/panel_snapshot_options.xml
index 981b9ab8816799776e4dc377a11272898fe6f109..2fe4cf8183c3c08500176b7b6e2a3d2d73b98fb9 100644
--- a/indra/newview/skins/default/xui/en/panel_snapshot_options.xml
+++ b/indra/newview/skins/default/xui/en/panel_snapshot_options.xml
@@ -56,40 +56,6 @@
     <button.commit_callback
      function="Snapshot.SaveToProfile" />
   </button>
-  <button
-   follows="left|top"
-   font="SansSerif"
-   halign="left"
-   height="22"
-   image_overlay="Command_Twitter_Icon"
-   image_overlay_alignment="left"
-   image_top_pad="0"
-   imgoverlay_label_space="10"
-   label="Share to Twitter"
-   layout="topleft"
-   left_delta="0"
-   name="send_to_twitter_btn"
-   top_pad="5">
-    <button.commit_callback
-     function="Snapshot.SendToTwitter"/>
-  </button>
-  <button
-   follows="left|top"
-   font="SansSerif"
-   halign="left"
-   height="22"
-   image_overlay="Command_Flickr_Icon"
-   image_overlay_alignment="left"
-   image_top_pad="0"
-   imgoverlay_label_space="10"
-   label="Share to Flickr"
-   layout="topleft"
-   left_delta="0"
-   name="send_to_flickr_btn"
-   top_pad="5">
-    <button.commit_callback
-     function="Snapshot.SendToFlickr"/>
-  </button>
   <button
    follows="left|top"
    font="SansSerif"
diff --git a/indra/newview/skins/default/xui/en/panel_twitter_account.xml b/indra/newview/skins/default/xui/en/panel_twitter_account.xml
deleted file mode 100644
index b9049a0bba7214f585e7f57f609f0ef1c2bc1ace..0000000000000000000000000000000000000000
--- a/indra/newview/skins/default/xui/en/panel_twitter_account.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<panel
-	 height="400"
-	 width="272"
-	 layout="topleft"
-   name="panel_twitter_account">
-  <string
-      name="twitter_connected"
-      value="You are connected to Twitter as:" />
-  <string
-      name="twitter_disconnected"
-      value="Not connected to Twitter" />
-  <text
-   layout="topleft"
-   length="1"
-   follows="top|left"
-   font="SansSerif"
-   height="16"
-   left="10"
-   name="account_caption_label"
-   top="5"
-   type="string">
-    Not connected to Twitter.
-  </text>
-  <text
-   layout="topleft"
-   top_pad="2"
-   length="1"
-   follows="top|left"
-   font="SansSerif"
-   height="16"
-   left="10"
-   name="account_name_label"
-   parse_urls="true"
-   type="string"/>
-  <panel
-    layout="topleft"
-	follows="top|left"
-    name="panel_buttons"
-    height="345"
-	top_pad="3"
-    left="0">
-    <button
-     layout="topleft"
-     follows="left|top|right"
-     top_pad="9"
-	 left="10"
-	 right="-10"
-     visible="true"
-     height="23"
-     label="Connect..."
-     name="connect_btn"
-     width="210">
-      <commit_callback function="SocialSharing.Connect"/>
-    </button>
-
-    <button
-     layout="topleft"
-     follows="left|top|right"
-     top_delta="0"
-	 left="10"
-	 right="-10"
-     height="23"
-     label="Disconnect"
-     name="disconnect_btn"
-     width="210"
-     visible="false">
-      <commit_callback function="SocialSharing.Disconnect"/>
-    </button>
-    <text
-      layout="topleft"
-      length="1"
-      follows="top|left"
-      height="16"
-      left="10"
-      name="account_learn_more_label"
-      top_pad="5"
-      type="string">
-      [http://community.secondlife.com/t5/English-Knowledge-Base/Second-Life-Share-Twitter/ta-p/2435453 Learn about posting to Twitter]
-    </text>
-  </panel>
-</panel>
diff --git a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml b/indra/newview/skins/default/xui/en/panel_twitter_photo.xml
deleted file mode 100644
index 8774d09a03ea1e11a18bdfa896e3f58adf5ac30c..0000000000000000000000000000000000000000
--- a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml
+++ /dev/null
@@ -1,196 +0,0 @@
-    <panel
-      height="420"
-      width="304"
-      layout="topleft"
-      name="panel_twitter_photo">
-          <text
-           length="1"
-		   layout="topleft"
-           follows="top|left|right"
-           font="SansSerif"
-           height="16"
-           left="10"
-           name="status_label"
-           top="5"
-           type="string">
-            What's happening?
-          </text>
-          <text
-           length="1"
-           follows="top|left"
-		   layout="topleft"
-           font="SansSerif"
-           text_color="EmphasisColor"
-           halign="right"
-           height="16"
-           width="30"
-           left="227"
-           name="status_counter_label"
-           top="5"
-           type="string">
-            140
-          </text>
-          <text_editor
-           follows="left|top"
-		   layout="topleft"
-           height="87"
-           width="250"
-           left="10"
-           length="1"
-           max_length="140"
-           name="photo_status"
-           spellcheck="true"
-           type="string"
-           word_wrap="true">
-          </text_editor>
-          <check_box
-           follows="left|top"
-		   layout="topleft"
-           initial_value="true"
-           label="Include SL location"
-           name="add_location_cb"
-            left="10"
-            height="16"
-           top_pad="8"/>
-          <check_box
-           follows="left|top"
-		   layout="topleft"
-           initial_value="true"
-           label="Include a photo"
-           name="add_photo_cb"
-            left="10"
-            height="16"
-           top_pad="1"/>
-            <combo_box
-             control_name="TwitterPhotoResolution"
-             follows="left|top"
-			 layout="topleft"
-             top_pad="5"
-             left="10"
-             name="resolution_combobox"
-             tool_tip="Image resolution"
-             height="21"
-             width="124">
-              <combo_box.item
-               label="Current Window"
-               name="CurrentWindow"
-               value="[i0,i0]" />
-              <combo_box.item
-               label="640x480"
-               name="640x480"
-               value="[i640,i480]" />
-              <combo_box.item
-               label="800x600"
-               name="800x600"
-               value="[i800,i600]" />
-              <combo_box.item
-               label="1024x768"
-               name="1024x768"
-               value="[i1024,i768]" />
-            </combo_box>
-              <combo_box
-                  control_name="TwitterPhotoFilters"
-                  follows="right|top"
-				  layout="topleft"
-                  name="filters_combobox"
-                  tool_tip="Image filters"
-                  top_delta="0"
-                  right="-10"
-                  height="21"
-                  width="124">
-                  <combo_box.item
-                  label="No Filter"
-                  name="NoFilter"
-                  value="NoFilter" />
-              </combo_box>
-            <panel
-				layout="topleft"
-                height="150"
-                width="250"
-                visible="true"
-                name="thumbnail_placeholder"
-                top_pad="5"
-				right="-10"
-                follows="left|top|right"
-                left="10">
-            </panel>
-			<text
-                follows="left|top"
-				layout="topleft"
-                font="SansSerif"
-                text_color="EmphasisColor"
-                height="14"
-                top_pad="2"
-                left="10"
-                length="1"
-                halign="center"
-                name="working_lbl"
-                translate="false"
-                type="string"
-                visible="true"
-                width="251">
-                Refreshing...
-            </text>
-			<view_border 
-			 bevel_style="in"
-			 follows="left|top"
-			 layout="topleft"
-			 height="1"
-			 left="10"
-			 name="refresh_border"
-			 width="250"
-			 top_pad="0"/>
-            <button
-             follows="left|top"
-			 layout="topleft"
-             height="23"
-             label="Refresh"
-             left="10"
-             top_pad="5"
-             name="new_snapshot_btn"
-             tool_tip="Click to refresh"
-             visible="true"
-             width="100" >
-             <button.commit_callback
-               function="SocialSharing.RefreshPhoto" />
-            </button>
-              <button
-                  follows="right|top"
-				  layout="topleft"
-                  height="23"
-                  label="Preview"
-                  right="-10"
-                  top_delta="0"
-                  name="big_preview_btn"
-                  tool_tip="Click to toggle preview"
-                  is_toggle="true"
-                  visible="true"
-                  width="100" >
-                  <button.commit_callback
-                  function="SocialSharing.BigPreview" />
-              </button>
-          <button
-           follows="left|top"
-		   layout="topleft"
-           top_pad="3"
-           left="10"
-           height="23"
-           label="Tweet"
-           name="post_photo_btn"
-           width="100">
-            <button.commit_callback
-             function="SocialSharing.SendPhoto" />
-          </button>
-          <button
-               follows="right|top"
-			   layout="topleft"
-               height="23"
-               label="Cancel"
-               name="cancel_photo_btn"
-			   right="-10"
-               top_delta="0"
-               width="100">
-            <button.commit_callback
-             function="SocialSharing.Cancel" />
-          </button>          
-    </panel>
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 3a311db25cede602d3565176c5d6c70e6ff036ee..e1aff135a567ff7d9c93fece99a16c23879cc032 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -201,21 +201,7 @@ Please try logging in again in a minute.</string>
 	<string name="YouHaveBeenDisconnected">You have been disconnected from the region you were in.</string>
 	<string name="SentToInvalidRegion">You were sent to an invalid region.</string>
 	<string name="TestingDisconnect">Testing viewer disconnect</string>
-
-	<!-- SLShare: Flickr and Twitter -->
-  <string name="SocialFlickrConnecting">Connecting to Flickr...</string>
-  <string name="SocialFlickrPosting">Posting...</string>
-  <string name="SocialFlickrDisconnecting">Disconnecting from Flickr...</string>
-  <string name="SocialFlickrErrorConnecting">Problem connecting to Flickr</string>
-  <string name="SocialFlickrErrorPosting">Problem posting to Flickr</string>
-  <string name="SocialFlickrErrorDisconnecting">Problem disconnecting from Flickr</string>
-  <string name="SocialTwitterConnecting">Connecting to Twitter...</string>
-  <string name="SocialTwitterPosting">Posting...</string>
-  <string name="SocialTwitterDisconnecting">Disconnecting from Twitter...</string>
-  <string name="SocialTwitterErrorConnecting">Problem connecting to Twitter</string>
-  <string name="SocialTwitterErrorPosting">Problem posting to Twitter</string>
-  <string name="SocialTwitterErrorDisconnecting">Problem disconnecting from Twitter</string>
-    
+  
 	<!-- SLShare: User Friendly Filter Names Translation -->
     <string name="BlackAndWhite">Black &amp; White</string>
     <string name="Colors1970">1970&apos;s Colors</string>
@@ -3656,13 +3642,6 @@ If you continue to receive this message, contact the [SUPPORT_SITE].
     Drag items from inventory here
   </string>
 
-  <string name="flickr_post_success">
-    You posted to Flickr.
-  </string>
-  <string name="twitter_post_success">
-    You posted to Twitter.
-  </string>
-
   <string name="no_session_message">
     (IM Session Doesn't Exist)
   </string>
@@ -4088,7 +4067,6 @@ Try enclosing path to the editor with double quotes.
   <string name="Command_Conversations_Label">Conversations</string>
   <string name="Command_Compass_Label">Compass</string>
   <string name="Command_Destinations_Label">Destinations</string>
-  <string name="Command_Flickr_Label">Flickr</string>
   <string name="Command_Gestures_Label">Gestures</string>
   <string name="Command_Grid_Status_Label">Grid status</string>
   <string name="Command_HowTo_Label">How to</string>
@@ -4107,7 +4085,6 @@ Try enclosing path to the editor with double quotes.
   <string name="Command_Search_Label">Search</string>
   <string name="Command_Snapshot_Label">Snapshot</string>
   <string name="Command_Speak_Label">Speak</string>
-  <string name="Command_Twitter_Label">Twitter</string>
   <string name="Command_View_Label">Camera controls</string>
   <string name="Command_Voice_Label">Voice settings</string>
 
@@ -4119,7 +4096,6 @@ Try enclosing path to the editor with double quotes.
   <string name="Command_Conversations_Tooltip">Converse with everyone</string>
   <string name="Command_Compass_Tooltip">Compass</string>
   <string name="Command_Destinations_Tooltip">Destinations of interest</string>
-  <string name="Command_Flickr_Tooltip">Upload to Flickr</string>
   <string name="Command_Gestures_Tooltip">Gestures for your avatar</string>
   <string name="Command_Grid_Status_Tooltip">Show current Grid status</string>
   <string name="Command_HowTo_Tooltip">How to do common tasks</string>
@@ -4138,7 +4114,6 @@ Try enclosing path to the editor with double quotes.
   <string name="Command_Search_Tooltip">Find places, events, people</string>
   <string name="Command_Snapshot_Tooltip">Take a picture</string>
   <string name="Command_Speak_Tooltip">Speak with people nearby using your microphone</string>
-  <string name="Command_Twitter_Tooltip">Twitter</string>
   <string name="Command_View_Tooltip">Changing camera angle</string>
   <string name="Command_Voice_Tooltip">Volume controls for calls and people near you in world</string>
 
diff --git a/indra/newview/tests/llxmlrpclistener_test.cpp b/indra/newview/tests/llxmlrpclistener_test.cpp
index 6e9756e7d5305f9b8fd3e0a4b9242ac8d4420ee6..dbaae7280c6f71080ab59ff2cc65c8fed41a94bb 100644
--- a/indra/newview/tests/llxmlrpclistener_test.cpp
+++ b/indra/newview/tests/llxmlrpclistener_test.cpp
@@ -88,15 +88,9 @@ namespace tut
         WrapLLErrs capture;
         LLSD request;
         request["uri"] = uri;
-        std::string threw;
-        try
-        {
-            pumps.obtain("LLXMLRPCTransaction").post(request);
-        }
-        catch (const WrapLLErrs::FatalException& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = capture.catch_llerrs([&pumps, &request](){
+                pumps.obtain("LLXMLRPCTransaction").post(request);
+            });
         ensure_contains("threw exception", threw, "missing params");
         ensure_contains("identified missing", threw, "method");
         ensure_contains("identified missing", threw, "reply");
@@ -113,15 +107,9 @@ namespace tut
         request["reply"] = "reply";
         LLSD& params(request["params"]);
         params["who"]["specifically"] = "world"; // LLXMLRPCListener only handles scalar params
-        std::string threw;
-        try
-        {
-            pumps.obtain("LLXMLRPCTransaction").post(request);
-        }
-        catch (const WrapLLErrs::FatalException& e)
-        {
-            threw = e.what();
-        }
+        std::string threw = capture.catch_llerrs([&pumps, &request](){
+                pumps.obtain("LLXMLRPCTransaction").post(request);
+            });
         ensure_contains("threw exception", threw, "unknown type");
     }
 
diff --git a/indra/test/catch_and_store_what_in.h b/indra/test/catch_and_store_what_in.h
index 59f8cc008585769dfe250e4c4ddde6059129cd43..5beba06024368dd878bd207484055c7600c3e7d3 100644
--- a/indra/test/catch_and_store_what_in.h
+++ b/indra/test/catch_and_store_what_in.h
@@ -2,7 +2,7 @@
  * @file   catch_and_store_what_in.h
  * @author Nat Goodspeed
  * @date   2012-02-15
- * @brief  CATCH_AND_STORE_WHAT_IN() macro
+ * @brief  catch_what() template function, CATCH_AND_STORE_WHAT_IN() macro
  * 
  * $LicenseInfo:firstyear=2012&license=viewerlgpl$
  * Copyright (c) 2012, Linden Research, Inc.
@@ -12,6 +12,30 @@
 #if ! defined(LL_CATCH_AND_STORE_WHAT_IN_H)
 #define LL_CATCH_AND_STORE_WHAT_IN_H
 
+/**
+ * In the brave new world of lambdas, we can use a nicer C++ idiom for testing
+ * exceptions than CATCH_AND_STORE_WHAT_IN() below, e.g.:
+ *
+ * @code
+ * std::string threw = catch_what<std::runtime_error>(
+ *     [](){ throw std::runtime_error("badness"); });
+ * ensure_equals(threw, "badness");
+ * @endcode
+ */
+template <typename EXCEPTION, typename FUNC>
+std::string catch_what(FUNC func)
+{
+    try
+    {
+        func();
+        return {};
+    }
+    catch (const EXCEPTION& err)
+    {
+        return err.what();
+    }
+}
+
 /**
  * Idiom useful for test programs: catch an expected exception, store its
  * what() string in a specified std::string variable. From there the caller
diff --git a/indra/test/llevents_tut.cpp b/indra/test/llevents_tut.cpp
index 16edab628229e6afad61886f43947fa2af17a167..3abae3e43ef4802be2b52b9d719f79e9e95fbd11 100644
--- a/indra/test/llevents_tut.cpp
+++ b/indra/test/llevents_tut.cpp
@@ -134,17 +134,15 @@ void events_object::test<1>()
 		per_frame.post(4);
 		check_listener("re-blocked", listener0, 3);
 	} // unblock
-	std::string threw;
-	try
-	{
-		// NOTE: boost::bind() saves its arguments by VALUE! If you pass
-		// an object instance rather than a pointer, you'll end up binding
-		// to an internal copy of that instance! Use boost::ref() to
-		// capture a reference instead.
-		per_frame.listen(listener0.getName(), // note bug, dup name
-						 boost::bind(&Listener::call, boost::ref(listener1), _1));
-	}
-	CATCH_AND_STORE_WHAT_IN(threw, LLEventPump::DupListenerName)
+	std::string threw = catch_what<LLEventPump::DupListenerName>(
+		[&per_frame, this](){
+			// NOTE: boost::bind() saves its arguments by VALUE! If you pass
+			// an object instance rather than a pointer, you'll end up binding
+			// to an internal copy of that instance! Use boost::ref() to
+			// capture a reference instead.
+			per_frame.listen(listener0.getName(), // note bug, dup name
+							 boost::bind(&Listener::call, boost::ref(listener1), _1));
+		});
 	ensure_equals(threw,
 				  std::string("DupListenerName: "
 							  "Attempt to register duplicate listener name '") +
@@ -341,15 +339,13 @@ void events_object::test<7>()
 	ensure_equals(collector.result, make<StringVec>(list_of("Mary")("spot")("checked")));
 	collector.clear();
 	button.stopListening("spot");
-	std::string threw;
-	try
-	{
-		button.listen("spot",
-					  boost::bind(&Collect::add, boost::ref(collector), "spot", _1),
-					  // after "Mary" and "checked" -- whoops!
-			 		  make<NameList>(list_of("Mary")("checked")));
-	}
-	CATCH_AND_STORE_WHAT_IN(threw, LLEventPump::Cycle)
+	std::string threw = catch_what<LLEventPump::Cycle>(
+		[&button, &collector](){
+			button.listen("spot",
+						  boost::bind(&Collect::add, boost::ref(collector), "spot", _1),
+						  // after "Mary" and "checked" -- whoops!
+						  make<NameList>(list_of("Mary")("checked")));
+		});
 	// Obviously the specific wording of the exception text can
 	// change; go ahead and change the test to match.
 	// Establish that it contains:
@@ -374,15 +370,13 @@ void events_object::test<7>()
 	button.post(3);
 	ensure_equals(collector.result, make<StringVec>(list_of("Mary")("checked")("yellow")("shoelaces")));
 	collector.clear();
-	threw.clear();
-	try
-	{
-		button.listen("of",
-					  boost::bind(&Collect::add, boost::ref(collector), "of", _1),
-					  make<NameList>(list_of("shoelaces")),
-					  make<NameList>(list_of("yellow")));
-	}
-	CATCH_AND_STORE_WHAT_IN(threw, LLEventPump::OrderChange)
+	threw = catch_what<LLEventPump::OrderChange>(
+		[&button, &collector](){
+			button.listen("of",
+						  boost::bind(&Collect::add, boost::ref(collector), "of", _1),
+						  make<NameList>(list_of("shoelaces")),
+						  make<NameList>(list_of("yellow")));
+		});
 	// Same remarks about the specific wording of the exception. Just
 	// ensure that it contains enough information to clarify the
 	// problem and what must be done to resolve it.
@@ -404,13 +398,11 @@ void events_object::test<8>()
 	{ 	// nested scope
 		// Hand-instantiate an LLEventStream...
 		LLEventStream bob("bob");
-		std::string threw;
-		try
-		{
-			// then another with a duplicate name.
-			LLEventStream bob2("bob");
-		}
-		CATCH_AND_STORE_WHAT_IN(threw, LLEventPump::DupPumpName)
+		std::string threw = catch_what<LLEventPump::DupPumpName>(
+			[](){
+				// then another with a duplicate name.
+				LLEventStream bob2("bob");
+			});
 		ensure("Caught DupPumpName", !threw.empty());
 	} 	// delete first 'bob'
 	LLEventStream bob("bob"); 		// should work, previous one unregistered
@@ -445,13 +437,11 @@ void events_object::test<9>()
 	listener0.listenTo(random);
 	eventSource("random");
 	check_listener("got by pump name", listener0, 17);
-	std::string threw;
-	try
-	{
-		LLListenerOrPumpName empty;
-		empty(17);
-	}
-	CATCH_AND_STORE_WHAT_IN(threw, LLListenerOrPumpName::Empty)
+	std::string threw = catch_what<LLListenerOrPumpName::Empty>(
+		[](){
+			LLListenerOrPumpName empty;
+			empty(17);
+		});
 
 	ensure("threw Empty", !threw.empty());
 }
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index 861ec1d942fac8120aac7435dbf6fdbe5106ca7b..b14c2eb255a5a1ca657b426749315cb3602808f5 100644
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -37,7 +37,6 @@
 #include "linden_common.h"
 #include "llerrorcontrol.h"
 #include "lltut.h"
-#include "tests/wrapllerrs.h"             // RecorderProxy
 #include "stringize.h"
 #include "namedtempfile.h"
 #include "lltrace.h"
@@ -254,7 +253,7 @@ class LLTestCallback : public tut::callback
 				break;
 			case tut::test_result::ex:
 				++mFailedTests;
-				out << "exception";
+				out << "exception: " << tr.exception_typeid;
 				break;
 			case tut::test_result::warn:
 				++mFailedTests;
@@ -265,7 +264,7 @@ class LLTestCallback : public tut::callback
 				out << "abnormal termination";
 				break;
 			case tut::test_result::skip:
-				++mSkippedTests;			
+				++mSkippedTests;
 				out << "skipped known failure";
 				break;
 			default: