diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6ab6cf87dfe6759a5a602b73010fa22bcd214dad..667f8a3a2c1eb45626bfb265e6aa3a6465405dfa 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -218,8 +218,6 @@
 #include "llgesturemgr.h"
 #include "llsky.h"
 #include "llvlmanager.h"
-#include "llviewercamera.h"
-#include "lldrawpoolbump.h"
 #include "llvieweraudio.h"
 #include "llimview.h"
 #include "llviewerthrottle.h"
@@ -231,7 +229,6 @@
 // Include for security api initialization
 #include "llsecapi.h"
 #include "llsecapicerthandler.h"
-#include "llmachineid.h"
 #include "llmainlooprepeater.h"
 #include "llcleanup.h"
 
@@ -397,7 +394,7 @@ const char* const VIEWER_WINDOW_CLASSNAME = "Alchemy";
  * Tasks added to this list will be executed in the next LLAppViewer::idle() iteration.
  * All tasks are executed only once.
  */
-class LLDeferredTaskList: public LLSingleton<LLDeferredTaskList>
+class LLDeferredTaskList : public LLSingleton<LLDeferredTaskList>
 {
 	LLSINGLETON(LLDeferredTaskList);
 	LOG_CLASS(LLDeferredTaskList);
@@ -833,7 +830,7 @@ bool LLAppViewer::init()
 
 	LL_INFOS("InitInfo") << "LLCore::Http initialized." << LL_ENDL ;
 
-    LLMachineID::init();
+    mMachineId.init();
 
 	{
 		if (gSavedSettings.getBool("QAModeMetrics"))
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index daaa9098bcfb1687945fc9c6f721561161f34bab..2d24720f103b73babee68543171d0e2cf3cb50ce 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -49,6 +49,7 @@
 #include "llsys.h"			// for LLOSInfo
 #include "lltimer.h"
 #include "llappcorehttp.h"
+#include "llmachineid.h"
 #include "lltrace.h"
 
 class LLCommandLineParser;
@@ -197,6 +198,9 @@ public:
 
 	// llcorehttp init/shutdown/config information.
 	LLAppCoreHttp & getAppCoreHttp()			{ return mAppCoreHttp; }
+
+    // LLMachineID instance
+    LLMachineID& getMachineID()                 { return mMachineId; }
 	
 protected:
 	virtual bool initWindow(); // Initialize the viewer's window.
@@ -303,7 +307,9 @@ private:
 	// llcorehttp library init/shutdown helper
 	LLAppCoreHttp mAppCoreHttp;
 
-        bool mIsFirstRun;
+    LLMachineID mMachineId;
+
+    bool mIsFirstRun;
 	U64 mMinMicroSecPerFrame; // frame throttling
 
 
diff --git a/indra/newview/llhasheduniqueid.cpp b/indra/newview/llhasheduniqueid.cpp
index c9f2bed95057582c5501895b634c0d673de65737..339007f827c9dc51f314018e420450721136660e 100644
--- a/indra/newview/llhasheduniqueid.cpp
+++ b/indra/newview/llhasheduniqueid.cpp
@@ -26,20 +26,17 @@
 
 #include "llviewerprecompiledheaders.h"
 #include "llhasheduniqueid.h"
-#include "llviewernetwork.h"
-#include "lluuid.h"
-#include "llmachineid.h"
+#include "llappviewer.h"
 
 bool llHashedUniqueID(unsigned char id[MD5HEX_STR_SIZE])
 {
 	bool idIsUnique = true;
 	LLMD5 hashed_unique_id;
-	unsigned char unique_id[LLMachineID::UNIQUE_ID_BYTES];
-	if (   LLUUID::getNodeID(unique_id)
-		|| LLMachineID::getUniqueID(unique_id, sizeof(unique_id))
-		)
+	U8 unique_id[32];
+	U32 id_length = LLAppViewer::instance()->getMachineID().getUniqueID(unique_id, sizeof(unique_id));
+	if (id_length)
 	{
-		hashed_unique_id.update(unique_id, MAC_ADDRESS_BYTES);
+		hashed_unique_id.update(unique_id, id_length);
 		hashed_unique_id.finalize();
 		hashed_unique_id.hex_digest((char*)id);
 		LL_INFOS_ONCE("AppInit") << "System ID " << id << LL_ENDL;
diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp
index 619ff76e0479def8f9fcb27cb7a636e0db8f4fb6..cec173729b7dd4e2b92a1a00cb5176ddbf0d4ba7 100644
--- a/indra/newview/llmachineid.cpp
+++ b/indra/newview/llmachineid.cpp
@@ -25,21 +25,20 @@
  */
 
 #include "llviewerprecompiledheaders.h"
-#include "lluuid.h"
 #include "llmachineid.h"
+#include <system_error>
+
 #if	defined(LL_WINDOWS)
 #  define _WIN32_DCOM
-#  include <iostream>
 #  include <comdef.h>
 #  include <Wbemidl.h>
 #elif defined(LL_DARWIN)
 #  include <CoreFoundation/CoreFoundation.h>
 #  include <IOKit/IOKitLib.h>
+#else
+#  include "lluuid.h"
 #endif
 
-unsigned char static_unique_id[LLMachineID::UNIQUE_ID_BYTES] =  { 0 };
-bool static has_static_unique_id = false;
-
 #ifdef LL_WINDOWS
 class LLComInitialize
 {
@@ -48,14 +47,16 @@ public:
     LLComInitialize()
     {
         mHR = CoInitializeEx(0, COINIT_MULTITHREADED);
-        if (FAILED(mHR))
+        if (FAILED(mHR)) {
             LL_DEBUGS("AppInit") << "Failed to initialize COM library. Error code = 0x" << std::hex << mHR << std::dec << LL_ENDL;
+        }
     }
 
     ~LLComInitialize()
     {
-        if (SUCCEEDED(mHR))
+        if (SUCCEEDED(mHR)) {
             CoUninitialize();
+        }
     }
 };
 
@@ -65,13 +66,18 @@ public:
 // NOT THREAD SAFE - do before setting up threads.
 // Keying on MAC address for this is stupid. lol
 
-S32 LLMachineID::init()
+LLMachineID::LLMachineID() : mIdLength(0)
+{
+    memset(mUniqueId, 0, sizeof(mUniqueId));
+}
+
+bool LLMachineID::init()
 {
-    memset(static_unique_id, 0, sizeof(static_unique_id));
-    S32 ret_code = 0;
+    mIdLength = 0;
+    memset(mUniqueId, 0, sizeof(mUniqueId));
+    
 #ifdef LL_WINDOWS
 # pragma comment(lib, "wbemuuid.lib")
-        size_t len = sizeof(static_unique_id);
 
         // algorithm to detect BIOS serial number found at:
         // http://msdn.microsoft.com/en-us/library/aa394077%28VS.85%29.aspx
@@ -107,8 +113,8 @@ S32 LLMachineID::init()
                           
         if (FAILED(hres))
         {
-            LL_WARNS("AppInit") << "Failed to initialize security. Error code = 0x"  << std::hex << hres << std::dec << LL_ENDL;
-            return 1;                    // Program has failed.
+            LL_WARNS("AppInit") << "Failed to initialize security: " << std::system_category().message(hres) << LL_ENDL;
+            return false;                    // Program has failed.
         }
         
         // Step 3: ---------------------------------------------------
@@ -120,12 +126,12 @@ S32 LLMachineID::init()
             CLSID_WbemLocator,             
             nullptr, 
             CLSCTX_INPROC_SERVER, 
-            IID_IWbemLocator, (LPVOID *) &pLoc);
+            IID_IWbemLocator, reinterpret_cast<LPVOID*>(&pLoc));
      
         if (FAILED(hres))
         {
-            LL_WARNS("AppInit") << "Failed to create IWbemLocator object." << " Err code = 0x" << std::hex << hres << std::dec << LL_ENDL;
-            return 1;                 // Program has failed.
+            LL_WARNS("AppInit") << "Failed to create IWbemLocator object: " << std::system_category().message(hres) << LL_ENDL;
+            return false;                 // Program has failed.
         }
 
         // Step 4: -----------------------------------------------------
@@ -149,9 +155,9 @@ S32 LLMachineID::init()
         
         if (FAILED(hres))
         {
-            LL_WARNS("AppInit") << "Could not connect. Error code = 0x"  << std::hex << hres << std::dec << LL_ENDL;
+            LL_WARNS("AppInit") << "Could not connect:" << std::system_category().message(hres) << LL_ENDL;
             pLoc->Release();     
-            return 1;                // Program has failed.
+            return false;                // Program has failed.
         }
 
         LL_DEBUGS("AppInit") << "Connected to ROOT\\CIMV2 WMI namespace" << LL_ENDL;
@@ -173,10 +179,10 @@ S32 LLMachineID::init()
 
         if (FAILED(hres))
         {
-            LL_WARNS("AppInit") << "Could not set proxy blanket. Error code = 0x"   << std::hex << hres << std::dec << LL_ENDL;
+            LL_WARNS("AppInit") << "Could not set proxy blanket: " << std::system_category().message(hres) << LL_ENDL;
             pSvc->Release();
             pLoc->Release();     
-            return 1;               // Program has failed.
+            return false;               // Program has failed.
         }
 
         // Step 6: --------------------------------------------------
@@ -193,10 +199,10 @@ S32 LLMachineID::init()
         
         if (FAILED(hres))
         {
-            LL_WARNS("AppInit") << "Query for operating system name failed." << " Error code = 0x"  << std::hex << hres << std::dec << LL_ENDL;
+            LL_WARNS("AppInit") << "Query for operating system name failed: " << std::system_category().message(hres) << LL_ENDL;
             pSvc->Release();
             pLoc->Release();
-            return 1;               // Program has failed.
+            return false;               // Program has failed.
         }
 
         // Step 7: -------------------------------------------------
@@ -220,19 +226,11 @@ S32 LLMachineID::init()
             // Get the value of the Name property
             hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, nullptr, nullptr);
             LL_INFOS("AppInit") << " Serial Number : " << vtProp.bstrVal << LL_ENDL;
-            // use characters in the returned Serial Number to create a byte array of size len
+            // use characters in the returned Serial Number to create a byte array
             BSTR serialNumber ( vtProp.bstrVal);
-            unsigned int j = 0;
-            while( vtProp.bstrVal[j] != 0)
+            for (; mIdLength < sizeof(mUniqueId) && vtProp.bstrVal[mIdLength] != 0; ++mIdLength)
             {
-                for (unsigned int i = 0; i < len; i++)
-                {
-                    if (vtProp.bstrVal[j] == 0)
-                        break;
-                    
-                    static_unique_id[i] = (unsigned int)(static_unique_id[i] + serialNumber[j]);
-                    j++;
-                }
+                mUniqueId[mIdLength] = serialNumber[mIdLength];
             }
             VariantClear(&vtProp);
 
@@ -244,13 +242,10 @@ S32 LLMachineID::init()
         // Cleanup
         // ========
         
-        if (pSvc)
-            pSvc->Release();
-        if (pLoc)
-            pLoc->Release();
-        if (pEnumerator)
-            pEnumerator->Release();
-        ret_code=0;
+        if (pSvc) { pSvc->Release(); }
+        if (pLoc) { pLoc->Release(); }
+        if (pEnumerator) { pEnumerator->Release(); }
+
 #elif defined(LL_DARWIN)
     // Apple best practice is to key to the system's serial number
     // https://developer.apple.com/library/archive/technotes/tn1103/_index.html
@@ -269,42 +264,51 @@ S32 LLMachineID::init()
                                         expert, CFSTR(kIOPlatformSerialNumberKey),
                                         kCFAllocatorDefault, 0);
         if (cf_prop) {
-            char buffer[32] = {0};
+            char buffer[sizeof(mUniqueId)] = {0};
             CFStringRef serial = (CFStringRef)cf_prop;
             if (CFStringGetCString(serial, buffer, sizeof(buffer), kCFStringEncodingUTF8)) {
-                memcpy(static_unique_id, buffer, sizeof(static_unique_id));
+                for (; mIdLength < sizeof(mUniqueId) && buffer != '\0'; ++mIdLength)
+                {
+                    mUniqueId[mIdLength] = serialNumber[mIdLength];
+                }
             }
         }
         IOObjectRelease(expert);
     }
