diff --git a/indra/newview/llagentdata.cpp b/indra/newview/llagentdata.cpp
index 5f6a082d7582a0f87acf4572829022de1f776245..d2c644a06f93fd4a600e0277aaa25c316156ba06 100755
--- a/indra/newview/llagentdata.cpp
+++ b/indra/newview/llagentdata.cpp
@@ -31,3 +31,4 @@
 
 LLUUID gAgentID;
 LLUUID gAgentSessionID;
+std::string gAgentUsername;
diff --git a/indra/newview/llagentdata.h b/indra/newview/llagentdata.h
index 83d6a53d5e33dbbc26583450bdd5329ea52261cb..efdd97f6c4177b8121115e03a9f6d3dad4b15d6a 100755
--- a/indra/newview/llagentdata.h
+++ b/indra/newview/llagentdata.h
@@ -30,5 +30,6 @@
 
 extern LLUUID gAgentID;
 extern LLUUID gAgentSessionID;
+extern std::string gAgentUsername;
 
 #endif
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index f2b369a9add833a452ca161781421dd0c7c478d5..8f3eaaa207ef5d68ecb3c57d7ff500bc7d2afe94 100755
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -380,9 +380,11 @@ LLFavoritesBarCtrl::LLFavoritesBarCtrl(const LLFavoritesBarCtrl::Params& p)
 	mShowDragMarker(FALSE),
 	mLandingTab(NULL),
 	mLastTab(NULL),
-	mTabsHighlightEnabled(TRUE)
-  , mUpdateDropDownItems(true)
-,	mRestoreOverflowMenu(false)
+	mTabsHighlightEnabled(TRUE),
+	mUpdateDropDownItems(true),
+	mRestoreOverflowMenu(false),
+	mGetPrevItems(true),
+	mItemsChangedTimer()
 {
 	// Register callback for menus with current registrar (will be parent panel's registrar)
 	LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Favorites.DoToSelected",
@@ -659,6 +661,15 @@ void LLFavoritesBarCtrl::changed(U32 mask)
 			LLFavoritesOrderStorage::instance().getSLURL((*i)->getAssetUUID());
 		}
 		updateButtons();
+		if (!mItemsChangedTimer.getStarted())
+		{
+			mItemsChangedTimer.start();
+		}
+		else
+		{
+			mItemsChangedTimer.reset();
+		}
+
 	}
 }
 
@@ -693,6 +704,21 @@ void LLFavoritesBarCtrl::draw()
 		// Once drawn, mark this false so we won't draw it again (unless we hit the favorite bar again)
 		mShowDragMarker = FALSE;
 	}
+	if (mItemsChangedTimer.getStarted())
+	{
+		if (mItemsChangedTimer.getElapsedTimeF32() > 1.f)
+		{
+			LLFavoritesOrderStorage::instance().saveFavoritesRecord();
+			mItemsChangedTimer.stop();
+		}
+	}
+
+	if(!mItemsChangedTimer.getStarted() && LLFavoritesOrderStorage::instance().mUpdateRequired)
+	{
+		LLFavoritesOrderStorage::instance().mUpdateRequired = false;
+		mItemsChangedTimer.start();
+	}
+
 }
 
 const LLButton::Params& LLFavoritesBarCtrl::getButtonParams()
@@ -723,6 +749,12 @@ void LLFavoritesBarCtrl::updateButtons()
 		return;
 	}
 
+	if(mGetPrevItems)
+	{
+		LLFavoritesOrderStorage::instance().mPrevFavorites = mItems;
+		mGetPrevItems = false;
+	}
+
 	const LLButton::Params& button_params = getButtonParams();
 
 	if(mItems.empty())
@@ -844,6 +876,7 @@ void LLFavoritesBarCtrl::updateButtons()
 	{
 		mUpdateDropDownItems = false;
 	}
+
 }
 
 LLButton* LLFavoritesBarCtrl::createButton(const LLPointer<LLViewerInventoryItem> item, const LLButton::Params& button_params, S32 x_offset)
