diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp
index b2b17fdd56583a7e71b5aef873a1478ec8f8c63a..da4abde451f203a3204464323d119febdc4abbd3 100644
--- a/indra/llvfs/lldir.cpp
+++ b/indra/llvfs/lldir.cpp
@@ -200,6 +200,11 @@ const std::string &LLDir::getOSUserAppDir() const
 
 const std::string &LLDir::getLindenUserDir() const
 {
+	if (mLindenUserDir.empty())
+	{
+		lldebugs << "getLindenUserDir() called early, we don't have the user name yet - returning empty string to caller" << llendl;
+	}
+
 	return mLindenUserDir;
 }
 
@@ -337,7 +342,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
 		break;
 		
 	case LL_PATH_CACHE:
-	    prefix = getCacheDir();
+		prefix = getCacheDir();
 		break;
 		
 	case LL_PATH_USER_SETTINGS:
@@ -348,6 +353,11 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
 
 	case LL_PATH_PER_SL_ACCOUNT:
 		prefix = getLindenUserDir();
+		if (prefix.empty())
+		{
+			// if we're asking for the per-SL-account directory but we haven't logged in yet (or otherwise don't know the account name from which to build this string), then intentionally return a blank string to the caller and skip the below warning about a blank prefix.
+			return std::string();
+		}
 		break;
 		
 	case LL_PATH_CHAT_LOGS:
@@ -557,7 +567,7 @@ std::string LLDir::getForbiddenFileChars()
 
 void LLDir::setLindenUserDir(const std::string &first, const std::string &last)
 {
-	// if both first and last aren't set, assume we're grabbing the cached dir
+	// if both first and last aren't set, that's bad.
 	if (!first.empty() && !last.empty())
 	{
 		// some platforms have case-sensitive filesystems, so be
@@ -571,6 +581,7 @@ void LLDir::setLindenUserDir(const std::string &first, const std::string &last)
 		mLindenUserDir += firstlower;
 		mLindenUserDir += "_";
 		mLindenUserDir += lastlower;
+		llinfos << "Got name for LLDir::setLindenUserDir(first='" << first << "', last='" << last << "')" << llendl;
 	}
 	else
 	{
diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h
index 206e3223e3bdce1e097b1c9dce55fc053e1b4854..9067d75bacad7a978d085edf0898ea7ab312b385 100644
--- a/indra/llvfs/lldir.h
+++ b/indra/llvfs/lldir.h
@@ -44,7 +44,7 @@ typedef enum ELLPath
 	LL_PATH_NONE = 0,
 	LL_PATH_USER_SETTINGS = 1,
 	LL_PATH_APP_SETTINGS = 2,	
-	LL_PATH_PER_SL_ACCOUNT = 3,	
+	LL_PATH_PER_SL_ACCOUNT = 3, // returns/expands to blank string if we don't know the account name yet
 	LL_PATH_CACHE = 4,	
 	LL_PATH_CHARACTER = 5,	
 	LL_PATH_HELP = 6,		
diff --git a/indra/llvfs/lldir_linux.cpp b/indra/llvfs/lldir_linux.cpp
index ee902d1de791e3e245e1e16169a4569141230493..a9736560eca049c1eb908622dd19d6f3bcba1c2c 100644
--- a/indra/llvfs/lldir_linux.cpp
+++ b/indra/llvfs/lldir_linux.cpp
@@ -112,9 +112,10 @@ LLDir_Linux::LLDir_Linux()
 		// ...normal installation running
 		mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins";
     }	
+
 	mOSUserDir = getCurrentUserHome(tmp_str);
 	mOSUserAppDir = "";
-	mLindenUserDir = tmp_str;
+	mLindenUserDir = "";
 
 	char path [32];	/* Flawfinder: ignore */ 
 
diff --git a/indra/llvfs/lldir_solaris.cpp b/indra/llvfs/lldir_solaris.cpp
index a8fad8e5bdf7b1fcad74a08138edf7ad6b46f10f..8ac5a41e934cb1bb9935d9caa6cbea3cfc2e05e3 100644
--- a/indra/llvfs/lldir_solaris.cpp
+++ b/indra/llvfs/lldir_solaris.cpp
@@ -100,7 +100,7 @@ LLDir_Solaris::LLDir_Solaris()
 	mAppRODataDir = strdup(tmp_str);
 	mOSUserDir = getCurrentUserHome(tmp_str);
 	mOSUserAppDir = "";
-	mLindenUserDir = tmp_str;
+	mLindenUserDir = "";
 
 	char path [LL_MAX_PATH];	/* Flawfinder: ignore */ 
 
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 4a61096ad8a0fb734ec0a502ff346e0b895107f6..704198aff53ee2bbab68e42b531340a748e49308 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1480,8 +1480,15 @@ bool LLAppViewer::cleanup()
 
 	// PerAccountSettingsFile should be empty if no use has been logged on.
 	// *FIX:Mani This should get really saved in a "logoff" mode. 
-	gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
-	llinfos << "Saved settings" << llendflush;
+	if (gSavedSettings.getString("PerAccountSettingsFile").empty())
+	{
+		llinfos << "Not saving per-account settings; don't know the account name yet." << llendl;
+	}
+	else
+	{
+		gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
+		llinfos << "Saved settings" << llendflush;
+	}
 
 	std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
 	// save all settings, even if equals defaults
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index 42ae122ff911205d9e063f75a161c760eb1053fa..87b8d807c4e8f78f46abc4d6d0ff372273ab6727 100644
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -64,7 +64,7 @@ void LLAvatarIconIDCache::load	()
 	llinfos << "Loading avatar icon id cache." << llendl;
 	
 	// build filename for each user
-	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, mFilename);
+	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, mFilename);
 	llifstream file(resolved_filename);
 
 	if (!file.is_open())