-#else // that means you leenox!
-        unsigned char * staticPtr = (unsigned char *)(&static_unique_id[0]);
-        ret_code = LLUUID::getNodeID(staticPtr);
+#else
+    if (LLUUID::getNodeID(mUniqueId) == 1)
+    {
+        mIdLength = 6; // getNodeID output is always 6 bytes
+    }
 #endif
-        has_static_unique_id = true;
-        return ret_code;
+    return (mIdLength != 0);
 }
 
 
-S32 LLMachineID::getUniqueID(unsigned char *unique_id, size_t len)
+U32 LLMachineID::getUniqueID(U8 unique_id[32], size_t len) const
 {
-    if (has_static_unique_id)
+    size_t length = 0;
+    if (mIdLength)
     {
-        memcpy ( unique_id, &static_unique_id, len);
+        memset(unique_id, 0, len);
+        for (; length < len && length < mIdLength; ++length)
+        {
+            unique_id[length] = mUniqueId[length];
+        }
+
         LL_INFOS_ONCE("AppInit") << "UniqueID: 0x";
         // Code between here and LL_ENDL is not executed unless the LL_DEBUGS
         // actually produces output
-        for (size_t i = 0; i < len; ++i)
+        for (size_t i = 0; i < length; ++i)
         {
             // Copy each char to unsigned int to hexify. Sending an unsigned
             // char to a std::ostream tries to represent it as a char, not
             // what we want here.
-            unsigned byte = unique_id[i];
+            U32 byte = static_cast<U32>(unique_id[i]);
             LL_CONT << std::hex << std::setw(2) << std::setfill('0') << byte;
         }
         // Reset default output formatting to avoid nasty surprises!
         LL_CONT << std::dec << std::setw(0) << std::setfill(' ') << LL_ENDL;
-        return 1;
     }
-    return 0;
+    return length;
 }