@@ -912,9 +945,11 @@ BOOL LLFavoritesBarCtrl::postBuild()
 
 BOOL LLFavoritesBarCtrl::collectFavoriteItems(LLInventoryModel::item_array_t &items)
 {
+
 	if (mFavoriteFolderId.isNull())
 		return FALSE;
 	
+
 	LLInventoryModel::cat_array_t cats;
 
 	LLIsType is_type(LLAssetType::AT_LANDMARK);
@@ -1411,6 +1446,7 @@ void LLFavoritesBarCtrl::insertItem(LLInventoryModel::item_array_t& items, const
 
 const std::string LLFavoritesOrderStorage::SORTING_DATA_FILE_NAME = "landmarks_sorting.xml";
 const S32 LLFavoritesOrderStorage::NO_INDEX = -1;
+bool LLFavoritesOrderStorage::mSaveOnExit = false;
 
 void LLFavoritesOrderStorage::setSortIndex(const LLViewerInventoryItem* inv_item, S32 sort_index)
 {
@@ -1447,6 +1483,7 @@ void LLFavoritesOrderStorage::getSLURL(const LLUUID& asset_id)
         LL_DEBUGS("FavoritesBar") << "landmark for " << asset_id << " already loaded" << LL_ENDL;
 		onLandmarkLoaded(asset_id, lm);
 	}
+	return;
 }
 
 // static
@@ -1482,13 +1519,16 @@ void LLFavoritesOrderStorage::destroyClass()
 		LLFile::remove(old_filename);
 	}
 
-	if (gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
-	{
-		LLFavoritesOrderStorage::instance().saveFavoritesSLURLs();
-	}
-	else
+	std::string filename = getSavedOrderFileName();
+	file.open(filename.c_str());
+	if (file.is_open())
 	{
-		LLFavoritesOrderStorage::instance().removeFavoritesRecordOfUser();
+		file.close();
+		LLFile::remove(filename);
+		if(mSaveOnExit)
+		{
+			LLFavoritesOrderStorage::instance().saveFavoritesRecord(true);
+		}
 	}
 }
 