@@ -97,7 +97,7 @@ void LLAvatarIconIDCache::load	()
 
 void LLAvatarIconIDCache::save	()
 {
-	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, mFilename);
+	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, mFilename);
 
 	// open a file for writing
 	llofstream file (resolved_filename);
diff --git a/indra/newview/lllocationhistory.cpp b/indra/newview/lllocationhistory.cpp
index d910dbf7185dc54c2acde60f758a03e88f475a0d..ae1b8f854080c7a3a3605b46372d451409a24f8d 100644
--- a/indra/newview/lllocationhistory.cpp
+++ b/indra/newview/lllocationhistory.cpp
@@ -123,6 +123,12 @@ void LLLocationHistory::save() const
 	// build filename for each user
 	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, mFilename);
 
+	if (resolved_filename.empty())
+	{
+		llinfos << "can't get path to location history filename - probably not logged in yet." << llendl;
+		return;
+	}
+
 	// open a file for writing
 	llofstream file (resolved_filename);
 	if (!file.is_open())
diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp
index b520bc1c2d37e0a28e791ec880ccdb464828bc52..af66b6e3de49184194e7d7fd8de3a94a5104ce56 100644
--- a/indra/newview/llmutelist.cpp
+++ b/indra/newview/llmutelist.cpp
@@ -258,7 +258,7 @@ LLMuteList::~LLMuteList()
 {
 	// If we quit from the login screen we will not have an SL account
 	// name.  Don't try to save, otherwise we'll dump a file in
-	// C:\Program Files\SecondLife\  JC
+	// C:\Program Files\SecondLife\ or similar. JC
 	std::string user_dir = gDirUtilp->getLindenUserDir();
 	if (!user_dir.empty())
 	{
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index e74a39c85cb800121bfe967671b94d65aebc410d..a5a61f0c7ba7b32b6c7c411eab2a0d0c2b8a3152 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -51,6 +51,8 @@
 #include "llviewermenu.h"
 #include "llviewertexturelist.h"
 
+const std::string FILTERS_FILENAME("filters.xml");
+
 static LLRegisterPanelClassWrapper<LLPanelMainInventory> t_inventory("panel_main_inventory");
 
 void on_file_loaded_for_save(BOOL success, 
@@ -160,7 +162,7 @@ BOOL LLPanelMainInventory::postBuild()
 
 	// Now load the stored settings from disk, if available.
 	std::ostringstream filterSaveName;
-	filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "filters.xml");
+	filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, FILTERS_FILENAME);
 	llinfos << "LLPanelMainInventory::init: reading from " << filterSaveName << llendl;
 	llifstream file(filterSaveName.str());
 	LLSD savedFilterState;
@@ -230,7 +232,7 @@ LLPanelMainInventory::~LLPanelMainInventory( void )
 	}
 
 	std::ostringstream filterSaveName;