diff --git a/indra/newview/llmachineid.h b/indra/newview/llmachineid.h
index 87fd2a0563ff3f9d6e445189800cc440f605b0b0..969d2fb66989fbd00c3fdf30d731500fa18d8f02 100644
--- a/indra/newview/llmachineid.h
+++ b/indra/newview/llmachineid.h
@@ -27,29 +27,19 @@
 #ifndef LL_LLMACHINEID_H
 #define LL_LLMACHINEID_H
 
+#include "stdtypes.h"
+
 class LLMachineID 
 {
 public:
 	LLMachineID();
-	virtual	~LLMachineID();
-    static S32 getUniqueID(unsigned char *unique_id, size_t len);
-    static S32 init();
-
-#if defined(LL_DARWIN)
-	static constexpr U32 UNIQUE_ID_BYTES = 12;
-#else
-	static constexpr U32 UNIQUE_ID_BYTES = 6;
-#endif
-    
-protected:
+	virtual	~LLMachineID() = default;
+    U32 getUniqueID(U8 unique_id[32], size_t len) const;
+    bool init();
 
 private:
-
-
+    U32 mIdLength;
+    U8 mUniqueId[32];
 };
 
-
-
-
-
 #endif // LL_LLMACHINEID_H
diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp
index c2aec25dadc09f0568d1ba9c7a8611c0f30bac4f..3d639b95685564c8f2b1a13a290b5d8f54840dd6 100644
--- a/indra/newview/llsechandler_basic.cpp
+++ b/indra/newview/llsechandler_basic.cpp
@@ -31,19 +31,17 @@
 #include "llsechandler_basic.h"
 
 #include "llsdserialize.h"