@@ -1503,108 +1543,57 @@ std::string LLFavoritesOrderStorage::getSavedOrderFileName()
 
 void LLFavoritesOrderStorage::load()
 {
-	// load per-resident sorting information
 	std::string filename = getSavedOrderFileName();
-
 	LLSD settings_llsd;
 	llifstream file;
 	file.open(filename.c_str());
 	if (file.is_open())
 	{
 		LLSDSerialize::fromXML(settings_llsd, file);
-        LL_INFOS("FavoritesBar") << "loaded favorites order from '" << filename << "' "
-                                 << (settings_llsd.isMap() ? "" : "un") << "successfully"
-                                 << LL_ENDL;
-        file.close();
-	}
-    else
-    {
-        LL_WARNS("FavoritesBar") << "unable to open favorites order file at '" << filename << "'" << LL_ENDL;
-    }
-
-	for (LLSD::map_const_iterator iter = settings_llsd.beginMap();
-		iter != settings_llsd.endMap(); ++iter)
-	{
-		mSortIndexes.insert(std::make_pair(LLUUID(iter->first), (S32)iter->second.asInteger()));
+		LL_INFOS("FavoritesBar") << "loaded favorites order from '" << filename << "' "
+	                                 << (settings_llsd.isMap() ? "" : "un") << "successfully"
+	                                 << LL_ENDL;
+		file.close();
+		mSaveOnExit = true;
+
+		for (LLSD::map_const_iterator iter = settings_llsd.beginMap();
+			iter != settings_llsd.endMap(); ++iter)
+		{
+			mSortIndexes.insert(std::make_pair(LLUUID(iter->first), (S32)iter->second.asInteger()));
+		}
 	}
-}
-
-void LLFavoritesOrderStorage::saveFavoritesSLURLs()
-{
-	// Do not change the file if we are not logged in yet.
-	if (!LLLoginInstance::getInstance()->authSuccess())
+	else
 	{
-		LL_WARNS("FavoritesBar") << "Cannot save favorites: not logged in" << LL_ENDL;
-		return;
+		filename = getStoredFavoritesFilename();
+		if (!filename.empty())
+		{
+			llifstream in_file;
+			in_file.open(filename.c_str());
+			LLSD fav_llsd;
+			LLSD user_llsd;
+			if (in_file.is_open())
+			{
+				LLSDSerialize::fromXML(fav_llsd, in_file);
+				LL_INFOS("FavoritesBar") << "loaded favorites from '" << filename << "' "
+												<< (fav_llsd.isMap() ? "" : "un") << "successfully"
+												<< LL_ENDL;
+				in_file.close();
+				user_llsd = fav_llsd[gAgentUsername];
+
+				S32 index = 0;
+				for (LLSD::array_iterator iter = user_llsd.beginArray();
+						iter != user_llsd.endArray(); ++iter)
+				{
+					mSortIndexes.insert(std::make_pair(iter->get("id").asUUID(), index));
+					index++;
+				}
+			}
+			else
+			{
+				LL_WARNS("FavoritesBar") << "unable to open favorites from '" << filename << "'" << LL_ENDL;
+			}
+		}
 	}
-
-	std::string filename = getStoredFavoritesFilename();
-    if (!filename.empty())
-    {
-        llifstream in_file;
-        in_file.open(filename.c_str());
-        LLSD fav_llsd;
-        if (in_file.is_open())
-        {
-            LLSDSerialize::fromXML(fav_llsd, in_file);
-            LL_INFOS("FavoritesBar") << "loaded favorites from '" << filename << "' "
-                                     << (fav_llsd.isMap() ? "" : "un") << "successfully"
-                                     << LL_ENDL;
-            in_file.close();
-        }
-        else
-        {
-            LL_WARNS("FavoritesBar") << "unable to open favorites from '" << filename << "'" << LL_ENDL;
-        }
-
-        const LLUUID fav_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
-        LLInventoryModel::cat_array_t cats;
-        LLInventoryModel::item_array_t items;
-        gInventory.collectDescendents(fav_id, cats, items, LLInventoryModel::EXCLUDE_TRASH);
-
-        LLSD user_llsd;
-        for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++)
-        {
-            LLSD value;
-            value["name"] = (*it)->getName();
-            value["asset_id"] = (*it)->getAssetUUID();
-
-            slurls_map_t::iterator slurl_iter = mSLURLs.find(value["asset_id"]);
-            if (slurl_iter != mSLURLs.end())
-            {
-                LL_DEBUGS("FavoritesBar") << "Saving favorite: idx=" << LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID()) << ", SLURL=" <<  slurl_iter->second << ", value=" << value << LL_ENDL;
-                value["slurl"] = slurl_iter->second;
-                user_llsd[LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID())] = value;
-            }
-            else
-            {
-                LL_WARNS("FavoritesBar") << "Not saving favorite " << value["name"] << ": no matching SLURL" << LL_ENDL;
-            }
-        }
-
-        LLAvatarName av_name;
-        LLAvatarNameCache::get( gAgentID, &av_name );
-        // Note : use the "John Doe" and not the "john.doe" version of the name 
-        // as we'll compare it with the stored credentials in the login panel.
-        fav_llsd[av_name.getUserName()] = user_llsd;
-
-        llofstream file;
-        file.open(filename.c_str());
-        if ( file.is_open() )
-        {
-            LLSDSerialize::toPrettyXML(fav_llsd, file);
-            LL_INFOS("FavoritesBar") << "saved favorites for '" << av_name.getUserName()
-                                     << "' to '" << filename << "' "
-                                     << LL_ENDL;
-            file.close();
-        }
-        else
-        {
-            LL_WARNS("FavoritesBar") << "unable to open favorites storage for '" << av_name.getUserName()
-                                     << "' at '" << filename << "' "
-                                     << LL_ENDL;
-        }
-    }
 }
 
 void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
@@ -1626,8 +1615,30 @@ void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
             // See saveFavoritesSLURLs() here above for the reason why.
             if (fav_llsd.has(av_name.getUserName()))
             {
-                LL_INFOS("FavoritesBar") << "Removed favorites for " << av_name.getUserName() << LL_ENDL;
-                fav_llsd.erase(av_name.getUserName());
+            	LLSD user_llsd = fav_llsd[av_name.getUserName()];
+
+            	if (user_llsd.beginArray()->has("id"))
+            	{
+            		for (LLSD::array_iterator iter = user_llsd.beginArray();iter != user_llsd.endArray(); ++iter)
+            		{
+            			LLSD value;
+            			value["id"]= iter->get("id").asUUID();
+            			iter->assign(value);
+            		}
+            		fav_llsd[av_name.getUserName()] = user_llsd;
+            		llofstream file;
+            		file.open(filename.c_str());
+            		if ( file.is_open() )
+            		{
+            				LLSDSerialize::toPrettyXML(fav_llsd, file);
+            				file.close();
+            		}
+            	}
+            	else
+            	{
+            		LL_INFOS("FavoritesBar") << "Removed favorites for " << av_name.getUserName() << LL_ENDL;
+            		fav_llsd.erase(av_name.getUserName());
+            	}
             }
         
             llofstream out_file;