-	filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "filters.xml");
+	filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, FILTERS_FILENAME);
 	llofstream filtersFile(filterSaveName.str());
 	if(!LLSDSerialize::toPrettyXML(filterRoot, filtersFile))
 	{
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index fbc98b7691f39be6e46520e3bef64fdd354154d6..ad88534a5dc6f6a02bb61d386ac9c1e4bee1ed9c 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -920,9 +920,9 @@ bool idle_startup()
 		// create necessary directories
 		// *FIX: these mkdir's should error check
 		gDirUtilp->setLindenUserDir(gFirstname, gLastname);
-    	LLFile::mkdir(gDirUtilp->getLindenUserDir());
-
-        // Set PerAccountSettingsFile to the default value.
+		LLFile::mkdir(gDirUtilp->getLindenUserDir());
+		
+		// Set PerAccountSettingsFile to the default value.
 		gSavedSettings.setString("PerAccountSettingsFile",
 			gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, 
 				LLAppViewer::instance()->getSettingsFilename("Default", "PerAccount")));
diff --git a/indra/newview/llurlhistory.cpp b/indra/newview/llurlhistory.cpp
index e8b5aa7c746ec23278772881ab35e6fdcb217ed1..08dd82ab863738577302dc402a04625d3e47c65c 100644
--- a/indra/newview/llurlhistory.cpp
+++ b/indra/newview/llurlhistory.cpp
@@ -77,7 +77,7 @@ bool LLURLHistory::saveFile(const std::string& filename)
 	std::string temp_str = gDirUtilp->getLindenUserDir();
 	if( temp_str.empty() )
 	{
-		llwarns << "Can't save. No user directory set." << llendl;
+		llinfos << "Can't save URL history - no user directory set yet." << llendl;
 		return false;
 	}
 
diff --git a/indra/newview/llurlwhitelist.cpp b/indra/newview/llurlwhitelist.cpp
index da69039cf9bbceab19ab738cc6c6624550b85e66..46bc9276c1429a0423f0e0316c44809fb9a1ac17 100644
--- a/indra/newview/llurlwhitelist.cpp
+++ b/indra/newview/llurlwhitelist.cpp
@@ -121,6 +121,12 @@ bool LLUrlWhiteList::save ()
 	// build filename for each user
 	std::string resolvedFilename = gDirUtilp->getExpandedFilename ( LL_PATH_PER_SL_ACCOUNT, mFilename );
 
+	if (resolvedFilename.empty())
+	{
+		llinfos << "No per-user dir for saving URL whitelist - presumably not logged in yet.  Skipping." << llendl;
+		return false;
+	}
+
 	// open a file for writing
 	llofstream file ( resolvedFilename );
 	if ( file.is_open () )
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 8252b7df003910c33844e85b46c6e4a112a08023..6bb547373c49340ea4bfdf4a140cb32fe7c0d703 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -178,7 +178,7 @@ static std::string get_texture_list_name()
 
 void LLViewerTextureList::doPrefetchImages()
 {
-    if (LLAppViewer::instance()->getPurgeCache())
+	if (LLAppViewer::instance()->getPurgeCache())
 	{
 		// cache was purged, no point
 		return;