-#include "llviewernetwork.h"
 #include "llxorcipher.h"
 #include "llfile.h"
 #include "lldir.h"
 #include "llviewercontrol.h"
 #include "llexception.h"
 #include "stringize.h"
-#include "llmachineid.h"
+#include "llappviewer.h"
 
 #include <openssl/evp.h>
 #include <openssl/rand.h>
 #include <vector>
-#include <iostream>
 #include <iomanip>
 #include <ctime>
 
@@ -98,9 +96,9 @@ void compat_rc4(llifstream &protected_data_stream, std::string &decrypted_data)
 	U8 buffer[BUFFER_READ_SIZE];
 	U8 decrypted_buffer[BUFFER_READ_SIZE];
 	int decrypted_length;
-	unsigned char unique_id[LLMachineID::UNIQUE_ID_BYTES];
-	LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
-	LLXORCipher cipher(unique_id, sizeof(unique_id));
+	U8 unique_id[32];
+	U32 id_len = LLAppViewer::instance()->getMachineID().getUniqueID(unique_id, sizeof(unique_id));
+	LLXORCipher cipher(unique_id, id_len);
 
 	// read in the salt and key
 	protected_data_stream.read((char *)salt, COMPAT_STORE_SALT_SIZE);
@@ -141,9 +139,9 @@ void LLSecAPIBasicHandler::_readProtectedData()
 		U8 buffer[BUFFER_READ_SIZE];
 		U8 decrypted_buffer[BUFFER_READ_SIZE];
 		int decrypted_length;	