@@ -1648,20 +1659,20 @@ void LLFavoritesOrderStorage::onLandmarkLoaded(const LLUUID& asset_id, LLLandmar
 	if (landmark)
     {
         LL_DEBUGS("FavoritesBar") << "landmark for " << asset_id << " loaded" << LL_ENDL;
-	LLVector3d pos_global;
-	if (!landmark->getGlobalPos(pos_global))
-	{
-		// If global position was unknown on first getGlobalPos() call
-		// it should be set for the subsequent calls.
-		landmark->getGlobalPos(pos_global);
-	}
+        LLVector3d pos_global;
+        if (!landmark->getGlobalPos(pos_global))
+        {
+        	// If global position was unknown on first getGlobalPos() call
+        	// it should be set for the subsequent calls.
+        	landmark->getGlobalPos(pos_global);
+        }
 
-	if (!pos_global.isExactlyZero())
-	{
-        LL_DEBUGS("FavoritesBar") << "requesting slurl for landmark " << asset_id << LL_ENDL;
-		LLLandmarkActions::getSLURLfromPosGlobal(pos_global,
+        if (!pos_global.isExactlyZero())
+        {
+        	LL_DEBUGS("FavoritesBar") << "requesting slurl for landmark " << asset_id << LL_ENDL;
+        	LLLandmarkActions::getSLURLfromPosGlobal(pos_global,
 			boost::bind(&LLFavoritesOrderStorage::storeFavoriteSLURL, this, asset_id, _1));
-	}
+        }
     }
 }
 
@@ -1671,41 +1682,6 @@ void LLFavoritesOrderStorage::storeFavoriteSLURL(const LLUUID& asset_id, std::st
 	mSLURLs[asset_id] = slurl;
 }
 
-void LLFavoritesOrderStorage::save()
-{
-	if (mIsDirty)
-    {
-        // something changed, so save it
-        std::string filename = LLFavoritesOrderStorage::getInstance()->getSavedOrderFileName();
-        if (!filename.empty())
-        {
-            LLSD settings_llsd;
-
-            for(sort_index_map_t::const_iterator iter = mSortIndexes.begin(); iter != mSortIndexes.end(); ++iter)
-            {
-                settings_llsd[iter->first.asString()] = iter->second;
-            }
-
-            llofstream file;
-            file.open(filename.c_str());
-            if ( file.is_open() )
-            {
-                LLSDSerialize::toPrettyXML(settings_llsd, file);
-                LL_INFOS("FavoritesBar") << "saved favorites order to '" << filename << "' " << LL_ENDL;
-            }
-            else
-            {
-                LL_WARNS("FavoritesBar") << "failed to open favorites order file '" << filename << "' " << LL_ENDL;
-            }
-        }
-        else
-        {
-            LL_DEBUGS("FavoritesBar") << "no user directory available to store favorites order file" << LL_ENDL;
-        }
-    }
-}
-
-
 void LLFavoritesOrderStorage::cleanup()
 {
 	// nothing to clean
@@ -1720,7 +1696,7 @@ void LLFavoritesOrderStorage::cleanup()
 
 	sort_index_map_t  aTempMap;
 	//copy unremoved values from mSortIndexes to aTempMap
-	std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(), 
+	std::remove_copy_if(mSortIndexes.begin(), mSortIndexes.end(),
 		inserter(aTempMap, aTempMap.begin()),
 		is_not_in_fav);
 
@@ -1752,8 +1728,8 @@ void LLFavoritesOrderStorage::saveOrder()
 
 void LLFavoritesOrderStorage::saveItemsOrder( const LLInventoryModel::item_array_t& items )
 {
-	int sortField = 0;
 
+	int sortField = 0;
 	// current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
 	for (LLInventoryModel::item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
 	{
@@ -1793,6 +1769,110 @@ void LLFavoritesOrderStorage::rearrangeFavoriteLandmarks(const LLUUID& source_it
 	saveItemsOrder(items);
 }
 
+BOOL LLFavoritesOrderStorage::saveFavoritesRecord(bool pref_changed)
+{
+
+	LLUUID favorite_folder= gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
+	if (favorite_folder.isNull())
+			return FALSE;
+
+	LLInventoryModel::item_array_t items;
+	LLInventoryModel::cat_array_t cats;
+
+	LLIsType is_type(LLAssetType::AT_LANDMARK);
+	gInventory.collectDescendentsIf(favorite_folder, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type);
+
+	std::sort(items.begin(), items.end(), LLFavoritesSort());
+
+	if((items != mPrevFavorites) || pref_changed)
+	{
+		std::string filename = getStoredFavoritesFilename();
+		if (!filename.empty())
+		{
+			llifstream in_file;
+			in_file.open(filename.c_str());
+			LLSD fav_llsd;
+			if (in_file.is_open())
+			{
+				LLSDSerialize::fromXML(fav_llsd, in_file);
+				in_file.close();
+			}
+			else
+			{
+				LL_WARNS("FavoritesBar") << "unable to open favorites from '" << filename << "'" << LL_ENDL;
+			}
+
+			LLSD user_llsd;
+			S32 fav_iter = 0;
+			for (LLInventoryModel::item_array_t::iterator it = items.begin(); it != items.end(); it++)
+			{
+				LLSD value;
+				if (gSavedPerAccountSettings.getBOOL("ShowFavoritesOnLogin"))
+				{
+					value["name"] = (*it)->getName();
+					value["asset_id"] = (*it)->getAssetUUID();
+					value["id"] = (*it)->getUUID();
+					slurls_map_t::iterator slurl_iter = mSLURLs.find(value["asset_id"]);
+					if (slurl_iter != mSLURLs.end())
+					{
+						value["slurl"] = slurl_iter->second;
+						user_llsd[fav_iter] = value;
+					}
+					else
+					{
+						getSLURL((*it)->getAssetUUID());
+						mUpdateRequired = true;
+						return FALSE;
+					}
+				}
+				else
+				{
+					value["id"] = (*it)->getUUID();
+					user_llsd[fav_iter] = value;
+				}
+
+				fav_iter ++;
+			}
+
+			LLAvatarName av_name;
+			LLAvatarNameCache::get( gAgentID, &av_name );
+			// Note : use the "John Doe" and not the "john.doe" version of the name
+			// as we'll compare it with the stored credentials in the login panel.
+			fav_llsd[av_name.getUserName()] = user_llsd;
+			llofstream file;
+			file.open(filename.c_str());
+			if ( file.is_open() )
+			{
+				LLSDSerialize::toPrettyXML(fav_llsd, file);
+				file.close();
+				mSaveOnExit = false;
+			}
+			else
+			{
+				LL_WARNS("FavoritesBar") << "unable to open favorites storage for '" << av_name.getUserName()
+												<< "' at '" << filename << "' " << LL_ENDL;
+			}
+		}
+
+		mPrevFavorites = items;
+	}
+
+	return TRUE;
+
+}
+
+void LLFavoritesOrderStorage::showFavoritesOnLoginChanged(BOOL show)
+{
+	if (show)
+	{
+		saveFavoritesRecord(true);
+	}
+	else
+	{
+		removeFavoritesRecordOfUser();
+	}
+}
+
 void AddFavoriteLandmarkCallback::fire(const LLUUID& inv_item_id)
 {
 	if (mTargetLandmarkId.isNull()) return;
diff --git a/indra/newview/llfavoritesbar.h b/indra/newview/llfavoritesbar.h
index a370724947d6823c3f58d5b66f4904b0e6350d01..66fc8b2ae71cb065b39282ed5f8f546ee2dc66b3 100755
--- a/indra/newview/llfavoritesbar.h
+++ b/indra/newview/llfavoritesbar.h
@@ -105,8 +105,10 @@ class LLFavoritesBarCtrl : public LLUICtrl, public LLInventoryObserver
 	bool mUpdateDropDownItems;
 	bool mRestoreOverflowMenu;
 
-	LLUUID mSelectedItemID;
+	bool mGetPrevItems;
 
+	LLUUID mSelectedItemID;
+	LLFrameTimer mItemsChangedTimer;
 	LLUIImage* mImageDragIndication;
 
 private:
@@ -204,12 +206,23 @@ class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
 	 * @see cleanup()
 	 */
 	static void destroyClass();
+	static std::string getStoredFavoritesFilename();
+	static std::string getSavedOrderFileName();
+
+	BOOL saveFavoritesRecord(bool pref_changed = false);
+	void showFavoritesOnLoginChanged(BOOL show);
+
+	LLInventoryModel::item_array_t mPrevFavorites;
+
 
 	const static S32 NO_INDEX;
+	static bool mSaveOnExit;
+	bool mUpdateRequired;
+
 private:
 	friend class LLSingleton<LLFavoritesOrderStorage>;
-	LLFavoritesOrderStorage() : mIsDirty(false) { load(); }
-	~LLFavoritesOrderStorage() { save(); }
+	LLFavoritesOrderStorage() : mIsDirty(false), mUpdateRequired(false){ load(); }
+	~LLFavoritesOrderStorage() {}
     
 	/**
 	 * Removes sort indexes for items which are not in Favorites bar for now.
@@ -217,13 +230,8 @@ class LLFavoritesOrderStorage : public LLSingleton<LLFavoritesOrderStorage>
 	void cleanup();
 
 	const static std::string SORTING_DATA_FILE_NAME;
-    std::string getSavedOrderFileName();
-    static std::string getStoredFavoritesFilename();
-    
-	void load();
-	void save();
 
-	void saveFavoritesSLURLs();
+	void load();
 
 	// Remove record of current user's favorites from file on disk.
 	void removeFavoritesRecordOfUser();
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 4db1a833961007047a3d25d044d0a729fbc265f8..dac610eda127027d3f14ccac6426eba6ea5e00ed 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -49,6 +49,7 @@
 //#include "llfirstuse.h"
 #include "llfloaterreg.h"
 #include "llfloaterabout.h"
+#include "llfavoritesbar.h"
 #include "llfloaterhardwaresettings.h"
 #include "llfloatersidepanelcontainer.h"
 #include "llfloaterimsession.h"
@@ -1919,7 +1920,7 @@ BOOL LLPanelPreference::postBuild()
 	}
 	if (hasChild("favorites_on_login_check", TRUE))
 	{
-		getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&showFavoritesOnLoginWarning, _1, _2));
+		getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2));
 		bool show_favorites_at_login = LLPanelLogin::getShowFavorites();
 		getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login);
 	}
@@ -2004,11 +2005,15 @@ void LLPanelPreference::showFriendsOnlyWarning(LLUICtrl* checkbox, const LLSD& v
 	}
 }
 
-void LLPanelPreference::showFavoritesOnLoginWarning(LLUICtrl* checkbox, const LLSD& value)
+void LLPanelPreference::handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value)
 {
-	if (checkbox && checkbox->getValue())
+	if (checkbox)
 	{
-		LLNotificationsUtil::add("FavoritesOnLogin");
+		LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
+		if(checkbox->getValue())
+		{
+			LLNotificationsUtil::add("FavoritesOnLogin");
+		}
 	}
 }
 
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index b3878457e23815b072594502658be381efb532dd..04e5e377313a5ef1ecd682490a531fc75cdf95a8 100755
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -229,7 +229,7 @@ class LLPanelPreference : public LLPanel
 	//for "Only friends and groups can call or IM me"
 	static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&);
 	//for "Show my Favorite Landmarks at Login"
-	static void showFavoritesOnLoginWarning(LLUICtrl* checkbox, const LLSD& value);
+	static void handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value);
 
 	typedef std::map<std::string, LLColor4> string_color_map_t;
 	string_color_map_t mSavedColors;
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index c012537e78c7c5599e36f1cce61420a246aaebfb..ca22f1f17b88c53855ede6eed33da09412157d8f 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -3218,6 +3218,23 @@ bool process_login_success_response()
 			LLStringUtil::trim(gDisplayName);
 		}
 	}
+	std::string first_name;
+	if(response.has("first_name"))
+	{
+		first_name = response["first_name"].asString();
+		LLStringUtil::replaceChar(first_name, '"', ' ');
+		LLStringUtil::trim(first_name);
+		gAgentUsername = first_name;
+	}
+
+	if(response.has("last_name") && !gAgentUsername.empty() && (gAgentUsername != "Resident"))
+	{
+		std::string last_name = response["last_name"].asString();
+		LLStringUtil::replaceChar(last_name, '"', ' ');
+		LLStringUtil::trim(last_name);
+		gAgentUsername = gAgentUsername + " " + last_name;
+	}
+
 	if(gDisplayName.empty())
 	{
 		if(response.has("first_name"))
@@ -3238,6 +3255,7 @@ bool process_login_success_response()
 			gDisplayName += text;
 		}
 	}
+
 	if(gDisplayName.empty())
 	{
 		gDisplayName.assign(gUserCredential->asString());