-		unsigned char unique_id[LLMachineID::UNIQUE_ID_BYTES];
-        LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
-		LLXORCipher cipher(unique_id, sizeof(unique_id));
+		U8 unique_id[32];
+        U32 id_len = LLAppViewer::instance()->getMachineID().getUniqueID(unique_id, sizeof(unique_id));
+		LLXORCipher cipher(unique_id, id_len);
 
 		// read in the salt and key
 		protected_data_stream.read((char *)salt, STORE_SALT_SIZE);
@@ -236,9 +234,9 @@ void LLSecAPIBasicHandler::_writeProtectedData()
 		
 		EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
 		EVP_CipherInit_ex(ctx, EVP_chacha20(), NULL, salt, NULL, 1); // 1 is encrypt
-		unsigned char unique_id[LLMachineID::UNIQUE_ID_BYTES];
-        LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
-		LLXORCipher cipher(unique_id, sizeof(unique_id));
+		U8 unique_id[32];
+        U32 id_len = LLAppViewer::instance()->getMachineID().getUniqueID(unique_id, sizeof(unique_id));
+		LLXORCipher cipher(unique_id, id_len);
 		cipher.encrypt(salt, STORE_SALT_SIZE);
 		protected_data_stream.write((const char *)salt, STORE_SALT_SIZE);
 
@@ -495,9 +493,9 @@ std::string LLSecAPIBasicHandler::_legacyLoadPassword()
 	}
 	
 	// Decipher with MAC address
-	unsigned char unique_id[LLMachineID::UNIQUE_ID_BYTES];
-    LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
-	LLXORCipher cipher(unique_id, sizeof(unique_id));
+	U8 unique_id[32];
+    U32 id_len = LLAppViewer::instance()->getMachineID().getUniqueID(unique_id, sizeof(unique_id));
+	LLXORCipher cipher(unique_id, id_len);
 	cipher.decrypt(&buffer[0], buffer.size());
 	
 	return std::string(reinterpret_cast<const char*>(&buffer[0]), buffer.size());