diff --git a/doc/contributions.txt b/doc/contributions.txt
index b7d15b5ff5c58d0b66bb565c63f8cb1cda4e21aa..2f8188f2c48bbcc6142c4e32977b3ee2db70f6fe 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -4,49 +4,214 @@ along with the issue identifier corresponding to the patches we've
 received from them.  To see more about these contributions, visit
 http://jira.secondlife.com/ and enter the issue identifier.
 
-Able Whitman - VWR-650, VWR-1460
-Alissa Sabre - VWR-81, VWR-83, VWR-171, VWR-251, VWR-414, VWR-415, VWR-459, VWR-606, VWR-652, VWR-1351, VWR-1410
-Argent Stonecutter - VWR-68
-Benja Kepler - VWR-746
-Blakar Ogre - VWR-881
-blino Nakamura - VWR-17
-bushing Spatula - VWR-424, VWR-119
-Catherine Pfeffer - VWR-1282
-Dale Glass - VWR-120, VWR-560
-Drewan Keats - VWR-28, VWR-248, VWR-412
-Dylan Haskell - VWR-72
-Dzonatas Sol - VWR-198, VWR-878, VWR-1704, VWR-1705, VWR-1729, VWR-975
-Eddy Stryker - VWR-15, VWR-23, VWR-1468
-EponymousDylan Ra - VWR-1465
-Feep Larsson - VWR-1314
-Fremont Cunningham - VWR-1147
-Gigs Taggart - VWR-71, VWR-326, VWR-1217, VWR-1434
-Ginko Bayliss - VWR-4
-Grazer Kline - VWR-1092
-Gudmund Shepherd - VWR-1594
-Hikkoshi Sakai - VWR-429
-Hiro Sommambulist - VWR-66, VWR-97, VWR-100, VWR-105, VWR-108, VWR-118, VWR-132, VWR-136, VWR-143
-Iskar Ariantho - VWR-1223
-Jacek Antonelli - VWR-165, VWR-188, VWR-427, VWR-597
-Joghert LeSabre - VWR-64
-Kage Pixel - VWR-11
-Kunnis Basiat - VWR-82
-McCabe Maxsted - VWR-1318
-Nicholaz Beresford - VWR-132, VWR-176, VWR-364, VWR-691, VWR-793, VWR-794, VWR-802, VWR-803, VWR-804, VWR-805, VWR-808, VWR-809, VWR-810, VWR-823, VWR-856, VWR-869, VWR-870, VWR-871, VWR-873, VWR-908, VWR-966, VWR-1221, VWR-1270, VWR-1296, VWR-1410, VWR-1418, VWR-1453, VWR-1455, VWR-1470, VWR-1578, VWR-1626, VWR-1655, VWR-1698, VWR-1706, VWR-1723, VWR-1732, VWR-1861
-Paul Churchill - VWR-20
-Paula Innis - VWR-30, VWR-1049
-Peekay Semyorka - VWR-7, VWR-19, VWR-49, VWR-79
-Ryozu Kojima - VWR-287
-SignpostMarv Martin - VWR-154, VWR-155
-Simon Nolan - VWR-409
-SpacedOut Frye - VWR-57, VWR-94, VWR-121, VWR-123, VWR-1823
-Stevex Janus - VWR-1182
-Still Defiant - VWR-207, VWR-446
-Strife Onizuka - SVC-9, VWR-74, VWR-85, VWR-148
-tenebrous pau - VWR-247
-TBBle Kurosawa - VWR-938, VWR-941, VWR-944, VWR-945
-Tharax Ferraris - VWR-605
-Thraxis Epsilon - VWR-383, SVC-371
-Whoops Babii - VWR-1640
-Zi Ree - VWR-671, VWR-682, VWR-1140
-Zipherius Turas - VWR-76, VWR-77
+Able Whitman
+	VWR-650
+	VWR-1460
+Alissa Sabre
+	VWR-81
+	VWR-83
+	VWR-171
+	VWR-251
+	VWR-414
+	VWR-415
+	VWR-459
+	VWR-606
+	VWR-652
+	VWR-1351
+	VWR-1410
+Argent Stonecutter
+	VWR-68
+Benja Kepler
+	VWR-746
+Blakar Ogre
+	VWR-881
+blino Nakamura
+	VWR-17
+bushing Spatula
+	VWR-119
+	VWR-424
+Catherine Pfeffer
+	VWR-1282
+Dale Glass
+	VWR-120
+	VWR-560
+Drewan Keats
+	VWR-28
+	VWR-248
+	VWR-412
+Dylan Haskell
+	VWR-72
+Dzonatas Sol
+	VWR-198
+	VWR-878
+	VWR-975
+	VWR-1704
+	VWR-1705
+	VWR-1729
+Eddy Stryker
+	VWR-15
+	VWR-23
+	VWR-1468
+EponymousDylan Ra
+	VWR-1465
+Feep Larsson
+	VWR-1314
+Fremont Cunningham
+	VWR-1147
+Gigs Taggart
+	VWR-71
+	VWR-326
+	VWR-493
+	VWR-1217
+	VWR-1434
+	VWR-1987
+Ginko Bayliss
+	VWR-4
+Grazer Kline
+	VWR-1092
+Gudmund Shepherd
+	VWR-1594
+Hikkoshi Sakai
+	VWR-429
+Hiro Sommambulist
+	VWR-66
+	VWR-97
+	VWR-100
+	VWR-105
+	VWR-108
+	VWR-118
+	VWR-132
+	VWR-136
+	VWR-143
+Iskar Ariantho
+	VWR-1223
+Jacek Antonelli
+	VWR-165
+	VWR-188
+	VWR-427
+	VWR-597
+Joghert LeSabre
+	VWR-64
+Kage Pixel
+	VWR-11
+Kunnis Basiat
+	VWR-82
+Matthew Dowd
+	VWR-1344
+	VWR-1736
+	VWR-1761
+McCabe Maxsted
+	VWR-1318
+Mr Greggan
+	VWR-445
+Nicholaz Beresford
+	VWR-132
+	VWR-176
+	VWR-364
+	VWR-546
+	VWR-691
+	VWR-793
+	VWR-794
+	VWR-802
+	VWR-803
+	VWR-804
+	VWR-805
+	VWR-808
+	VWR-809
+	VWR-810
+	VWR-823
+	VWR-856
+	VWR-869
+	VWR-870
+	VWR-871
+	VWR-873
+	VWR-908
+	VWR-966
+	VWR-1221
+	VWR-1230
+	VWR-1270
+	VWR-1296
+	VWR-1410
+	VWR-1418
+	VWR-1453
+	VWR-1455
+	VWR-1470
+	VWR-1566
+	VWR-1578
+	VWR-1626
+	VWR-1655
+	VWR-1698
+	VWR-1706
+	VWR-1721
+	VWR-1723
+	VWR-1732
+	VWR-1769
+	VWR-1808
+	VWR-1826
+	VWR-1861
+	VWR-1872
+	VWR-1968
+	VWR-2152
+Paul Churchill
+	VWR-20
+	VWR-493
+	VWR-749
+	VWR-1567
+	VWR-1647
+	VWR-1880
+Paula Innis
+	VWR-30
+	VWR-1049
+Peekay Semyorka
+	VWR-7
+	VWR-19
+	VWR-49
+	VWR-79
+Renault Clio
+	VWR-1976
+Ryozu Kojima
+	VWR-287
+SignpostMarv Martin
+	VWR-154
+	VWR-155
+Simon Nolan
+	VWR-409
+SpacedOut Frye
+	VWR-57
+	VWR-94
+	VWR-121
+	VWR-123
+	VWR-1823
+Stevex Janus
+	VWR-1182
+Still Defiant
+	VWR-207
+	VWR-446
+Strife Onizuka
+	SVC-9
+	VWR-74
+	VWR-85
+	VWR-148
+tenebrous pau
+	VWR-247
+TBBle Kurosawa
+	VWR-938
+	VWR-941
+	VWR-942
+	VWR-944
+	VWR-945
+	VWR-1892
+Tharax Ferraris
+	VWR-605
+Thraxis Epsilon
+	SVC-371
+	VWR-383
+Whoops Babii
+	VWR-1640
+Zi Ree
+	VWR-671
+	VWR-682
+	VWR-1140
+Zipherius Turas
+	VWR-76
+	VWR-77
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index 16a0e71f0461d2c80583d77e163de199761b3da4..d8a4acecc1dae39c026320361e8ac2d89c142f13 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -405,15 +405,17 @@ void LLKeyframeMotion::JointMotion::update(LLJointState* joint_state, F32 time,
 // LLKeyframeMotion()
 // Class Constructor
 //-----------------------------------------------------------------------------
-LLKeyframeMotion::LLKeyframeMotion( const LLUUID &id) : LLMotion(id)
+LLKeyframeMotion::LLKeyframeMotion(const LLUUID &id) 
+	: LLMotion(id),
+		mJointMotionList(NULL),
+		mJointStates(NULL),
+		mPelvisp(NULL),
+		mLastSkeletonSerialNum(0),
+		mLastUpdateTime(0.f),
+		mLastLoopedTime(0.f),
+		mAssetStatus(ASSET_UNDEFINED)
 {
-	mJointMotionList = NULL;
-	mJointStates = NULL;
-	mLastSkeletonSerialNum = 0;
-	mLastLoopedTime = 0.f;
-	mLastUpdateTime = 0.f;
-	mAssetStatus = ASSET_UNDEFINED;
-	mPelvisp = NULL;
+
 }
 
 
@@ -1718,7 +1720,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 	}	
 
 	success &= dp.packS32(mJointMotionList->mConstraints.size(), "num_constraints");
-	for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin();
+	for (JointMotionList::constraint_list_t::const_iterator iter = mJointMotionList->mConstraints.begin();
 		 iter != mJointMotionList->mConstraints.end(); ++iter)
 	{
 		JointConstraintSharedData* shared_constraintp = *iter;
@@ -1836,8 +1838,7 @@ void LLKeyframeMotion::setEaseOut(F32 ease_in)
 //-----------------------------------------------------------------------------
 void LLKeyframeMotion::flushKeyframeCache()
 {
-	// TODO: Make this safe to do
-// 	LLKeyframeDataCache::clear();
+	LLKeyframeDataCache::clear();
 }
 
 //-----------------------------------------------------------------------------
@@ -1913,7 +1914,7 @@ void LLKeyframeMotion::setLoopOut(F32 out_point)
 void LLKeyframeMotion::onLoadComplete(LLVFS *vfs,
 									   const LLUUID& asset_uuid,
 									   LLAssetType::EType type,
-									   void* user_data, S32 status)
+									   void* user_data, S32 status, LLExtStat ext_status)
 {
 	LLUUID* id = (LLUUID*)user_data;
 		
@@ -2091,7 +2092,6 @@ void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id)
 	keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id);
 	if (found_data != sKeyframeDataMap.end())
 	{
-		delete found_data->second;
 		sKeyframeDataMap.erase(found_data);
 	}
 }
@@ -2122,7 +2122,6 @@ LLKeyframeDataCache::~LLKeyframeDataCache()
 //-----------------------------------------------------------------------------
 void LLKeyframeDataCache::clear()
 {
-	for_each(sKeyframeDataMap.begin(), sKeyframeDataMap.end(), DeletePairedPointer());
 	sKeyframeDataMap.clear();
 }
 
diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h
index 9b8c04ac926971ab7ed562951bc27afdf4dd9fa2..5a03f7549ae108f0f0c6ada24e9edadd8c21aedf 100644
--- a/indra/llcharacter/llkeyframemotion.h
+++ b/indra/llcharacter/llkeyframemotion.h
@@ -20,6 +20,7 @@
 #include "llhandmotion.h"
 #include "lljointstate.h"
 #include "llmotion.h"
+#include "llmemory.h"
 #include "llptrskipmap.h"
 #include "llquaternion.h"
 #include "v3dmath.h"
@@ -124,14 +125,14 @@ class LLKeyframeMotion :
 	static void onLoadComplete(LLVFS *vfs,
 							   const LLUUID& asset_uuid,
 							   LLAssetType::EType type,
-							   void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
 
 public:
 	U32		getFileSize();
 	BOOL	serialize(LLDataPacker& dp) const;
 	BOOL	deserialize(LLDataPacker& dp);
 	void	writeCAL3D(apr_file_t* fp);
-	BOOL	isLoaded() { return mJointMotionList != NULL; }
+	BOOL	isLoaded() { return mJointMotionList.notNull(); }
 
 
 	// setters for modifying a keyframe animation
@@ -371,8 +372,11 @@ class LLKeyframeMotion :
 	//-------------------------------------------------------------------------
 	// JointMotionList
 	//-------------------------------------------------------------------------
-	class JointMotionList
+	class JointMotionList : public LLRefCount
 	{
+	protected:
+		~JointMotionList();
+
 	public:
 		U32						mNumJointMotions;
 		JointMotion*			mJointMotionArray;
@@ -390,7 +394,6 @@ class LLKeyframeMotion :
 		LLBBoxLocal				mPelvisBBox;
 	public:
 		JointMotionList();
-		~JointMotionList();
 		U32 dumpDiagInfo();
 	};
 
@@ -401,7 +404,7 @@ class LLKeyframeMotion :
 	//-------------------------------------------------------------------------
 	// Member Data
 	//-------------------------------------------------------------------------
-	JointMotionList*				mJointMotionList;
+	LLPointer<JointMotionList>		mJointMotionList;
 	LLJointState*					mJointStates;
 	LLJoint*						mPelvisp;
 	LLCharacter*					mCharacter;
@@ -421,7 +424,7 @@ class LLKeyframeDataCache
 	LLKeyframeDataCache(){};
 	~LLKeyframeDataCache();
 
-	typedef std::map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t; 
+	typedef std::map<LLUUID, LLPointer<class LLKeyframeMotion::JointMotionList> > keyframe_data_map_t; 
 	static keyframe_data_map_t sKeyframeDataMap;
 
 	static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*);
@@ -436,3 +439,4 @@ class LLKeyframeDataCache
 
 #endif // LL_LLKEYFRAMEMOTION_H
 
+
diff --git a/indra/llcharacter/llmultigesture.cpp b/indra/llcharacter/llmultigesture.cpp
index 34064b758e622595664f2e5d11e48d986d829354..c86f32fd9b85c684ce4b814079beedff0f0578de 100644
--- a/indra/llcharacter/llmultigesture.cpp
+++ b/indra/llcharacter/llmultigesture.cpp
@@ -258,7 +258,7 @@ BOOL LLGestureStepAnimation::deserialize(LLDataPacker& dp)
 
 	// Apparently an earlier version of the gesture code added \r to the end
 	// of the animation names.  Get rid of it.  JC
-	if (mAnimName[mAnimName.length() - 1] == '\r')
+	if (!mAnimName.empty() && mAnimName[mAnimName.length() - 1] == '\r')
 	{
 		// chop the last character
 		mAnimName.resize(mAnimName.length() - 1);
diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h
index 4ef4d21833c91e9ef1fff07755d4b3bfa460c517..bf9218deacbbf29c10230b648d631eeecdd8fdf9 100644
--- a/indra/llcommon/indra_constants.h
+++ b/indra/llcommon/indra_constants.h
@@ -116,6 +116,7 @@ const MASK MASK_ALT =			0x0002;
 const MASK MASK_SHIFT =			0x0004;
 const MASK MASK_NORMALKEYS =    0x0007;     // A real mask - only get the bits for normal modifier keys
 const MASK MASK_MAC_CONTROL =	0x0008;		// Un-mapped Ctrl key on Macs, not used on Windows
+const MASK MASK_MODIFIERS =		MASK_CONTROL|MASK_ALT|MASK_SHIFT|MASK_MAC_CONTROL;
 
 // Special keys go into >128
 const KEY KEY_SPECIAL = 0x80;	// special keys start here
diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h
index 2ecda65d6f25335a27d97625db1840db1f4fba9c..5826bc917d48b0f2657c1d22ae7283d1efb1ce44 100644
--- a/indra/llcommon/linden_common.h
+++ b/indra/llcommon/linden_common.h
@@ -30,6 +30,7 @@
 #include "stdtypes.h"
 #include "lldefs.h"
 #include "llerror.h"
+#include "llextendedstatus.h"
 #include "llformat.h"
 #include "llstring.h"
 #include "lltimer.h"
diff --git a/indra/llcommon/llevent.cpp b/indra/llcommon/llevent.cpp
index 368159ee547d79e06bc52d7b710bce2af2bd07d6..af776b1273d45211e77263db69d9f6db04001bb1 100644
--- a/indra/llcommon/llevent.cpp
+++ b/indra/llcommon/llevent.cpp
@@ -218,6 +218,7 @@ LLEventDispatcher::~LLEventDispatcher()
 	if (impl)
 	{
 		delete impl;
+		impl = NULL;
 	}
 }
 
diff --git a/indra/llcommon/llextendedstatus.h b/indra/llcommon/llextendedstatus.h
new file mode 100644
index 0000000000000000000000000000000000000000..a45a894be25bdc9d03e028cfbb36c6e5bd79ceb6
--- /dev/null
+++ b/indra/llcommon/llextendedstatus.h
@@ -0,0 +1,49 @@
+/** 
+ * @file llextendedstatus.h
+ * @date   August 2007
+ * @brief extended status codes for curl/vfs/resident asset storage and delivery
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#ifndef LL_LLEXTENDEDSTATUS_H
+#define LL_LLEXTENDEDSTATUS_H
+
+
+typedef S32 LLExtStat;
+
+
+// Status provider groups - Top bits indicate which status type it is
+// Zero is common status code (next section)
+const LLExtStat LL_EXSTAT_CURL_RESULT	= 1L<<30; // serviced by curl - use 1L if we really implement the below
+const LLExtStat LL_EXSTAT_RES_RESULT	= 2L<<30; // serviced by resident copy
+const LLExtStat LL_EXSTAT_VFS_RESULT	= 3L<<30; // serviced by vfs
+
+
+// Common Status Codes
+//
+const LLExtStat LL_EXSTAT_NONE				= 0x00000; // No extra info here - sorry!
+const LLExtStat LL_EXSTAT_NULL_UUID			= 0x10001; // null asset ID
+const LLExtStat LL_EXSTAT_NO_UPSTREAM		= 0x10002; // attempt to upload without a valid upstream method/provider
+const LLExtStat LL_EXSTAT_REQUEST_DROPPED	= 0x10003; // request was dropped unserviced
+const LLExtStat LL_EXSTAT_NONEXISTENT_FILE	= 0x10004; // trying to upload a file that doesn't exist
+const LLExtStat LL_EXSTAT_BLOCKED_FILE		= 0x10005; // trying to upload a file that we can't open
+
+
+// curl status codes:
+//
+// Mask off LL_EXSTAT_CURL_RESULT for original result and
+// see: libraries/include/curl/curl.h
+
+
+// Memory-Resident status codes:
+// None at present
+
+
+// VFS status codes:
+const LLExtStat LL_EXSTAT_VFS_CACHED	= LL_EXSTAT_VFS_RESULT | 0x0001;
+const LLExtStat LL_EXSTAT_VFS_CORRUPT	= LL_EXSTAT_VFS_RESULT | 0x0002;
+
+
+#endif // LL_LLEXTENDEDSTATUS_H
diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp
index df2e94035254cf2804dfebe89134fbe7d432067a..4bfc43e68a87484b05e497495a740618ac9e99d0 100644
--- a/indra/llcommon/lllivefile.cpp
+++ b/indra/llcommon/lllivefile.cpp
@@ -126,8 +126,11 @@ namespace
 			: LLEventTimer(refresh), mLiveFile(f)
 			{ }
 			
-		void tick()
-			{ mLiveFile.checkAndReload(); }
+		BOOL tick()
+		{ 
+			mLiveFile.checkAndReload(); 
+			return FALSE;
+		}
 	
 	private:
 		LLLiveFile& mLiveFile;
diff --git a/indra/llcommon/llmetrics.cpp b/indra/llcommon/llmetrics.cpp
index fee20b43ef363cc3ac7b3fb5e6958ea91e36aac0..b193afebcc9f2a4a7483133d2e83740b8d6a8413 100644
--- a/indra/llcommon/llmetrics.cpp
+++ b/indra/llcommon/llmetrics.cpp
@@ -47,7 +47,7 @@ void LLMetricsImpl::recordEventDetails(const std::string& location,
 	metrics["location"] = location;
 	metrics["stats"]  = stats;
 	
-	llinfos << "LLMETRICS: " << LLSDOStreamer<LLSDNotationFormatter>(metrics) << llendl; 
+	llinfos << "LLMETRICS: " << LLSDNotationStreamer(metrics) << llendl; 
 }
 
 // Store this:
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index b6d927d0f3c4a68fcf2a7886ab97915a63ca965c..b1b92ae2772f1527a78354ff73a78b3a8f541b71 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -26,6 +26,7 @@
 #elif LL_DARWIN
 #	include <sys/sysctl.h>
 #	include <sys/utsname.h>
+#	include <stdint.h>
 #elif LL_LINUX
 #	include <sys/utsname.h>
 #	include <unistd.h>
@@ -462,57 +463,97 @@ LLMemoryInfo::LLMemoryInfo()
 {
 }
 
-U32 LLMemoryInfo::getPhysicalMemory() const
+#if LL_WINDOWS
+static U32 LLMemoryAdjustKBResult(U32 inKB)
+{
+	// Moved this here from llfloaterabout.cpp
+
+	//! \bug
+	// For some reason, the reported amount of memory is always wrong.
+	// The original adjustment assumes it's always off by one meg, however
+	// errors of as much as 2520 KB have been observed in the value
+	// returned from the GetMemoryStatusEx function.  Here we keep the
+	// original adjustment from llfoaterabout.cpp until this can be
+	// fixed somehow.
+	inKB += 1024;
+
+	return inKB;
+}
+#endif
+
+U32 LLMemoryInfo::getPhysicalMemoryKB() const
 {
 #if LL_WINDOWS
-	MEMORYSTATUS state;
+	MEMORYSTATUSEX state;
 	state.dwLength = sizeof(state);
-	GlobalMemoryStatus(&state);
+	GlobalMemoryStatusEx(&state);
 
-	return (U32)state.dwTotalPhys;
+	return LLMemoryAdjustKBResult((U32)(state.ullTotalPhys >> 10));
 
 #elif LL_DARWIN
 	// This might work on Linux as well.  Someone check...
-	unsigned int phys = 0;
-	int mib[2] = { CTL_HW, HW_PHYSMEM };
+	uint64_t phys = 0;
+	int mib[2] = { CTL_HW, HW_MEMSIZE };
 
 	size_t len = sizeof(phys);	
 	sysctl(mib, 2, &phys, &len, NULL, 0);
 	
-	return phys;
+	return (U32)(phys >> 10);
+
 #elif LL_LINUX
+	U64 phys = 0;
+	phys = (U64)(getpagesize()) * (U64)(get_phys_pages());
+	return (U32)(phys >> 10);
 
-	return getpagesize() * get_phys_pages();
 #elif LL_SOLARIS
-	return getpagesize() * sysconf(_SC_PHYS_PAGES);
+	U64 phys = 0;
+	phys = (U64)(getpagesize()) * (U64)(sysconf(_SC_PHYS_PAGES));
+	return (U32)(phys >> 10);
+
 #else
 	return 0;
 
 #endif
 }
 
+U32 LLMemoryInfo::getPhysicalMemoryClamped() const
+{
+	// Return the total physical memory in bytes, but clamp it
+	// to no more than U32_MAX
+	
+	U32 phys_kb = getPhysicalMemoryKB();
+	if (phys_kb >= 4194304 /* 4GB in KB */)
+	{
+		return U32_MAX;
+	}
+	else
+	{
+		return phys_kb << 10;
+	}
+}
+
 void LLMemoryInfo::stream(std::ostream& s) const
 {
 #if LL_WINDOWS
-	MEMORYSTATUS state;
+	MEMORYSTATUSEX state;
 	state.dwLength = sizeof(state);
-	GlobalMemoryStatus(&state);
+	GlobalMemoryStatusEx(&state);
 
 	s << "Percent Memory use: " << (U32)state.dwMemoryLoad << '%' << std::endl;
-	s << "Total Physical Kb:  " << (U32)state.dwTotalPhys/1024 << std::endl;
-	s << "Avail Physical Kb:  " << (U32)state.dwAvailPhys/1024 << std::endl;
-	s << "Total page Kb:      " << (U32)state.dwTotalPageFile/1024 << std::endl;
-	s << "Avail page Kb:      " << (U32)state.dwAvailPageFile/1024 << std::endl;
-	s << "Total Virtual Kb:   " << (U32)state.dwTotalVirtual/1024 << std::endl;
-	s << "Avail Virtual Kb:   " << (U32)state.dwAvailVirtual/1024 << std::endl;
+	s << "Total Physical KB:  " << (U32)(state.ullTotalPhys/1024) << std::endl;
+	s << "Avail Physical KB:  " << (U32)(state.ullAvailPhys/1024) << std::endl;
+	s << "Total page KB:      " << (U32)(state.ullTotalPageFile/1024) << std::endl;
+	s << "Avail page KB:      " << (U32)(state.ullAvailPageFile/1024) << std::endl;
+	s << "Total Virtual KB:   " << (U32)(state.ullTotalVirtual/1024) << std::endl;
+	s << "Avail Virtual KB:   " << (U32)(state.ullAvailVirtual/1024) << std::endl;
 #elif LL_DARWIN
-	U64 phys = 0;
+	uint64_t phys = 0;
 
 	size_t len = sizeof(phys);	
 	
 	if(sysctlbyname("hw.memsize", &phys, &len, NULL, 0) == 0)
 	{
-		s << "Total Physical Kb:  " << phys/1024 << std::endl;
+		s << "Total Physical KB:  " << phys/1024 << std::endl;
 	}
 	else
 	{
@@ -523,7 +564,7 @@ void LLMemoryInfo::stream(std::ostream& s) const
 
         phys = (U64)(sysconf(_SC_PHYS_PAGES)) * (U64)(sysconf(_SC_PAGESIZE)/1024);
 
-        s << "Total Physical Kb:  " << phys << std::endl;
+        s << "Total Physical KB:  " << phys << std::endl;
 #else
 	// *NOTE: This works on linux. What will it do on other systems?
 	FILE* meminfo = LLFile::fopen(MEMINFO_FILE,"rb");
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index 4c80e2877cb7833fb47b69a979fb9ab5ba472a7d..866d33a2d84f994879c682cb96bf12fe9ab96227 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -69,13 +69,31 @@ class LLCPUInfo
 	std::string mCPUString;
 };
 
+//=============================================================================
+//
+//	CLASS		LLMemoryInfo
+
 class LLMemoryInfo
+
+/*!	@brief		Class to query the memory subsystem
+
+	@details
+		Here's how you use an LLMemoryInfo:
+		
+		LLMemoryInfo info;
+<br>	llinfos << info << llendl;
+*/
 {
 public:
-	LLMemoryInfo();
-	void stream(std::ostream& s) const;
-
-	U32 getPhysicalMemory() const;
+	LLMemoryInfo(); ///< Default constructor
+	void stream(std::ostream& s) const;	///< output text info to s
+
+	U32 getPhysicalMemoryKB() const; ///< Memory size in KiloBytes
+	
+	/*! Memory size in bytes, if total memory is >= 4GB then U32_MAX will
+	**  be returned.
+	*/
+	U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes
 };
 
 
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index 659f73bee74a502c116b2d181d3ccdfada357cc3..46ac5a8bd7dde18193220888b99367f7f21f2d59 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -200,7 +200,7 @@ class LLThreadSafeRefCount
 		if (0 == res) 
 		{
 			delete this; 
-			res = 0;
+			return 0;
 		}
 		return res;
 	}	
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index f335458f24bb439688bf068ffecca37889f8ecdb..73e73b9c44da4cb328aa4ab4205138eb27931206 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -505,13 +505,27 @@ LLEventTimer::~LLEventTimer()
 
 void LLEventTimer::updateClass() 
 {
+	std::list<LLEventTimer*> completed_timers;
 	for (std::list<LLEventTimer*>::iterator iter = sActiveList.begin(); iter != sActiveList.end(); ) 
 	{
 		LLEventTimer* timer = *iter++;
 		F32 et = timer->mEventTimer.getElapsedTimeF32();
 		if (et > timer->mPeriod) {
 			timer->mEventTimer.reset();
-			timer->tick();
+			if ( timer->tick() )
+			{
+				completed_timers.push_back( timer );
+			}
+		}
+	}
+
+	if ( completed_timers.size() > 0 )
+	{
+		for (std::list<LLEventTimer*>::iterator completed_iter = completed_timers.begin(); 
+			 completed_iter != completed_timers.end(); 
+			 completed_iter++ ) 
+		{
+			delete *completed_iter;
 		}
 	}
 }
diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h
index 575bf9fc0b1e527f244107d7f1ada4dcdbfffbb2..6f67e19c4865d48c3082c6d6c8d22bc8a984f767 100644
--- a/indra/llcommon/lltimer.h
+++ b/indra/llcommon/lltimer.h
@@ -122,11 +122,12 @@ void secondsToTimecodeString(F32 current_time, char *tcstring);
 class LLEventTimer 
 {
 public:
-	LLEventTimer(F32 period);	// period is the amount of time between each call to tick()
+	LLEventTimer(F32 period);	// period is the amount of time between each call to tick() in seconds
 	virtual ~LLEventTimer();
 
 	//function to be called at the supplied frequency
-	virtual void tick() = 0;
+	// Normally return FALSE; TRUE will delete the timer after the function returns.
+	virtual BOOL tick() = 0;
 
 	static void updateClass();
 
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 5ef3e9de3bfee99440106671c88a942f2476989f..1ea0ac2714b4b5a6d2c0b73679505ec8acea34d8 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -290,42 +290,15 @@ BOOL LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height,
 	// Should do some simple bounds checking
 
 	U32 i;
-	U32 to_offset;
-	U32 from_offset;
-	if (!reverse_y)
+	for (i = 0; i < height; i++)
 	{
-		for (i = 0; i < height; i++)
-		{
-			to_offset = (y_pos + i)*getWidth() + x_pos;
-			if (stride != 0)
-			{
-				from_offset = i*stride;
-			}
-			else
-			{
-				from_offset = i*width*getComponents();
-			}
-			memcpy(getData() + to_offset*getComponents(),		/* Flawfinder: ignore */
-					data + from_offset, getComponents()*width);
-		}
-	}
-	else
-	{
-		for (i = 0; i < height; i++)
-		{
-			to_offset = (y_pos + i)*getWidth() + x_pos;
-			if (stride != 0)
-			{
-				from_offset = (height - 1 - i)*stride;
-			}
-			else
-			{
-				from_offset = (height - 1 - i)*width*getComponents();
-			}
-			memcpy(getData() + to_offset*getComponents(),		/* Flawfinder: ignore */
-					data + from_offset, getComponents()*width);
-		}
+		const U32 row = reverse_y ? height - 1 - i : i;
+		const U32 from_offset = row * ((stride == 0) ? width*getComponents() : stride);
+		const U32 to_offset = (y_pos + i)*getWidth() + x_pos;
+		memcpy(getData() + to_offset*getComponents(),		/* Flawfinder: ignore */
+				data + from_offset, getComponents()*width);
 	}
+
 	return TRUE;
 }
 
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 99e60c48a8b3823332e7d9e31d19737f620bf91b..5ffed9fbb1667b0ef3b3e12288f1120fe66c1c5e 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -96,7 +96,7 @@ class LLImageBase : public LLThreadSafeRefCount
 
 	static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels);
 	
-	// Function for calculating the download priority for textes
+	// Function for calculating the download priority for textures
 	// <= 0 priority means that there's no need for more data.
 	static F32 calc_download_priority(F32 virtual_size, F32 visible_area, S32 bytes_sent);
 
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 398e7c9e32e4da9ae124faf906ac729bf7347fd2..1f345e9d04bdd547c2f72c36068f23cee9f48f4a 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -132,7 +132,9 @@ void LLImageJ2C::closeDSO()
 LLImageJ2C::LLImageJ2C() : 	LLImageFormatted(IMG_CODEC_J2C),
 							mMaxBytes(0),
 							mRawDiscardLevel(-1),
-							mRate(0.0f)
+							mRate(0.0f),
+							mReversible(FALSE)
+	
 {
 	//We assume here that if we wanted to destory via
 	//a dynamic library that the approriate open calls were made
@@ -252,7 +254,7 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time)
 BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time)
 {
 	LLMemType mt1((LLMemType::EMemType)mMemType);
-	return mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time);
+	return mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible);
 }
 
 //static
@@ -321,11 +323,11 @@ void LLImageJ2C::setMaxBytes(S32 max_bytes)
 {
 	mMaxBytes = max_bytes;
 }
-// NOT USED
-// void LLImageJ2C::setReversible(const BOOL reversible)
-// {
-// 	mReversible = reversible;
-// }
+
+void LLImageJ2C::setReversible(const BOOL reversible)
+{
+ 	mReversible = reversible;
+}
 
 
 BOOL LLImageJ2C::loadAndValidate(const LLString &filename)
diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h
index 8a832677a314524349c3dff26ba2d14d84501d1a..08bb12b2149025ba054e5694ead9655d216932b9 100644
--- a/indra/llimage/llimagej2c.h
+++ b/indra/llimage/llimagej2c.h
@@ -59,6 +59,7 @@ class LLImageJ2C : public LLImageFormatted
 	S32 mMaxBytes; // Maximum number of bytes of data to use...
 	S8  mRawDiscardLevel;
 	F32 mRate;
+	BOOL mReversible;
 	LLImageJ2CImpl *mImpl;
 };
 
@@ -80,7 +81,8 @@ class LLImageJ2CImpl
 	// true: decoding complete (even if it failed)
 	// false: time expired while decoding
 	virtual BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) = 0;
-	virtual BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0) = 0;
+	virtual BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0,
+							BOOL reversible=FALSE) = 0;
 
 	friend class LLImageJ2C;
 };
diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp
index 94e79ba4f2ef1a9cb6618c87be62adec581d48f4..68a3152f0aa9ad2269ac09875fbf0bf86762eb82 100644
--- a/indra/llimagej2coj/llimagej2coj.cpp
+++ b/indra/llimagej2coj/llimagej2coj.cpp
@@ -173,7 +173,7 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
 }
 
 
-BOOL LLImageJ2COJ::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time)
+BOOL LLImageJ2COJ::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time, BOOL reversible)
 {
 	const S32 MAX_COMPS = 5;
 	opj_cparameters_t parameters;	/* compression parameters */
diff --git a/indra/llimagej2coj/llimagej2coj.h b/indra/llimagej2coj/llimagej2coj.h
index 5c901444695dc9530630833c9ce380869fd7465e..a3f5cc27dd13816e3f34145c64a99cd628b796ac 100644
--- a/indra/llimagej2coj/llimagej2coj.h
+++ b/indra/llimagej2coj/llimagej2coj.h
@@ -20,7 +20,8 @@ class LLImageJ2COJ : public LLImageJ2CImpl
 protected:
 	/*virtual*/ BOOL getMetadata(LLImageJ2C &base);
 	/*virtual*/ BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count);
-	/*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0);
+	/*virtual*/ BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0,
+								BOOL reversible = FALSE);
 	int ceildivpow2(int a, int b)
 	{
 		// Divide a by b to the power of 2 and round upwards.
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 7345dabf72b430bdc08001056dae2b06016bca0d..06f1c5c6eaee6d545ce72e40cd26e86d1d1a2697 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -441,6 +441,20 @@ F32 next_power_of_two(F32 value)
 	return pow(2.0f, power);
 }
 
+F32 nearest_power_of_two(F32 value)
+{
+	// nearest in the linear sense means closest w/r/t a "halfway" point.
+	// in the exponential sense, the "halfway" point isn't 1/2, it's 1/sqrt(2).
+
+	// our windows build hates the math.h defines, so do it here. -qarl
+	F32 const INVSQRT2 = 0.7071067812f;
+	
+	F32 answer = next_power_of_two(value * INVSQRT2);
+
+	// llwarns << value << " -> " << answer << llendl;
+	
+	return answer;
+}
 
 
 BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted)
@@ -585,7 +599,7 @@ BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split, BOOL is_sculpted)
 			S32 sides = (S32)circle_detail;
 
 			if (is_sculpted)
-				sides = (S32)next_power_of_two((F32)sides);
+				sides = (S32)nearest_power_of_two((F32)sides - 1);
 			
 			genNGon(sides);
 			
@@ -1132,7 +1146,7 @@ BOOL LLPath::generate(F32 detail, S32 split, BOOL is_sculpted)
 			S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * mParams.getRevolutions());
 
 			if (is_sculpted)
-				sides = (S32)next_power_of_two((F32)sides);
+				sides = (S32)nearest_power_of_two((F32)sides - 1);
 			
 			genNGon(sides);
 		}
@@ -1809,7 +1823,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 	sNumMeshPoints += mMesh.size();
 
 	S32 vertex_change = 0;
-	// first test to see if image has enough variation to create geometry
+	// first test to see if image has enough variation to create non-degenerate geometry
 	if (!data_is_empty)
 	{
 		S32 last_index = 0;
@@ -1835,12 +1849,13 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 
 				if (fabs((F32)(sculpt_data[index] - sculpt_data[last_index])) +
 					fabs((F32)(sculpt_data[index+1] - sculpt_data[last_index+1])) +
-					fabs((F32)(sculpt_data[index+2] - sculpt_data[last_index+2])) > 256 * 0.02)
+					fabs((F32)(sculpt_data[index+2] - sculpt_data[last_index+2])) > 0)
 					vertex_change++;
 
 				last_index = index;
 			}
-		if ((F32)vertex_change / sizeS / sizeT < 0.05) // less than 5%
+		
+		if ((F32)vertex_change / sizeS / sizeT < 0.02) // less than 2%
 			data_is_empty = TRUE;
 	}
 
diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp
index 911e073fb62a9a4a9cb6186721f3b64db397696e..b5a9e8a7278eae1dffde1a7178bee57d72dec372 100644
--- a/indra/llmessage/llassetstorage.cpp
+++ b/indra/llmessage/llassetstorage.cpp
@@ -345,11 +345,11 @@ void LLAssetStorage::_cleanupRequests(BOOL all, S32 error)
 		LLAssetRequest* tmp = *curiter;
 		if (tmp->mUpCallback)
 		{
-			tmp->mUpCallback(tmp->getUUID(), tmp->mUserData, error);
+			tmp->mUpCallback(tmp->getUUID(), tmp->mUserData, error, LL_EXSTAT_NONE);
 		}
 		if (tmp->mDownCallback)
 		{
-			tmp->mDownCallback(mVFS, tmp->getUUID(), tmp->getType(), tmp->mUserData, error);
+			tmp->mDownCallback(mVFS, tmp->getUUID(), tmp->getType(), tmp->mUserData, error, LL_EXSTAT_NONE);
 		}
 		if (tmp->mInfoCallback)
 		{
@@ -370,7 +370,7 @@ BOOL LLAssetStorage::hasLocalAsset(const LLUUID &uuid, const LLAssetType::EType
 ///////////////////////////////////////////////////////////////////////////
 
 // IW - uuid is passed by value to avoid side effects, please don't re-add &    
-void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *,S32), void *user_data, BOOL is_priority)
+void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat), void *user_data, BOOL is_priority)
 {
 	lldebugs << "LLAssetStorage::getAssetData() - " << uuid << "," << LLAssetType::lookup(type) << llendl;
 
@@ -384,7 +384,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo
 		// Special case early out for NULL uuid
 		if (callback)
 		{
-			callback(mVFS, uuid, type, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE);
+			callback(mVFS, uuid, type, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE, LL_EXSTAT_NULL_UUID);
 		}
 		return;
 	}
@@ -439,7 +439,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo
 		// unless there's a weird error
 		if (callback)
 		{
-			callback(mVFS, uuid, type, user_data, LL_ERR_NOERR);
+			callback(mVFS, uuid, type, user_data, LL_ERR_NOERR, LL_EXSTAT_VFS_CACHED);
 		}
 	}
 }
@@ -482,7 +482,7 @@ void LLAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType at
 		llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl;
 		if (callback)
 		{
-			callback(mVFS, uuid, atype, user_data, LL_ERR_CIRCUIT_GONE);
+			callback(mVFS, uuid, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM);
 		}
 	}
 }
@@ -492,7 +492,7 @@ void LLAssetStorage::downloadCompleteCallback(
 	S32 result,
 	const LLUUID& file_id,
 	LLAssetType::EType file_type,
-	void* user_data)
+	void* user_data, LLExtStat ext_status)
 {
 	lldebugs << "LLAssetStorage::downloadCompleteCallback() for " << file_id
 		 << "," << LLAssetType::lookup(file_type) << llendl;
@@ -546,7 +546,7 @@ void LLAssetStorage::downloadCompleteCallback(
 		LLAssetRequest* tmp = *curiter;
 		if (tmp->mDownCallback)
 		{
-			tmp->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), tmp->mUserData, result);
+			tmp->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), tmp->mUserData, result, ext_status);
 		}
 		delete tmp;
 	}
@@ -566,7 +566,7 @@ void LLAssetStorage::getEstateAsset(const LLHost &object_sim, const LLUUID &agen
 		// Special case early out for NULL uuid
 		if (callback)
 		{
-			callback(mVFS, asset_id, atype, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE);
+			callback(mVFS, asset_id, atype, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE, LL_EXSTAT_NULL_UUID);
 		}
 		return;
 	}
@@ -622,7 +622,7 @@ void LLAssetStorage::getEstateAsset(const LLHost &object_sim, const LLUUID &agen
 			llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl;
 			if (callback)
 			{
-				callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE);
+				callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM);
 			}
 		}
 	}
@@ -633,7 +633,7 @@ void LLAssetStorage::getEstateAsset(const LLHost &object_sim, const LLUUID &agen
 		// unless there's a weird error
 		if (callback)
 		{
-			callback(mVFS, asset_id, atype, user_data, LL_ERR_NOERR);
+			callback(mVFS, asset_id, atype, user_data, LL_ERR_NOERR, LL_EXSTAT_VFS_CACHED);
 		}
 	}
 }
@@ -642,7 +642,8 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback(
 	S32 result,
 	const LLUUID& file_id,
 	LLAssetType::EType file_type,
-	void* user_data)
+	void* user_data,
+	LLExtStat ext_status)
 {
 	LLEstateAssetRequest *req = (LLEstateAssetRequest*)user_data;
 	if(!req)
@@ -673,7 +674,7 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback(
 		}
 	}
 
-	req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getAType(), req->mUserData, result);
+	req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getAType(), req->mUserData, result, ext_status);
 }
 
 void LLAssetStorage::getInvItemAsset(const LLHost &object_sim, const LLUUID &agent_id, const LLUUID &session_id,
@@ -757,7 +758,7 @@ void LLAssetStorage::getInvItemAsset(const LLHost &object_sim, const LLUUID &age
 			llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl;
 			if (callback)
 			{
-				callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE);
+				callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM);
 			}
 		}
 	}
@@ -768,7 +769,7 @@ void LLAssetStorage::getInvItemAsset(const LLHost &object_sim, const LLUUID &age
 		// unless there's a weird error
 		if (callback)
 		{
-			callback(mVFS, asset_id, atype, user_data, LL_ERR_NOERR);
+			callback(mVFS, asset_id, atype, user_data, LL_ERR_NOERR, LL_EXSTAT_VFS_CACHED);
 		}
 	}
 }
@@ -778,7 +779,8 @@ void LLAssetStorage::downloadInvItemCompleteCallback(
 	S32 result,
 	const LLUUID& file_id,
 	LLAssetType::EType file_type,
-	void* user_data)
+	void* user_data,
+	LLExtStat ext_status)
 {
 	LLInvItemRequest *req = (LLInvItemRequest*)user_data;
 	if(!req)
@@ -808,7 +810,7 @@ void LLAssetStorage::downloadInvItemCompleteCallback(
 		}
 	}
 
-	req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), req->mUserData, result);
+	req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), req->mUserData, result, ext_status);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -816,7 +818,7 @@ void LLAssetStorage::downloadInvItemCompleteCallback(
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 // static
-void LLAssetStorage::uploadCompleteCallback(const LLUUID& uuid, void *user_data, S32 result) // StoreAssetData callback (fixed)
+void LLAssetStorage::uploadCompleteCallback(const LLUUID& uuid, void *user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	if (!gAssetStorage)
 	{
@@ -856,10 +858,10 @@ void LLAssetStorage::processUploadComplete(LLMessageSystem *msg, void **user_dat
 	msg->getBOOLFast(_PREHASH_AssetBlock, _PREHASH_Success, success);
 
 	asset_type = (LLAssetType::EType)asset_type_s8;
-	this_ptr->_callUploadCallbacks(uuid, asset_type, success);
+	this_ptr->_callUploadCallbacks(uuid, asset_type, success, LL_EXSTAT_NONE);
 }
 
-void LLAssetStorage::_callUploadCallbacks(const LLUUID &uuid, LLAssetType::EType asset_type, BOOL success)
+void LLAssetStorage::_callUploadCallbacks(const LLUUID &uuid, LLAssetType::EType asset_type, BOOL success, LLExtStat ext_status )
 {
 	// SJB: We process the callbacks in reverse order, I do not know if this is important,
 	//      but I didn't want to mess with it.
@@ -893,7 +895,7 @@ void LLAssetStorage::_callUploadCallbacks(const LLUUID &uuid, LLAssetType::EType
 		LLAssetRequest* req = *curiter;
 		if (req->mUpCallback)
 		{
-			req->mUpCallback(uuid, req->mUserData, (success ?  LL_ERR_NOERR :  LL_ERR_ASSET_REQUEST_FAILED ));
+			req->mUpCallback(uuid, req->mUserData, (success ?  LL_ERR_NOERR :  LL_ERR_ASSET_REQUEST_FAILED ), ext_status );
 		}
 		delete req;
 	}
@@ -1116,11 +1118,11 @@ bool LLAssetStorage::deletePendingRequest(LLAssetStorage::request_list_t* reques
 		// Run callbacks.
 		if (req->mUpCallback)
 		{
-			req->mUpCallback(req->getUUID(), req->mUserData, error);
+			req->mUpCallback(req->getUUID(), req->mUserData, error, LL_EXSTAT_REQUEST_DROPPED);
 		}
 		if (req->mDownCallback)
 		{
-			req->mDownCallback(mVFS, req->getUUID(), req->getType(), req->mUserData, error);
+			req->mDownCallback(mVFS, req->getUUID(), req->getType(), req->mUserData, error, LL_EXSTAT_REQUEST_DROPPED);
 		}
 		if (req->mInfoCallback)
 		{
@@ -1173,7 +1175,7 @@ const char* LLAssetStorage::getErrorString(S32 status)
 
 
 
-void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(const char*, const LLUUID&, void *, S32), void *user_data, BOOL is_priority)
+void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(const char*, const LLUUID&, void *, S32, LLExtStat), void *user_data, BOOL is_priority)
 {
 	// check for duplicates here, since we're about to fool the normal duplicate checker
 	for (request_list_t::iterator iter = mPendingDownloads.begin();
@@ -1203,7 +1205,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo
 }
 
 // static
-void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 status)
+void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 status, LLExtStat ext_status)
 {
 	LLLegacyAssetRequest *legacy = (LLLegacyAssetRequest *)user_data;
 	char filename[LL_MAX_PATH] = "";	/* Flawfinder: ignore */ 
@@ -1239,7 +1241,7 @@ void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAss
 		}
 	}
 
-	legacy->mDownCallback(filename, uuid, legacy->mUserData, status);
+	legacy->mDownCallback(filename, uuid, legacy->mUserData, status, ext_status);
 	delete legacy;
 }
 
@@ -1309,12 +1311,12 @@ void LLAssetStorage::storeAssetData(
 }
 
 // static
-void LLAssetStorage::legacyStoreDataCallback(const LLUUID &uuid, void *user_data, S32 status)
+void LLAssetStorage::legacyStoreDataCallback(const LLUUID &uuid, void *user_data, S32 status, LLExtStat ext_status)
 {
 	LLLegacyAssetRequest *legacy = (LLLegacyAssetRequest *)user_data;
 	if (legacy && legacy->mUpCallback)
 	{
-		legacy->mUpCallback(uuid, legacy->mUserData, status);
+		legacy->mUpCallback(uuid, legacy->mUserData, status, ext_status);
 	}
 	delete legacy;
 }
diff --git a/indra/llmessage/llassetstorage.h b/indra/llmessage/llassetstorage.h
index df448b010ebd2b47a461b2eeb63062044a8c999f..fed05d88688d444238fe22be3f9811f00000d0b4 100644
--- a/indra/llmessage/llassetstorage.h
+++ b/indra/llmessage/llassetstorage.h
@@ -20,6 +20,7 @@
 #include "lltransfermanager.h" // For LLTSCode enum
 #include "llassettype.h"
 #include "llstring.h"
+#include "llextendedstatus.h"
 
 // Forward declarations
 class LLMessageSystem;
@@ -82,8 +83,8 @@ class LLAssetRequest
 	LLAssetType::EType mType;
 
 public:
-	void	(*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32);
-	void	(*mUpCallback)(const LLUUID&, void *, S32);
+	void	(*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat);
+	void	(*mUpCallback)(const LLUUID&, void *, S32, LLExtStat);
 	void	(*mInfoCallback)(LLAssetInfo *, void *, S32);
 
 	void	*mUserData;
@@ -130,7 +131,7 @@ class LLInvItemRequest
 	LLAssetType::EType mType;
 
 public:
-	void	(*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32);
+	void	(*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat);
 
 	void	*mUserData;
 	LLHost  mHost;
@@ -160,7 +161,7 @@ class LLEstateAssetRequest
 	EstateAssetType mEstateAssetType;
 
 public:
-	void	(*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32);
+	void	(*mDownCallback)(LLVFS*, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat);
 
 	void	*mUserData;
 	LLHost  mHost;
@@ -176,14 +177,14 @@ class LLEstateAssetRequest
 
 
 typedef void (*LLGetAssetCallback)(LLVFS *vfs, const LLUUID &asset_id,
-										 LLAssetType::EType asset_type, void *user_data, S32 status);
+										 LLAssetType::EType asset_type, void *user_data, S32 status, LLExtStat ext_status);
 
 class LLAssetStorage
 {
 public:
 	// VFS member is public because static child methods need it :(
 	LLVFS *mVFS;
-	typedef void (*LLStoreAssetCallback)(const LLUUID &asset_id, void *user_data, S32 status);
+	typedef void (*LLStoreAssetCallback)(const LLUUID &asset_id, void *user_data, S32 status, LLExtStat ext_status);
 
 	enum ERequestType
 	{
@@ -315,27 +316,27 @@ class LLAssetStorage
 		S32 result,
 		const LLUUID& file_id,
 		LLAssetType::EType file_type,
-		void* user_data);
+		void* user_data, LLExtStat ext_status);
 	static void downloadEstateAssetCompleteCallback(
 		S32 result,
 		const LLUUID& file_id,
 		LLAssetType::EType file_type,
-		void* user_data);
+		void* user_data, LLExtStat ext_status);
 	static void downloadInvItemCompleteCallback(
 		S32 result,
 		const LLUUID& file_id,
 		LLAssetType::EType file_type,
-		void* user_data);
+		void* user_data, LLExtStat ext_status);
 
 	// upload process callbacks
-	static void uploadCompleteCallback(const LLUUID&, void *user_data, S32 result);
+	static void uploadCompleteCallback(const LLUUID&, void *user_data, S32 result, LLExtStat ext_status);
 	static void processUploadComplete(LLMessageSystem *msg, void **this_handle);
 
 	// debugging
 	static const char* getErrorString( S32 status );
 
 	// deprecated file-based methods
-	void getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(const char*, const LLUUID&, void *, S32), void *user_data, BOOL is_priority = FALSE);
+	void getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(const char*, const LLUUID&, void *, S32, LLExtStat), void *user_data, BOOL is_priority = FALSE);
 
 	/*
 	 * AssetID version.
@@ -365,8 +366,8 @@ class LLAssetStorage
 		bool user_waiting = false,
 		F64 timeout  = LL_ASSET_STORAGE_TIMEOUT);
 
-	static void legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType, void *user_data, S32 status);
-	static void legacyStoreDataCallback(const LLUUID &uuid, void *user_data, S32 status);
+	static void legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType, void *user_data, S32 status, LLExtStat ext_status);
+	static void legacyStoreDataCallback(const LLUUID &uuid, void *user_data, S32 status, LLExtStat ext_status);
 
 	// Temp assets are stored on sim nodes, they have agent ID and location data associated with them.
 	// This is a no-op for non-http asset systems
@@ -384,10 +385,10 @@ class LLAssetStorage
 
 protected:
 	void _cleanupRequests(BOOL all, S32 error);
-	void _callUploadCallbacks(const LLUUID &uuid, const LLAssetType::EType asset_type, BOOL success);
+	void _callUploadCallbacks(const LLUUID &uuid, const LLAssetType::EType asset_type, BOOL success, LLExtStat ext_status);
 
 	virtual void _queueDataRequest(const LLUUID& uuid, LLAssetType::EType type,
-								   void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32),
+								   void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat),
 								   void *user_data, BOOL duplicate,
 								   BOOL is_priority);
 
@@ -405,7 +406,7 @@ class LLAssetStorage
 class LLLegacyAssetRequest
 {
 public:
-	void	(*mDownCallback)(const char *, const LLUUID&, void *, S32);
+	void	(*mDownCallback)(const char *, const LLUUID&, void *, S32, LLExtStat);
 	LLAssetStorage::LLStoreAssetCallback mUpCallback;
 
 	void	*mUserData;
diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp
index e9a60e4eb80ff82c312cb6e654d2c24d1407a23a..6dff2683b4ab54e79c892b9422bd95b23847b0bc 100644
--- a/indra/llmessage/llcircuit.cpp
+++ b/indra/llmessage/llcircuit.cpp
@@ -1138,7 +1138,7 @@ std::ostream& operator<<(std::ostream& s, LLCircuitData& circuit)
 	s << S32(circuit.mBytesInLastPeriod * 8.f / circuit.mLastPeriodLength / 1024.f);
 	s << "/";
 	s << S32(circuit.mBytesOutLastPeriod * 8.f / circuit.mLastPeriodLength / 1024.f);
-	s << " Peak Kbps: ";
+	s << " Peak kbps: ";
 	s << S32(circuit.mPeakBPSIn / 1024.f);
 	s << "/";
 	s << S32(circuit.mPeakBPSOut / 1024.f);
diff --git a/indra/llmessage/llhttpassetstorage.cpp b/indra/llmessage/llhttpassetstorage.cpp
index 534f1d8ca65b41e032c40557c447577b9bd51a27..23b90aef7170e087269c6bd0332c1b3592ad2773 100644
--- a/indra/llmessage/llhttpassetstorage.cpp
+++ b/indra/llmessage/llhttpassetstorage.cpp
@@ -444,7 +444,7 @@ void LLHTTPAssetStorage::storeAssetData(
 		llwarns << "AssetStorage: attempt to upload non-existent vfile " << uuid << ":" << LLAssetType::lookup(type) << llendl;
 		if (callback)
 		{
-			callback(uuid, user_data,  LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE );
+			callback(uuid, user_data,  LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE);
 		}
 	}
 }
@@ -509,7 +509,7 @@ void LLHTTPAssetStorage::storeAssetData(
 	{
 		if (callback)
 		{
-			callback(LLUUID::null, user_data, LL_ERR_CANNOT_OPEN_FILE);
+			callback(LLUUID::null, user_data, LL_ERR_CANNOT_OPEN_FILE, LL_EXSTAT_BLOCKED_FILE);
 		}
 	}
 	// Coverity CID-269 says there's a leak of 'legacy' here, but
@@ -611,7 +611,7 @@ bool LLHTTPAssetStorage::deletePendingRequest(LLAssetStorage::ERequestType rt,
 					{
 						if (pending_req->mUpCallback)	//Clean up here rather than _callUploadCallbacks because this request is already cleared the req.
 						{
-							pending_req->mUpCallback(pending_req->getUUID(), pending_req->mUserData, -1);
+							pending_req->mUpCallback(pending_req->getUUID(), pending_req->mUserData, -1, LL_EXSTAT_REQUEST_DROPPED);
 						}
 
 					}
@@ -637,7 +637,7 @@ bool LLHTTPAssetStorage::deletePendingRequest(LLAssetStorage::ERequestType rt,
 
 // internal requester, used by getAssetData in superclass
 void LLHTTPAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType type,
-										  void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32),
+										  void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat),
 										  void *user_data, BOOL duplicate,
 										   BOOL is_priority)
 {
@@ -902,7 +902,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
 				{
 					// shared upload finished callback
 					// in the base class, this is called from processUploadComplete
-					_callUploadCallbacks(req->getUUID(), req->getType(), (xfer_result == 0));
+					_callUploadCallbacks(req->getUUID(), req->getType(), (xfer_result == 0), LL_EXSTAT_CURL_RESULT | curl_result);
 					// Pending upload flag will get cleared when the request is deleted
 				}
 			}
@@ -944,7 +944,8 @@ void LLHTTPAssetStorage::checkForTimeouts()
 					xfer_result,
 					req->getUUID(),
 					req->getType(),
-					(void *)req);
+					(void *)req,
+					LL_EXSTAT_CURL_RESULT | curl_result);
 				// Pending download flag will get cleared when the request is deleted
 			}
 			else
@@ -1369,3 +1370,4 @@ void LLHTTPAssetStorage::clearTempAssetData()
 	mTempAssets.clear();
 }
 
+
diff --git a/indra/llmessage/llhttpassetstorage.h b/indra/llmessage/llhttpassetstorage.h
index d6f74d7744c9f6c5fdf9dc586ddc989280c4a258..548dc1305ec97974e20439b396f5d1d0647082c9 100644
--- a/indra/llmessage/llhttpassetstorage.h
+++ b/indra/llmessage/llhttpassetstorage.h
@@ -108,7 +108,7 @@ class LLHTTPAssetStorage : public LLAssetStorage
 
 protected:
 	void _queueDataRequest(const LLUUID& uuid, LLAssetType::EType type,
-						   void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32),
+						   void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat),
 						   void *user_data, BOOL duplicate, BOOL is_priority);
 
 private:
diff --git a/indra/llmessage/llmessageconfig.cpp b/indra/llmessage/llmessageconfig.cpp
index 25bdc9fb1684358c7f9694d94719eea26da5ad13..bfaec7c8fc5bd9c99e7d15d1c4ebd1213761edb9 100644
--- a/indra/llmessage/llmessageconfig.cpp
+++ b/indra/llmessage/llmessageconfig.cpp
@@ -143,7 +143,7 @@ void LLMessageConfigFile::loadMessageBans(const LLSD& data)
 
 bool LLMessageConfigFile::isCapBanned(const std::string& cap_name) const
 {
-	llinfos << "mCapBans is " << LLSDXMLStreamer(mCapBans) << llendl;
+	lldebugs << "mCapBans is " << LLSDNotationStreamer(mCapBans) << llendl;
     return mCapBans[cap_name];
 }
 
diff --git a/indra/llmessage/llsdmessagebuilder.cpp b/indra/llmessage/llsdmessagebuilder.cpp
index 94d2378050686fe7c07a69a170d748673115fbe7..64eeefc25658838db8c3033a153e82896615eb85 100755
--- a/indra/llmessage/llsdmessagebuilder.cpp
+++ b/indra/llmessage/llsdmessagebuilder.cpp
@@ -256,7 +256,7 @@ void LLSDMessageBuilder::copyFromMessageData(const LLMsgData& data)
 void LLSDMessageBuilder::copyFromLLSD(const LLSD& msg)
 {
 	mCurrentMessage = msg;
-	lldebugs << LLSDXMLStreamer(mCurrentMessage) << llendl;
+	lldebugs << LLSDNotationStreamer(mCurrentMessage) << llendl;
 }
 
 const LLSD& LLSDMessageBuilder::getMessage() const
diff --git a/indra/llmessage/llteleportflags.h b/indra/llmessage/llteleportflags.h
index fd54814ce54afa06dc1c469aa749855db6763d15..49795f2e1ba0be05f2a90e2f306cd8af33926b25 100644
--- a/indra/llmessage/llteleportflags.h
+++ b/indra/llmessage/llteleportflags.h
@@ -25,6 +25,7 @@ const U32 TELEPORT_FLAGS_DISABLE_CANCEL		= 1 << 11;	// Used for llTeleportAgentH
 const U32 TELEPORT_FLAGS_VIA_REGION_ID  	= 1 << 12;
 const U32 TELEPORT_FLAGS_IS_FLYING			= 1 << 13;
 const U32 TELEPORT_FLAGS_SHOW_RESET_HOME	= 1 << 14;
+const U32 TELEPORT_FLAGS_FORCE_REDIRECT		= 1 << 15; // used to force a redirect to some random location - used when kicking someone from land.
 
 const U32 TELEPORT_FLAGS_MASK_VIA =   TELEPORT_FLAGS_VIA_LURE 
 									| TELEPORT_FLAGS_VIA_LANDMARK
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index 3e08b9de26788b289b52bc98c571a1f16f024130..03ef738e43332214b5107b6cc3c89cbb9f34dc55 100644
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -482,12 +482,15 @@ BOOL LLTemplateMessageReader::decodeTemplate(
 	return(TRUE);
 }
 
-void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host )
+void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host, const S32 where, const S32 wanted )
 {
 	// we've run off the end of the packet!
 	llwarns << "Ran off end of packet " << mCurrentRMessageTemplate->mName
 //			<< " with id " << mCurrentRecvPacketID 
 			<< " from " << host
+			<< " trying to read " << wanted
+			<< " bytes at position " << where
+			<< " going past packet end at " << mReceiveSize
 			<< llendl;
 	if(gMessageSystem->mVerboseLog)
 	{
@@ -542,7 +545,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
 			// repeat number is a single byte
 			if (decode_pos >= mReceiveSize)
 			{
-				logRanOffEndOfPacket(sender);
+				logRanOffEndOfPacket(sender, decode_pos, 1);
 
 				// default to 0 repeats
 				repeat_number = 0;
@@ -601,7 +604,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
 
 					if ((decode_pos + data_size) > mReceiveSize)
 					{
-						logRanOffEndOfPacket(sender);
+						logRanOffEndOfPacket(sender, decode_pos, data_size);
 
 						// default to 0 length variable blocks
 						tsize = 0;
@@ -637,7 +640,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
 					// so, copy data pointer and set data size to fixed size
 					if ((decode_pos + mvci.getSize()) > mReceiveSize)
 					{
-						logRanOffEndOfPacket(sender);
+						logRanOffEndOfPacket(sender, decode_pos, mvci.getSize());
 
 						// default to 0s.
 						U32 size = mvci.getSize();
diff --git a/indra/llmessage/lltemplatemessagereader.h b/indra/llmessage/lltemplatemessagereader.h
index ea8bd522980d22bea7a930e6e32eea07dd07691b..87c91d92e2f4f8541325cdf8c1251ed867594330 100644
--- a/indra/llmessage/lltemplatemessagereader.h
+++ b/indra/llmessage/lltemplatemessagereader.h
@@ -93,7 +93,7 @@ class LLTemplateMessageReader : public LLMessageReader
 	BOOL decodeTemplate(const U8* buffer, S32 buffer_size,  // inputs
 						LLMessageTemplate** msg_template ); // outputs
 
-	void logRanOffEndOfPacket( const LLHost& host );
+	void logRanOffEndOfPacket( const LLHost& host, const S32 where, const S32 wanted );
 
 	BOOL decodeData(const U8* buffer, const LLHost& sender );
 
diff --git a/indra/llmessage/lltransfersourceasset.cpp b/indra/llmessage/lltransfersourceasset.cpp
index 635b7cffaf59ade08b8ffb912ac45ef6eebdf4fa..9490d9757c10781bac66d2b856522aac618585f4 100644
--- a/indra/llmessage/lltransfersourceasset.cpp
+++ b/indra/llmessage/lltransfersourceasset.cpp
@@ -154,7 +154,7 @@ BOOL LLTransferSourceAsset::unpackParams(LLDataPacker &dp)
 
 
 void LLTransferSourceAsset::responderCallback(LLVFS *vfs, const LLUUID& uuid, LLAssetType::EType type,
-											  void *user_data, S32 result)
+											  void *user_data, S32 result, LLExtStat ext_status )
 {
 	LLUUID *tidp = ((LLUUID*) user_data);
 	LLUUID transfer_id = *(tidp);
diff --git a/indra/llmessage/lltransfersourceasset.h b/indra/llmessage/lltransfersourceasset.h
index 446c9622b2239cb04634d4f26331c5529b6e91ea..6c9aabe91b0595ca6149c863afa60bc958630cc2 100644
--- a/indra/llmessage/lltransfersourceasset.h
+++ b/indra/llmessage/lltransfersourceasset.h
@@ -39,7 +39,7 @@ class LLTransferSourceAsset : public LLTransferSource
 	virtual ~LLTransferSourceAsset();
 
 	static void responderCallback(LLVFS *vfs, const LLUUID& uuid, LLAssetType::EType type,
-								  void *user_data, S32 result);
+								  void *user_data, S32 result, LLExtStat ext_status );
 protected:
 	/*virtual*/ void initTransfer();
 	/*virtual*/ F32 updatePriority();
diff --git a/indra/llmessage/lltransfertargetvfile.cpp b/indra/llmessage/lltransfertargetvfile.cpp
index 6714185d3f6bc38fe15feb081a2d210c33647b70..9c280fc20847ef776de25207e1c5b1944b542795 100644
--- a/indra/llmessage/lltransfertargetvfile.cpp
+++ b/indra/llmessage/lltransfertargetvfile.cpp
@@ -195,6 +195,7 @@ void LLTransferTargetVFile::completionCallback(const LLTSCode status)
 		mParams.mCompleteCallback(err_code,
 								  mParams.getAssetID(),
 								  mParams.getAssetType(),
-								  mParams.mUserDatap);
+								  mParams.mUserDatap,
+								  LL_EXSTAT_NONE);
 	}
 }
diff --git a/indra/llmessage/lltransfertargetvfile.h b/indra/llmessage/lltransfertargetvfile.h
index e9d5fa0c00650eda32c1ebdabbd597ea075ef2f4..edce3bc677a6cd7efc2a2931ae1e2a055f4f3497 100644
--- a/indra/llmessage/lltransfertargetvfile.h
+++ b/indra/llmessage/lltransfertargetvfile.h
@@ -21,7 +21,7 @@ typedef void (*LLTTVFCompleteCallback)(
 	S32 status,
 	const LLUUID& file_id,
 	LLAssetType::EType file_type,
-	void* user_data);
+	void* user_data, LLExtStat ext_status );
 
 class LLTransferTargetParamsVFile : public LLTransferTargetParams
 {
diff --git a/indra/llmessage/llxfer.cpp b/indra/llmessage/llxfer.cpp
index 1a1492c20a29a24481246a66014b6e8bb0e4991c..441f15365aad9491566769df22e4483c01c81c08 100644
--- a/indra/llmessage/llxfer.cpp
+++ b/indra/llmessage/llxfer.cpp
@@ -281,7 +281,7 @@ S32 LLXfer::processEOF()
 
 	if (mCallback)
 	{
-		mCallback(mCallbackDataHandle,mCallbackResult);
+		mCallback(mCallbackDataHandle,mCallbackResult,LL_EXSTAT_NONE);
 	}
 
 	return(retval);
@@ -355,3 +355,4 @@ std::ostream& operator<< (std::ostream& os, LLXfer &hh)
 
 
 
+
diff --git a/indra/llmessage/llxfer.h b/indra/llmessage/llxfer.h
index 3fd12df7a5fa9284666b008d024a2c3ce3afd2c9..ebe4d76d3141f62521daef1daa8ed35fb3640c8a 100644
--- a/indra/llmessage/llxfer.h
+++ b/indra/llmessage/llxfer.h
@@ -47,7 +47,7 @@ class LLXfer
 
 	BOOL mWaitingForACK;
 
-	void (*mCallback)(void **,S32);	
+	void (*mCallback)(void **,S32,LLExtStat);	
 	void **mCallbackDataHandle;
 	S32 mCallbackResult;
 
@@ -96,3 +96,4 @@ class LLXfer
 
 
 
+
diff --git a/indra/llmessage/llxfer_file.cpp b/indra/llmessage/llxfer_file.cpp
index 338dbdd215933dfad0c4865cbeb6184125535808..cc5b9f1add7940aa22853ca0f2ebcd010d325e01 100644
--- a/indra/llmessage/llxfer_file.cpp
+++ b/indra/llmessage/llxfer_file.cpp
@@ -103,7 +103,7 @@ S32 LLXfer_File::initializeRequest(U64 xfer_id,
 				   ELLPath remote_path,
 				   const LLHost& remote_host,
 				   BOOL delete_remote_on_completion,
-				   void (*callback)(void**,S32),
+				   void (*callback)(void**,S32,LLExtStat),
 				   void** user_data)
 {
  	S32 retval = 0;  // presume success
diff --git a/indra/llmessage/llxfer_file.h b/indra/llmessage/llxfer_file.h
index b3d1ccbfbe4fd2e68eba8848acb96fa20c350893..38c94f6591a6eb0720ebb5c8fc3227fc0c0b962c 100644
--- a/indra/llmessage/llxfer_file.h
+++ b/indra/llmessage/llxfer_file.h
@@ -40,7 +40,7 @@ class LLXfer_File : public LLXfer
 								  ELLPath remote_path,
 								  const LLHost& remote_host,
 								  BOOL delete_remote_on_completion,
-								  void (*callback)(void**,S32),
+								  void (*callback)(void**,S32,LLExtStat),
 								  void** user_data);
 	virtual S32 startDownload();
 
@@ -66,3 +66,4 @@ class LLXfer_File : public LLXfer
 
 
 
+
diff --git a/indra/llmessage/llxfer_mem.cpp b/indra/llmessage/llxfer_mem.cpp
index ff878dc9f2bf8a42a8b258a6b4c32c2ecec7b8e2..1eda712d2b489ef88d79cc5abd631012a5ed9cb6 100644
--- a/indra/llmessage/llxfer_mem.cpp
+++ b/indra/llmessage/llxfer_mem.cpp
@@ -116,7 +116,7 @@ S32 LLXfer_Mem::processEOF()
 
 	if (mCallback)
 	{
-		mCallback((void *)mBuffer,mBufferLength,mCallbackDataHandle,mCallbackResult);
+		mCallback((void *)mBuffer,mBufferLength,mCallbackDataHandle,mCallbackResult,LL_EXSTAT_NONE);
 	}
 
 	return(retval);
@@ -129,7 +129,7 @@ S32 LLXfer_Mem::initializeRequest(U64 xfer_id,
 								  ELLPath remote_path,
 								  const LLHost& remote_host,
 								  BOOL delete_remote_on_completion,
-								  void (*callback)(void*,S32,void**,S32),
+								  void (*callback)(void*,S32,void**,S32,LLExtStat),
 								  void** user_data)
 {
  	S32 retval = 0;  // presume success
@@ -198,3 +198,4 @@ U32 LLXfer_Mem::getXferTypeTag()
 
 
 
+
diff --git a/indra/llmessage/llxfer_mem.h b/indra/llmessage/llxfer_mem.h
index d7cbdc4f85f72938a3c4a125cfbba7be8b20b5cb..6577132c9b892f4b281a17841da97beedc85eb59 100644
--- a/indra/llmessage/llxfer_mem.h
+++ b/indra/llmessage/llxfer_mem.h
@@ -20,7 +20,7 @@ class LLXfer_Mem : public LLXfer
 {
  private:
  protected:
-	void (*mCallback)(void *, S32, void **,S32);	
+	void (*mCallback)(void *, S32, void **, S32, LLExtStat);	
 	char mRemoteFilename[LL_MAX_PATH];		/* Flawfinder : ignore */
 	ELLPath mRemotePath;
 	BOOL mDeleteRemoteOnCompletion;
@@ -45,7 +45,7 @@ class LLXfer_Mem : public LLXfer
 								  ELLPath remote_path,
 								  const LLHost& remote_host,
 								  BOOL delete_remote_on_completion,
-								  void (*callback)(void*,S32,void**,S32),
+								  void (*callback)(void*,S32,void**,S32,LLExtStat),
 								  void** user_data);
 	virtual S32 startDownload();
 
@@ -59,3 +59,4 @@ class LLXfer_Mem : public LLXfer
 
 
 
+
diff --git a/indra/llmessage/llxfer_vfile.cpp b/indra/llmessage/llxfer_vfile.cpp
index 5030556eb034a5994c0e1995558a5007b0c18ca2..cc5bfab64ef4181a54be0c3c6e5473c87df02733 100644
--- a/indra/llmessage/llxfer_vfile.cpp
+++ b/indra/llmessage/llxfer_vfile.cpp
@@ -78,7 +78,7 @@ S32 LLXfer_VFile::initializeRequest(U64 xfer_id,
 									const LLUUID& remote_id,
 									LLAssetType::EType type,
 									const LLHost& remote_host,
-									void (*callback)(void**,S32),
+									void (*callback)(void**,S32,LLExtStat),
 									void** user_data)
 {
  	S32 retval = 0;  // presume success
diff --git a/indra/llmessage/llxfer_vfile.h b/indra/llmessage/llxfer_vfile.h
index 3d9d8de7a794941402ef3bc3fc3d440bd2cae409..a5dce0352c7c2b8d672ec42e59ab292f1d99f53d 100644
--- a/indra/llmessage/llxfer_vfile.h
+++ b/indra/llmessage/llxfer_vfile.h
@@ -45,7 +45,7 @@ class LLXfer_VFile : public LLXfer
 			const LLUUID &remote_id,
 			const LLAssetType::EType type,
 			const LLHost &remote_host,
-			void (*callback)(void **,S32),
+			void (*callback)(void **,S32,LLExtStat),
 			void **user_data);
 	virtual S32 startDownload();
 
@@ -72,3 +72,4 @@ class LLXfer_VFile : public LLXfer
 
 
 
+
diff --git a/indra/llmessage/llxfermanager.cpp b/indra/llmessage/llxfermanager.cpp
index 98d8a626e5fe6002b9b5e1a9725f448f61266a8a..00d38c4ebc68c1722fc45af9d1c22b555d24bac0 100644
--- a/indra/llmessage/llxfermanager.cpp
+++ b/indra/llmessage/llxfermanager.cpp
@@ -376,7 +376,7 @@ void LLXferManager::requestFile(const char* local_filename,
 								ELLPath remote_path,
 								const LLHost& remote_host,
 								BOOL delete_remote_on_completion,
-								void (*callback)(void**,S32),
+								void (*callback)(void**,S32,LLExtStat),
 								void** user_data,
 								BOOL is_priority,
 								BOOL use_big_packets)
@@ -433,7 +433,7 @@ void LLXferManager::requestFile(const char* remote_filename,
 								ELLPath remote_path,
 								const LLHost& remote_host,
 								BOOL delete_remote_on_completion,
-								void (*callback)(void*,S32,void**,S32),
+								void (*callback)(void*,S32,void**,S32,LLExtStat),
 								void** user_data,
 								BOOL is_priority)
 {
@@ -461,7 +461,7 @@ void LLXferManager::requestVFile(const LLUUID& local_id,
 								 const LLUUID& remote_id,
 								 LLAssetType::EType type, LLVFS* vfs,
 								 const LLHost& remote_host,
-								 void (*callback)(void**, S32),
+								 void (*callback)(void**,S32,LLExtStat),
 								 void** user_data,
 								 BOOL is_priority)
 {
@@ -1129,5 +1129,6 @@ void process_abort_xfer(LLMessageSystem *mesgsys, void **user_data)
 
 
 
+
 
 
diff --git a/indra/llmessage/llxfermanager.h b/indra/llmessage/llxfermanager.h
index eca3684df58423cde0cd9af84b88b7ee0cf5f134..d311781746865fac5b094ac7cde1a7179d7626c4 100644
--- a/indra/llmessage/llxfermanager.h
+++ b/indra/llmessage/llxfermanager.h
@@ -125,7 +125,7 @@ class LLXferManager
 							 ELLPath remote_path,
 							 const LLHost& remote_host,
  							 BOOL delete_remote_on_completion,
-							 void (*callback)(void**,S32), void** user_data,
+							 void (*callback)(void**,S32,LLExtStat), void** user_data,
 							 BOOL is_priority = FALSE,
 							 BOOL use_big_packets = FALSE);
 
@@ -134,7 +134,7 @@ class LLXferManager
 							 ELLPath remote_path,
 							 const LLHost &remote_host,
  							 BOOL delete_remote_on_completion,
-							 void (*callback)(void*, S32, void**, S32),
+							 void (*callback)(void*, S32, void**, S32, LLExtStat),
 							 void** user_data,
 							 BOOL is_priority = FALSE);
 
@@ -143,7 +143,7 @@ class LLXferManager
 	virtual void requestVFile(const LLUUID &local_id, const LLUUID& remote_id,
 							  LLAssetType::EType type, LLVFS* vfs,
 							  const LLHost& remote_host,
-							  void (*callback)(void**, S32), void** user_data,
+							  void (*callback)(void**,S32,LLExtStat), void** user_data,
 							  BOOL is_priority = FALSE);
 
 /*
@@ -185,3 +185,4 @@ void process_abort_xfer (LLMessageSystem *mesgsys, void **user_data);
 #endif
 
 
+
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index d0414def6dd543ee0b6eb8fdb66324fb8acd4971..c6911515a6cd2192c8f6f3445912d6f060c8a3e3 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -2114,7 +2114,7 @@ void LLMessageSystem::dispatch(
 	}
 	// enable this for output of message names
 	//llinfos << "< \"" << msg_name << "\"" << llendl;
-	//lldebugs << "data: " << LLSDXMLStreamer(message) << llendl;	   
+	//lldebugs << "data: " << LLSDNotationStreamer(message) << llendl;	   
 
 	handler->post(responsep, context, message);
 }
diff --git a/indra/llmessage/message_prehash.cpp b/indra/llmessage/message_prehash.cpp
index 67ee5d56751dc3ea78791e7368da495e6e67d4b1..f11c1592e19976a48fb86ddf8bac52b2e829a1e9 100644
--- a/indra/llmessage/message_prehash.cpp
+++ b/indra/llmessage/message_prehash.cpp
@@ -285,6 +285,7 @@ char * _PREHASH_LogFailedMoneyTransaction;
 char * _PREHASH_ViewerStartAuction;
 char * _PREHASH_StartAuction;
 char * _PREHASH_DuplicateFlags;
+char * _PREHASH_RegionInfo2;
 char * _PREHASH_TextColor;
 char * _PREHASH_SlaveID;
 char * _PREHASH_Charter;
@@ -650,9 +651,9 @@ char * _PREHASH_PreyAgent;
 char * _PREHASH_SimStats;
 char * _PREHASH_LogoutReply;
 char * _PREHASH_FeatureDisabled;
+char * _PREHASH_PhysicalAvatarEventList;
 char * _PREHASH_ObjectLocalID;
 char * _PREHASH_Dropped;
-char * _PREHASH_PhysicalAvatarEventList;
 char * _PREHASH_WebProfilesDisabled;
 char * _PREHASH_Destination;
 char * _PREHASH_MasterID;
@@ -1617,6 +1618,7 @@ void init_prehash_data()
 	_PREHASH_ViewerStartAuction = gMessageStringTable.getString("ViewerStartAuction");
 	_PREHASH_StartAuction = gMessageStringTable.getString("StartAuction");
 	_PREHASH_DuplicateFlags = gMessageStringTable.getString("DuplicateFlags");
+	_PREHASH_RegionInfo2 = gMessageStringTable.getString("RegionInfo2");
 	_PREHASH_TextColor = gMessageStringTable.getString("TextColor");
 	_PREHASH_SlaveID = gMessageStringTable.getString("SlaveID");
 	_PREHASH_Charter = gMessageStringTable.getString("Charter");
@@ -1982,9 +1984,9 @@ void init_prehash_data()
 	_PREHASH_SimStats = gMessageStringTable.getString("SimStats");
 	_PREHASH_LogoutReply = gMessageStringTable.getString("LogoutReply");
 	_PREHASH_FeatureDisabled = gMessageStringTable.getString("FeatureDisabled");
+	_PREHASH_PhysicalAvatarEventList = gMessageStringTable.getString("PhysicalAvatarEventList");
 	_PREHASH_ObjectLocalID = gMessageStringTable.getString("ObjectLocalID");
 	_PREHASH_Dropped = gMessageStringTable.getString("Dropped");
-	_PREHASH_PhysicalAvatarEventList = gMessageStringTable.getString("PhysicalAvatarEventList");
 	_PREHASH_WebProfilesDisabled = gMessageStringTable.getString("WebProfilesDisabled");
 	_PREHASH_Destination = gMessageStringTable.getString("Destination");
 	_PREHASH_MasterID = gMessageStringTable.getString("MasterID");
diff --git a/indra/llmessage/message_prehash.h b/indra/llmessage/message_prehash.h
index 71661ef83deafe769851ca67c276b891a7e788fc..3daf1c270136157419b7b0757d652a72710ad234 100644
--- a/indra/llmessage/message_prehash.h
+++ b/indra/llmessage/message_prehash.h
@@ -285,6 +285,7 @@ extern char * _PREHASH_LogFailedMoneyTransaction;
 extern char * _PREHASH_ViewerStartAuction;
 extern char * _PREHASH_StartAuction;
 extern char * _PREHASH_DuplicateFlags;
+extern char * _PREHASH_RegionInfo2;
 extern char * _PREHASH_TextColor;
 extern char * _PREHASH_SlaveID;
 extern char * _PREHASH_Charter;
@@ -650,9 +651,9 @@ extern char * _PREHASH_PreyAgent;
 extern char * _PREHASH_SimStats;
 extern char * _PREHASH_LogoutReply;
 extern char * _PREHASH_FeatureDisabled;
+extern char * _PREHASH_PhysicalAvatarEventList;
 extern char * _PREHASH_ObjectLocalID;
 extern char * _PREHASH_Dropped;
-extern char * _PREHASH_PhysicalAvatarEventList;
 extern char * _PREHASH_WebProfilesDisabled;
 extern char * _PREHASH_Destination;
 extern char * _PREHASH_MasterID;
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index bdf1c12b79a38bdb83121aaecfcb6fb806f00b82..2fe43c04f22cd046b10565371268c9f204d10b3a 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -69,8 +69,7 @@ LLButton::LLButton(	const LLString& name, const LLRect& rect, const LLString& co
 	mCurGlowStrength(0.f),
 	mNeedsHighlight(FALSE),
 	mCommitOnReturn(TRUE),
-	mImagep( NULL ),
-	mIsDirty( FALSE )
+	mImagep( NULL )
 {
 	mUnselectedLabel = name;
 	mSelectedLabel = name;
@@ -255,8 +254,6 @@ void LLButton::onCommit()
 	{
 		(*mClickedCallback)( mCallbackUserData );
 	}
-
-	mIsDirty = TRUE;
 }
 
 
@@ -271,7 +268,6 @@ BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent)
 			(*mClickedCallback)( mCallbackUserData );
 		}
 		handled = TRUE;		
-		mIsDirty = TRUE;
 	}
 	return handled;	
 }
@@ -288,7 +284,6 @@ BOOL LLButton::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
 				(*mClickedCallback)( mCallbackUserData );
 			}
 			handled = TRUE;
-			mIsDirty = TRUE;
 		}
 	}
 	return handled;
@@ -348,9 +343,7 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask)
 			if (mClickedCallback)
 			{
 				(*mClickedCallback)( mCallbackUserData );
-			}
-			
-			mIsDirty = TRUE;
+			}			
 		}
 
 		mMouseDownTimer.stop();
@@ -753,7 +746,6 @@ void LLButton::setToggleState(BOOL b)
 void LLButton::setValue(const LLSD& value )
 {
 	mToggleState = value.asBoolean();
-	mIsDirty = FALSE;
 }
 
 LLSD LLButton::getValue() const
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index a638b5be49cc53c29799f2bfc3fbe7d58af7ed1f..9c737956baa12175c93e374bfc031b71176f70e8 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -80,8 +80,6 @@ class LLButton
 	// HACK: "committing" a button is the same as clicking on it.
 	virtual void	onCommit();
 
-	virtual BOOL	isDirty()	{ return mIsDirty;	};			// Returns TRUE if the user has clicked on the button at all
-
 	void			setUnselectedLabelColor( const LLColor4& c )		{ mUnselectedLabelColor = c; }
 	void			setSelectedLabelColor( const LLColor4& c )			{ mSelectedLabelColor = c; }
 
@@ -259,8 +257,6 @@ class LLButton
 
 	LLPointer<LLImageGL> mImagep;
 
-	BOOL			mIsDirty;
-
 	static LLFrameTimer	sFlashingTimer;
 };
 
diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp
index 6c181acc941a90c91096ef13410e25778e2b5e8b..318268bdb6364de16e62acf1a1e285940c5158df 100644
--- a/indra/llui/llcheckboxctrl.cpp
+++ b/indra/llui/llcheckboxctrl.cpp
@@ -39,7 +39,8 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect,
 	mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
 	mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ),
 	mRadioStyle( use_radio_style ),
-	mInitialValue( initial_value )
+	mInitialValue( initial_value ),
+	mSetValue( initial_value )
 {
 	if (font)
 	{
@@ -208,7 +209,8 @@ void LLCheckBoxCtrl::draw()
 //virtual
 void LLCheckBoxCtrl::setValue(const LLSD& value )
 {
-	mButton->setToggleState( value.asBoolean() );
+	mSetValue = value.asBoolean();
+	mButton->setToggleState( mSetValue );
 }
 
 //virtual
@@ -249,16 +251,27 @@ void LLCheckBoxCtrl::setControlName(const LLString& control_name, LLView* contex
 
 
 // virtual		Returns TRUE if the user has modified this control.
-BOOL	 LLCheckBoxCtrl::isDirty()
+BOOL	 LLCheckBoxCtrl::isDirty() const
 {
 	if ( mButton )
 	{
-		return mButton->isDirty();
+		return (mSetValue != mButton->getToggleState());
 	}
 	return FALSE;		// Shouldn't get here
 }
 
 
+// virtual			Clear dirty state
+void	LLCheckBoxCtrl::resetDirty()
+{
+	if ( mButton )
+	{
+		mSetValue = mButton->getToggleState();
+	}
+}
+
+
+
 // virtual
 LLXMLNodePtr LLCheckBoxCtrl::getXML(bool save_children) const
 {
diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h
index 76b197125dd4a6c09934456ae6ddbfcd32af7a69..3b1883ce8d55e8c494ca56339eeb6785d98df6b5 100644
--- a/indra/llui/llcheckboxctrl.h
+++ b/indra/llui/llcheckboxctrl.h
@@ -90,7 +90,8 @@ class LLCheckBoxCtrl
 
 	static void			onButtonPress(void *userdata);
 
-	virtual BOOL		isDirty();		// Returns TRUE if the user has modified this control.
+	virtual BOOL		isDirty()	const;		// Returns TRUE if the user has modified this control.
+	virtual void		resetDirty();			// Clear dirty state
 
 protected:
 	// note: value is stored in toggle state of button
@@ -100,7 +101,8 @@ class LLCheckBoxCtrl
 	LLColor4		mTextEnabledColor;
 	LLColor4		mTextDisabledColor;
 	BOOL			mRadioStyle;
-	BOOL			mInitialValue;
+	BOOL			mInitialValue;			// Value set in constructor
+	BOOL			mSetValue;				// Value set programmatically
 	BOOL			mKeyboardFocusOnClick;
 	LLViewBorder*	mBorder;
 };
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index d63a53fdff2a09c12f84b7532fb73ccd4e8cac53..5eeb1d19c8ad22a7464e34d284654cf24823248b 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -227,6 +227,27 @@ void LLComboBox::onCommit()
 	LLUICtrl::onCommit();
 }
 
+// virtual
+BOOL LLComboBox::isDirty() const
+{
+	BOOL grubby = FALSE;
+	if ( mList )
+	{
+		grubby = mList->isDirty();
+	}
+	return grubby;
+}
+
+// virtual   Clear dirty state
+void	LLComboBox::resetDirty()
+{
+	if ( mList )
+	{
+		mList->resetDirty();
+	}
+}
+
+
 // add item "name" to menu
 void LLComboBox::add(const LLString& name, EAddPosition pos, BOOL enabled)
 {
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 02aa0084edb244f7745a9cc87cfccedb9f3e1de0..fea54c554e824bf21bd723889cb3688fc746cca6 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -68,6 +68,8 @@ class LLComboBox
 	virtual void	clear();					// select nothing
 	virtual void	onCommit();
 	virtual BOOL	acceptsTextInput() const		{ return mAllowTextEntry; }
+	virtual BOOL	isDirty() const;			// Returns TRUE if the user has modified this control.
+	virtual void	resetDirty();				// Clear dirty state
 
 	virtual void	setFocus(BOOL b);
 
@@ -127,7 +129,7 @@ class LLComboBox
 	virtual BOOL	getCanSelect() const				{ return TRUE; }
 	virtual BOOL	selectFirstItem()					{ return setCurrentByIndex(0); }
 	virtual BOOL	selectNthItem( S32 index )			{ return setCurrentByIndex(index); }
-	virtual S32		getFirstSelectedIndex()				{ return getCurrentIndex(); }
+	virtual S32		getFirstSelectedIndex() const		{ return getCurrentIndex(); }
 	virtual BOOL	setCurrentByID( const LLUUID& id );
 	virtual LLUUID	getCurrentID();				// LLUUID::null if no items in menu
 	virtual BOOL	setSelectedByValue(LLSD value, BOOL selected);
diff --git a/indra/llui/llctrlselectioninterface.h b/indra/llui/llctrlselectioninterface.h
index 9df7475a6c45dd06ad9d41efc7a68cc981b084bd..daa84712d4aca7694e1964d6db064e7b07fc0012 100644
--- a/indra/llui/llctrlselectioninterface.h
+++ b/indra/llui/llctrlselectioninterface.h
@@ -36,7 +36,7 @@ class LLCtrlSelectionInterface
 	virtual BOOL	selectFirstItem() = 0;
 	virtual BOOL	selectNthItem( S32 index ) = 0;
 
-	virtual S32		getFirstSelectedIndex() = 0;
+	virtual S32		getFirstSelectedIndex() const = 0;
 
 	// TomY TODO: Simply cast the UUIDs to LLSDs, using the selectByValue function
 	virtual BOOL	setCurrentByID( const LLUUID& id ) = 0;
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 17b4dffa3fe56acd59cbb46f3f709e53591d81a9..9ea4165ea4d506d06410dff7b71aca6aaefe51fe 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -1232,10 +1232,13 @@ BOOL LLFloater::getEditModeEnabled()
 //static 
 void LLFloater::show(LLFloater* floaterp)
 {
-	if (floaterp) floaterp->open();
-	if (floaterp->getHost())
+	if (floaterp) 
 	{
-		floaterp->getHost()->open();
+		floaterp->open();
+		if (floaterp->getHost())
+		{
+			floaterp->getHost()->open();
+		}
 	}
 }
 
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 5e043ecea3a7ee8d8e0bc92a5fa14f243f863be8..ccf18a3506c6e6cc889db74659b6867f27cf3732 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -118,6 +118,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
 		mSelectionEnd( 0 ),
 		mLastSelectionX(-1),
 		mLastSelectionY(-1),
+		mLastSelectionStart(-1),
+		mLastSelectionEnd(-1),
 		mPrevalidateFunc( prevalidate_func ),
 		mCursorColor(		LLUI::sColorsGroup->getColor( "TextCursorColor" ) ),
 		mFgColor(			LLUI::sColorsGroup->getColor( "TextFgColor" ) ),
@@ -227,6 +229,19 @@ void LLLineEditor::onCommit()
 	selectAll();
 }
 
+// virtual 
+BOOL	LLLineEditor::isDirty() const	
+{ 
+	return ( mText.getString() != mPrevText );	
+}
+
+// virtual 
+void	LLLineEditor::resetDirty()	
+{ 
+	mPrevText = mText.getString();	
+}
+
+
 // line history support
 void LLLineEditor::updateHistory()
 {
@@ -448,8 +463,38 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
 	}
 	else
 	{
-		// otherwise select everything
-		selectAll();
+		const LLWString& wtext = mText.getWString();
+
+		BOOL doSelectAll = TRUE;
+
+		// Select the word we're on
+		if( isPartOfWord( wtext[mCursorPos] ) )
+		{
+			S32 old_selection_start = mLastSelectionStart;
+			S32 old_selection_end = mLastSelectionEnd;
+
+			// Select word the cursor is over
+			while ((mCursorPos > 0) && isPartOfWord( wtext[mCursorPos-1] ))
+			{	// Find the start of the word
+				mCursorPos--;
+			}
+			startSelection();	
+
+			while ((mCursorPos < (S32)wtext.length()) && isPartOfWord( wtext[mCursorPos] ) )
+			{	// Find the end of the word
+				mCursorPos++;
+			}
+			mSelectionEnd = mCursorPos;
+
+			// If nothing changed, then the word was already selected.  Select the whole line.
+			doSelectAll = (old_selection_start == mSelectionStart) &&  
+						  (old_selection_end   == mSelectionEnd);
+		}
+		
+		if ( doSelectAll )
+		{	// Select everything
+			selectAll();
+		}
 	}
 
 	// We don't want handleMouseUp() to "finish" the selection (and thereby
@@ -476,6 +521,9 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
 	}
 	else
 	{
+		mLastSelectionStart = -1;
+		mLastSelectionStart = -1;
+
 		setFocus( TRUE );
 
 		if (mask & MASK_SHIFT)
@@ -519,6 +567,10 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
 		}
 		else
 		{
+			// Save selection for word/line selecting on double-click
+			mLastSelectionStart = mSelectionStart;
+			mLastSelectionEnd = mSelectionEnd;
+
 			// Move cursor and deselect for regular click
 			setCursorAtLocalPos( x );
 			deselect();
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index 110e40b92d451d8f13e241e6f5b15e28e5fdc4e4..db6aea84323d2b0f4444cb72d188b41bf5b22e5b 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -107,7 +107,8 @@ class LLLineEditor
 	virtual void 	setRect(const LLRect& rect);
 	virtual BOOL	acceptsTextInput() const;
 	virtual void	onCommit();
-	virtual BOOL	isDirty()		{ return ( mText.getString() != mPrevText );	};		// Returns TRUE if the user has changed value at all
+	virtual BOOL	isDirty() const;	// Returns TRUE if the user has changed value at all
+	virtual void	resetDirty();		// Clear dirty state
 
 	// assumes UTF8 text
 	virtual void	setValue(const LLSD& value );
@@ -237,6 +238,8 @@ class LLLineEditor
 	S32			mSelectionEnd;
 	S32			mLastSelectionX;
 	S32			mLastSelectionY;
+	S32			mLastSelectionStart;
+	S32			mLastSelectionEnd;
 
 	S32			(*mPrevalidateFunc)(const LLWString &str);
 
diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h
index 2a856ee6cf1749c6e7748020ddf7c7bf86fa04a5..38b56a179ef3d857e6b4b51a650f89a3596a5e39 100644
--- a/indra/llui/llradiogroup.h
+++ b/indra/llui/llradiogroup.h
@@ -95,7 +95,7 @@ class LLRadioGroup
 	/*virtual*/ BOOL	getCanSelect() const				{ return TRUE; }
 	/*virtual*/ BOOL	selectFirstItem()					{ return setSelectedIndex(0); }
 	/*virtual*/ BOOL	selectNthItem( S32 index )			{ return setSelectedIndex(index); }
-	/*virtual*/ S32		getFirstSelectedIndex()				{ return getSelectedIndex(); }
+	/*virtual*/ S32		getFirstSelectedIndex() const		{ return getSelectedIndex(); }
 	/*virtual*/ BOOL	setCurrentByID( const LLUUID& id );
 	/*virtual*/ LLUUID	getCurrentID();				// LLUUID::null if no items in menu
 	/*virtual*/ BOOL	setSelectedByValue(LLSD value, BOOL selected);
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index e802b3426bd9bd5d71c7131dbe1a29a68c622101..ffad4809e94bc8c33b1c1311fe1517b77f199b1e 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -427,6 +427,8 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect,
 	mSortColumn(-1),
 	mSortAscending(TRUE),
 	mSorted(TRUE),
+	mDirty(FALSE),
+	mOriginalSelection(-1),
 	mDrewSelected(FALSE)
 {
 	mItemListRect.setOriginAndSize(
@@ -515,6 +517,7 @@ void LLScrollListCtrl::clearRows()
 	mScrollLines = 0;
 	mLastSelected = NULL;
 	updateMaxContentWidth(NULL);
+	mDirty = FALSE; 
 }
 
 
@@ -547,10 +550,10 @@ std::vector<LLScrollListItem*> LLScrollListCtrl::getAllSelected() const
 	return ret;
 }
 
-S32 LLScrollListCtrl::getFirstSelectedIndex()
+S32 LLScrollListCtrl::getFirstSelectedIndex() const
 {
 	S32 CurSelectedIndex = 0;
-	item_list::iterator iter;
+	item_list::const_iterator iter;
 	for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
 	{
 		LLScrollListItem* item  = *iter;
@@ -865,6 +868,7 @@ BOOL LLScrollListCtrl::selectFirstItem()
 				selectItem(itemp);
 			}
 			success = TRUE;
+			mOriginalSelection = 0;
 		}
 		else
 		{
@@ -898,6 +902,7 @@ BOOL LLScrollListCtrl::selectNthItem( S32 target_index )
 			{
 				selectItem(itemp);
 				success = TRUE;
+				mOriginalSelection = target_index;
 			}
 		}
 		else
@@ -1721,6 +1726,7 @@ BOOL LLScrollListCtrl::handleMouseUp(S32 x, S32 y, MASK mask)
 	// always commit when mouse operation is completed inside list
 	if (mItemListRect.pointInRect(x,y))
 	{
+		mDirty |= mSelectionChanged;
 		mSelectionChanged = FALSE;
 		onCommit();
 	}
@@ -2121,6 +2127,7 @@ void LLScrollListCtrl::commitIfChanged()
 {
 	if (mSelectionChanged)
 	{
+		mDirty = TRUE;
 		mSelectionChanged = FALSE;
 		onCommit();
 	}
@@ -2979,6 +2986,26 @@ void LLScrollListCtrl::setFocus(BOOL b)
 	LLUICtrl::setFocus(b);
 }
 
+
+// virtual 
+BOOL	LLScrollListCtrl::isDirty() const		
+{
+	BOOL grubby = mDirty;
+	if ( !mAllowMultipleSelection )
+	{
+		grubby = (mOriginalSelection != getFirstSelectedIndex());
+	}
+	return grubby;
+}
+
+// Clear dirty state
+void LLScrollListCtrl::resetDirty()
+{
+	mDirty = FALSE;
+	mOriginalSelection = getFirstSelectedIndex();
+}
+
+
 //virtual
 void LLScrollListCtrl::onFocusReceived()
 {
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 9604b0569ce097e237bcd87d054d23f3cd024bec..c7dfa870fb6ea6496aa7c36244311df574f27efb 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -440,7 +440,7 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
 	LLUUID				getStringUUIDSelectedItem();
 
 	LLScrollListItem*	getFirstSelected() const;
-	virtual S32			getFirstSelectedIndex();
+	virtual S32			getFirstSelectedIndex() const;
 	std::vector<LLScrollListItem*> getAllSelected() const;
 
 	LLScrollListItem*	getLastSelectedItem() const { return mLastSelected; }
@@ -495,6 +495,9 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
 	virtual void	onFocusReceived();
 	virtual void	onFocusLost();
 
+	virtual BOOL	isDirty() const;
+	virtual void	resetDirty();		// Clear dirty state
+
 	virtual void	reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 	virtual void	arrange(S32 max_width, S32 max_height);
 	virtual LLRect	getRequiredRect();
@@ -638,6 +641,9 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
 	std::map<LLString, LLScrollListColumn> mColumns;
 	std::vector<LLScrollListColumn*> mColumnsIndexed;
 
+	BOOL			mDirty;
+	S32				mOriginalSelection;
+
 public:
 	// HACK:  Did we draw one selected item this frame?
 	BOOL mDrewSelected;
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index ea5897e28e69bfb3e5a2792f9fbc2787d701d952..52f8c19ebda6bbcae902a2b4d3aef0e8e1c04a16 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -334,6 +334,8 @@ LLTextEditor::LLTextEditor(
 
 	appendText(default_text, FALSE, FALSE);
 	
+	resetDirty();		// Update saved text state
+
 	mParseHTML=FALSE;
 	mHTML="";
 }
@@ -509,6 +511,8 @@ void LLTextEditor::setText(const LLString &utf8str)
 
 	updateLineStartList();
 	updateScrollFromCursor();
+
+	resetDirty();
 }
 
 void LLTextEditor::setWText(const LLWString &wtext)
@@ -525,6 +529,8 @@ void LLTextEditor::setWText(const LLWString &wtext)
 
 	updateLineStartList();
 	updateScrollFromCursor();
+
+	resetDirty();
 }
 
 void LLTextEditor::setValue(const LLSD& value)
@@ -3427,6 +3433,7 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr
 	BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
 	S32 selection_start = mSelectionStart;
 	S32 selection_end = mSelectionEnd;
+	BOOL was_selecting = mIsSelecting;
 	S32 cursor_pos = mCursorPos;
 	S32 old_length = getLength();
 	BOOL cursor_was_at_end = (mCursorPos == old_length);
@@ -3459,17 +3466,23 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr
 	updateLineStartList(old_length);
 	
 	// Set the cursor and scroll position
-	// Maintain the scroll position unless the scroll was at the end of the doc 
-	//	  (in which case, move it to the new end of the doc)
-	if( was_scrolled_to_bottom )
+	// Maintain the scroll position unless the scroll was at the end of the doc (in which 
+	// case, move it to the new end of the doc) or unless the user was doing actively selecting
+	if( was_scrolled_to_bottom && !was_selecting )
 	{
+		if( selection_start != selection_end )
+		{
+			// maintain an existing non-active selection
+			mSelectionStart = selection_start;
+			mSelectionEnd = selection_end;
+		}	
 		endOfDoc();
 	}
 	else if( selection_start != selection_end )
 	{
 		mSelectionStart = selection_start;
-
 		mSelectionEnd = selection_end;
+		mIsSelecting = was_selecting;
 		setCursorPos(cursor_pos);
 	}
 	else if( cursor_was_at_end )
@@ -3606,6 +3619,11 @@ BOOL LLTextEditor::tryToRevertToPristineState()
 	return isPristine(); // TRUE => success
 }
 
+// virtual    Return TRUE if changes have been made
+BOOL LLTextEditor::isDirty() const
+{
+	return( mLastCmd != NULL || (mPristineCmd && (mPristineCmd != mLastCmd)) );
+}
 
 
 void LLTextEditor::updateTextRect()
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index 0b6e29184364ee8ecebe26495198db1faf03301f..7c7ec9c13b7c17b1a1f85ba417d96d8a08667b9a 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -89,6 +89,7 @@ class LLTextEditor : public LLUICtrl, LLEditMenuHandler
 	virtual void	clear();
 	virtual void	setFocus( BOOL b );
 	virtual BOOL	acceptsTextInput() const;
+	virtual BOOL	isDirty() const;
 
 	// LLEditMenuHandler interface
 	virtual void	undo();
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 7b96ec5655027582eb149bf30976ecda22f4fa55..1355b12924a3deece19fc39164c6b9cd60632cc2 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -129,7 +129,9 @@ class LLUICtrl
 	};
 
 	// Returns TRUE if the user has modified this control.   Editable controls should override this.
-	virtual BOOL	 isDirty()			{ return FALSE;		};
+	virtual BOOL	isDirty() const			{ return FALSE;		};
+	// Clear the dirty state
+	virtual void	resetDirty()			{};
 
 protected:
 	virtual void	onFocusReceived();
diff --git a/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp
index a74bbefb0cfc9f3809ffa7af2d76657f89485bfa..64b66139b8b20df41acc08ea46b38ae9dea8d2c4 100644
--- a/indra/llvfs/lldir_mac.cpp
+++ b/indra/llvfs/lldir_mac.cpp
@@ -156,11 +156,7 @@ LLDir_Mac::LLDir_Mac()
 				FSRefToLLString(&tempRef, mTempDir);
 		}
 		
-		// Set the working dir to <bundle>/Contents/Resources
-		(void) chdir(mAppRODataDir.c_str());
-		
-		// Canonically, since we set it here...
-		mWorkingDir = mAppRODataDir;
+		mWorkingDir = getCurPath();
 				
 		CFRelease(executableURLRef);
 		executableURLRef = NULL;
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index 9094bdd24f5953dbf64d11d47571a113236799c8..0054e87755929c00ef48e579e09f1d5f646a3c56 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -872,11 +872,11 @@ BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type
 							{
 								llwarns << "Short write" << llendl;
 							}
-    
-							delete[] buffer;
 						} else {
 							llwarns << "Short read" << llendl;
 						}
+    
+						delete[] buffer;
 					}
 				}
     
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index 0fdb42436e399d1f98498528ae9b6b208c4d7c0f..501e9119fbb0c843f059bff6ca44a2ea42cf1da9 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -93,6 +93,7 @@ BOOL ll_try_gtk_init(void)
 	if (!tried_gtk_init)
 	{
 		tried_gtk_init = TRUE;
+		if (!g_thread_supported ()) g_thread_init (NULL);
 		maybe_lock_display();
 		gtk_is_good = gtk_init_check(NULL, NULL);
 		maybe_unlock_display();
diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y
index 49d0c38b3077aa8dffcea7a744e844a3b4f81e41..56f40c974c912640a8593e309948a1ee8a7ae70c 100644
--- a/indra/lscript/lscript_compile/indra.y
+++ b/indra/lscript/lscript_compile/indra.y
@@ -53,7 +53,6 @@
 %token					QUATERNION
 %token					LIST
 
-%token					STATE_DEFAULT
 %token					STATE
 %token					EVENT
 %token					JUMP
diff --git a/indra/lscript/lscript_compile/lscript_tree.cpp b/indra/lscript/lscript_compile/lscript_tree.cpp
index 4f54bdd7b7daf0056c8a1d0d8f5556bd434f3701..af06bc1c8bfb832ccc709ff3632f4a5496bb60cb 100644
--- a/indra/lscript/lscript_compile/lscript_tree.cpp
+++ b/indra/lscript/lscript_compile/lscript_tree.cpp
@@ -8937,8 +8937,12 @@ void LLScriptEventHandler::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi
 		{
 			entrycount = 0;
 			mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mScopeEntry, entrycount, NULL);
-			fprintf(fp, "Function Args: %s\n", mScopeEntry->mFunctionArgs.mString);
-			fprintf(fp, "Local List: %s\n", mScopeEntry->mLocals.mString);
+
+			const char *function_args = mScopeEntry->mFunctionArgs.mString;
+			fprintf(fp, "Function Args: %s\n", function_args?function_args:"");
+
+			const char *local_list = mScopeEntry->mLocals.mString;
+			fprintf(fp, "Local List: %s\n", local_list?local_list:"");
 		}
 		mStackSpace = (S32)count;
 		break;
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 28b1ddc131ec7eab9b0b469fd127e2f74948181f..f98b42bba2881bfcfddc761402ee95bd9277e248 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -34,6 +34,8 @@ RenderParticleCount	1	4096
 RenderRippleWater	1	1
 RenderTerrainDetail	1	2
 VertexShaderEnable	1	1
+UseOcclusion		1	1
+RenderCubeMap		1	1
 
 //
 // Class 0 Hardware (Unknown or just old)
diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index 6c7acfa18711b2bb1cc898199215c19598aae439..f31fc0dbb6fef56d979ac4d1979a46a0e04b856b 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -34,6 +34,8 @@ RenderParticleCount	1	4096
 RenderRippleWater	1	1
 RenderTerrainDetail	1	2
 VertexShaderEnable	1	1
+UseOcclusion		1	1
+RenderCubeMap		1	1
 
 //
 // Class 0 Hardware (Unknown or just old)
@@ -107,6 +109,8 @@ RenderAvatarVP		0	0
 RenderLighting		1	0
 RenderParticleCount	1	1024
 RenderTerrainDetail 1	0
+RenderCubeMap		0	0
+UseOcclusion		0	0
 
 
 list low
@@ -145,6 +149,7 @@ RenderVBO			1	0
 RenderAniso			1	0
 RenderLighting		1	0
 RenderTerrainDetail	1	0
+RenderCubeMap		0	0
 
 list GeForce2
 RenderVBO			1	1
@@ -156,6 +161,7 @@ RenderTerrainDetail	1	0
 list GeForce3
 
 list ATI
+UseOcclusion		0	0
 
 list Radeon8500
 RenderLighting		1	0
diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index 2685e3b7b41f9115ce8f57a4c0c2c897923afe85..fe5ae7a4ae0b1d7711dcf85b48b0304e10e1b2fc 100644
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -35,7 +35,8 @@ RenderParticleCount	1	4096
 RenderRippleWater	1	1
 RenderTerrainDetail	1	2
 VertexShaderEnable	1	1
-
+UseOcclusion		1	1
+RenderCubeMap		1	1
 
 //
 // Class 0 Hardware (Unknown or just old)
diff --git a/indra/newview/gpu_table.txt b/indra/newview/gpu_table.txt
index 74fbe2c7f2cd0c8a0a9b9c6264cbbbd96fbd3eee..066990bafa6c8fe446e499879f507d0c75f4e492 100644
--- a/indra/newview/gpu_table.txt
+++ b/indra/newview/gpu_table.txt
@@ -25,6 +25,8 @@ ATI Mobility Radeon X1xxx		.*ATI.*Mobility.*X1.*					2
 ATI Mobility Radeon X3xx		.*ATI.*Mobility.*X3.*					1
 ATI Mobility Radeon X6xx		.*ATI.*Mobility.*X6.*					1
 ATI Mobility Radeon X7xx		.*ATI.*Mobility.*X7.*					1
+ATI Mobility Radeon Xxxx		.*ATI.*Mobility.*X.*					1
+ATI Mobility Radeon				.*ATI.*Mobility.*						0
 ATI Radeon OpenGL				.*ATI.*Radeon OpenGL.* 					3
 ATI Diamond X1xxx				.*ATI.*Diamond.*X1.*					3
 ATI FireGL 5xxx					.*ATI.*FireGL V5.*						3
diff --git a/indra/newview/linux_tools/client-readme.txt b/indra/newview/linux_tools/client-readme.txt
index e07384cc93e3c3bec05d79c49ee303308578df79..59ebf6793ae0a95578654b412d3f50a83fd8c998 100644
--- a/indra/newview/linux_tools/client-readme.txt
+++ b/indra/newview/linux_tools/client-readme.txt
@@ -97,6 +97,10 @@ you wish.
 These are the most commonly-encountered known issues which are specific to
 the Alpha release of the Linux client.
 
+* VOICE COMMUNICATION - this is not yet available in the Linux client.
+
+* STREAMING MOVIES - these are currently disabled while we work on some issues.
+
 * VISUAL EFFECTS AND PERFORMANCE - many Linux graphics drivers are not as
   robust as their counterparts for other operating systems, so some advanced
   Second Life graphical features have been DISABLED by default to aid
diff --git a/indra/newview/linux_tools/wrapper.sh b/indra/newview/linux_tools/wrapper.sh
index d39fc3a8d1c1ab30bad2f5009cd2dc42529b9086..2a57b6688343c64df38cf175bd24b24dacea8e49 100755
--- a/indra/newview/linux_tools/wrapper.sh
+++ b/indra/newview/linux_tools/wrapper.sh
@@ -43,6 +43,9 @@ export LL_GL_BASICEXT=x
 ## - Avoids an often-buggy X feature that doesn't really benefit us anyway.
 export SDL_VIDEO_X11_DGAMOUSE=0
 
+## - Works around a problem with misconfigured 64-bit systems not finding GL
+export LIBGL_DRIVERS_PATH="${LIBGL_DRIVERS_PATH}":/usr/lib64/dri:/usr/lib32/dri:/usr/lib/dri
+
 ## Nothing worth editing below this line.
 ##-------------------------------------------------------------------
 
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 7ed11c11540d680669792446fc84c726d3215583..e12904ef43ac4aff1ac556d2e6ed23f14c498dc5 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -5592,7 +5592,7 @@ void LLAgent::teleportCancel()
 		sendReliableMessage();
 	}	
 	gTeleportDisplay = FALSE;
-	gAgent.setTeleportState( LLAgent::TELEPORT_CANCELLING );
+	gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
 }
 
 
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 438239e7175aefe77a4fe6491176b865f18cd5d3..8b6e1c33a462a3021851e892dfa6216170f24f86 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -509,8 +509,7 @@ class LLAgent : public LLObservable
 		TELEPORT_REQUESTED = 2,		// Waiting for source simulator to respond
 		TELEPORT_MOVING = 3,		// Viewer has received destination location from source simulator
 		TELEPORT_START_ARRIVAL = 4,	// Transition to ARRIVING.  Viewer has received avatar update, etc., from destination simulator
-		TELEPORT_ARRIVING = 5,		// Make the user wait while content "pre-caches"
-		TELEPORT_CANCELLING = 6		// used only if user clicks "cancel" button
+		TELEPORT_ARRIVING = 5		// Make the user wait while content "pre-caches"
 	};
 
 	ETeleportState	getTeleportState() const			{ return mTeleportState; }
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 0fcf28ee6c7139b2f275868fb053ad7f189f5d0c..923a2b935ae0a1abcae80eb1b00b7086c11dde5d 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -75,8 +75,8 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason)
 	{
 		case 400:
 			args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName);
-			args["[REASON]"] = "Error in upload request.  Please contact "
-				"support@lindenlab.com for help fixing this problem.";
+			args["[REASON]"] = "Error in upload request.  Please visit "
+				"http://secondlife.com/support for help fixing this problem.";
 			gViewerWindow->alertXml("CannotUploadReason", args);
 			break;
 		case 500:
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index d31c7b4f53c65f078a35dfde15abaabc0a44c069..11d55b5215454fa6949bac2c730ba5e118d7087b 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -346,7 +346,7 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
 // static
 void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 										  LLAssetType::EType type,
-										  void* user_data, S32 status)
+										  void* user_data, S32 status, LLExtStat ext_status)
 {
 	llinfos << "LLFloaterCompileQueue::scriptArrived()" << llendl;
 	LLScriptQueueData* data = (LLScriptQueueData*)user_data;
@@ -429,7 +429,7 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 }
 
 // static
-void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	llinfos << "LLFloaterCompileQueue::onSaveTextComplete()" << llendl;
 	if (status)
@@ -442,7 +442,7 @@ void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* use
 }
 
 // static
-void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	llinfos << "LLFloaterCompileQueue::onSaveBytecodeComplete()" << llendl;
 	LLCompileQueueData* data = (LLCompileQueueData*)user_data;
diff --git a/indra/newview/llcompilequeue.h b/indra/newview/llcompilequeue.h
index fc0a872907ee6387adec5c8620299f2d4e2b1a1d..11f3cfb8f26f647e304a4731de8adf5de5f8e7f3 100644
--- a/indra/newview/llcompilequeue.h
+++ b/indra/newview/llcompilequeue.h
@@ -113,12 +113,12 @@ class LLFloaterCompileQueue : public LLFloaterScriptQueue
 	// This is the callback for when each script arrives
 	static void scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 								LLAssetType::EType type,
-								void* user_data, S32 status);
+								void* user_data, S32 status, LLExtStat ext_status);
 
-	static void onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status);
+	static void onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status);
 	static void onSaveBytecodeComplete(const LLUUID& asset_id,
 									   void* user_data,
-									   S32 status);
+									   S32 status, LLExtStat ext_status);
 
 	// compile the file given and save it out.
 	void compile(const char* filename, const LLUUID& asset_id);
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 2626a8bd311c4ec479cd2ac50f0629f51c2b7d55..a2c39b807c9ddb5d98ba97f2a8115cd1321aedcd 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -449,12 +449,14 @@ LLDrawPool* LLRenderPass::instancePool()
 
 void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture)
 {					
-	std::vector<LLDrawInfo*>& draw_info = group->mDrawMap[type];
+	LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type];
 	
-	for (std::vector<LLDrawInfo*>::const_iterator k = draw_info.begin(); k != draw_info.end(); ++k)
+	for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k)	
 	{
-		LLDrawInfo& params = **k;
-		pushBatch(params, mask, texture);
+		LLDrawInfo *pparams = *k;
+		if (pparams) {
+			pushBatch(*pparams, mask, texture);
+		}
 	}
 }
 
@@ -464,14 +466,15 @@ void LLRenderPass::renderInvisible(U32 mask)
 	LLGLState::checkClientArrays(mask);
 #endif
 	
-	std::vector<LLDrawInfo*>& draw_info = gPipeline.mRenderMap[LLRenderPass::PASS_INVISIBLE];
+	LLSpatialGroup::drawmap_elem_t& draw_info = gPipeline.mRenderMap[LLRenderPass::PASS_INVISIBLE];	
 
-	for (std::vector<LLDrawInfo*>::iterator i = draw_info.begin(); i != draw_info.end(); ++i)
+	for (LLSpatialGroup::drawmap_elem_t::iterator i = draw_info.begin(); i != draw_info.end(); ++i)	
 	{
-		LLDrawInfo& params = **i;
+		
+ 		LLDrawInfo *pparams = *i;
+		if (pparams && pparams->mVertexBuffer.notNull()) {
+	 		LLDrawInfo &params = *pparams;
 
-		if (params.mVertexBuffer)
-		{
 			params.mVertexBuffer->setBuffer(mask);
 			U32 *indices_pointer =
 				(U32 *) params.mVertexBuffer->getIndicesPointer();
@@ -489,22 +492,19 @@ void LLRenderPass::renderTexture(U32 type, U32 mask)
 	LLGLState::checkClientArrays(mask);
 #endif
 
-	std::vector<LLDrawInfo*>& draw_info = gPipeline.mRenderMap[type];
+	LLSpatialGroup::drawmap_elem_t& draw_info = gPipeline.mRenderMap[type];	
 
-	for (std::vector<LLDrawInfo*>::iterator i = draw_info.begin(); i != draw_info.end(); ++i)
+	for (LLSpatialGroup::drawmap_elem_t::iterator i = draw_info.begin(); i != draw_info.end(); ++i)	
 	{
-		LLDrawInfo& params = **i;
-		pushBatch(params, mask, TRUE);
+		LLDrawInfo* pparams = *i;
+		if (pparams) {
+			pushBatch(*pparams, mask, TRUE);
+		}
 	}
 }
 
 void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
 {
-	if (params.mVertexBuffer.isNull())
-	{
-		return;
-	}
-
 	if (texture)
 	{
 		if (params.mTexture.notNull())
@@ -522,12 +522,15 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
 			LLImageGL::unbindTexture(0);
 		}
 	}
-	
-	params.mVertexBuffer->setBuffer(mask);
-	U32* indices_pointer = (U32*) params.mVertexBuffer->getIndicesPointer();
-	glDrawRangeElements(GL_TRIANGLES, params.mStart, params.mEnd, params.mCount,
-						GL_UNSIGNED_INT, indices_pointer+params.mOffset);
-	gPipeline.mTrianglesDrawn += params.mCount/3;
+
+	if (params.mVertexBuffer.notNull())
+	{
+		params.mVertexBuffer->setBuffer(mask);
+		U32* indices_pointer = (U32*) params.mVertexBuffer->getIndicesPointer();
+		glDrawRangeElements(GL_TRIANGLES, params.mStart, params.mEnd, params.mCount,
+							GL_UNSIGNED_INT, indices_pointer+params.mOffset);
+		gPipeline.mTrianglesDrawn += params.mCount/3;
+	}
 
 	if (params.mTextureMatrix && texture && params.mTexture.notNull())
 	{
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index de82dff95d79bcf3d290de0b4b33ff9e6eeb89ac..56fb0bc1f9dabd519bdf3481e5b16ce8949c7425 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -199,9 +199,9 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask, std::vector<LLSpatialGroup*
 				last_part = part;
 			}
 
-			std::vector<LLDrawInfo*>& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];
+			LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];	
 
-			for (std::vector<LLDrawInfo*>::const_iterator k = draw_info.begin(); k != draw_info.end(); ++k)
+			for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k)	
 			{
 				LLDrawInfo& params = **k;
 				
@@ -225,7 +225,7 @@ void LLDrawPoolAlpha::renderGroupAlpha(LLSpatialGroup* group, U32 type, U32 mask
 {					
 	BOOL light_enabled = TRUE;
 
-	std::vector<LLDrawInfo*>& draw_info = group->mDrawMap[type];
+	LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type];	
 	
 	U32 prim_type = GL_TRIANGLES;
 
@@ -252,7 +252,7 @@ void LLDrawPoolAlpha::renderGroupAlpha(LLSpatialGroup* group, U32 type, U32 mask
 		glPointSize(width/(view*view));
 	}*/
 
-	for (std::vector<LLDrawInfo*>::const_iterator k = draw_info.begin(); k != draw_info.end(); ++k)
+	for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k)	
 	{
 		LLDrawInfo& params = **k;
 		if (texture && params.mTexture.notNull())
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 67f60ffdfa2a0069dd821b68f38452a20258b017..cc605df0995b63baa02a3ee60baab07774e26c70 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -330,9 +330,9 @@ void LLDrawPoolBump::renderActive(U32 type, U32 mask, BOOL texture)
 
 void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE)
 {					
-	std::vector<LLDrawInfo*>& draw_info = group->mDrawMap[type];
+	LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type];	
 	
-	for (std::vector<LLDrawInfo*>::const_iterator k = draw_info.begin(); k != draw_info.end(); ++k)
+	for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) 
 	{
 		LLDrawInfo& params = **k;
 		if (LLPipeline::sDynamicReflections)
@@ -879,9 +879,9 @@ void LLDrawPoolBump::renderBump(U32 type, U32 mask)
 	LLGLState::checkClientArrays(mask);
 #endif
 
-	std::vector<LLDrawInfo*>& draw_info = gPipeline.mRenderMap[type];
+	LLSpatialGroup::drawmap_elem_t& draw_info = gPipeline.mRenderMap[type];	
 
-	for (std::vector<LLDrawInfo*>::iterator i = draw_info.begin(); i != draw_info.end(); ++i)
+	for (LLSpatialGroup::drawmap_elem_t::iterator i = draw_info.begin(); i != draw_info.end(); ++i)	
 	{
 		LLDrawInfo& params = **i;
 
@@ -894,9 +894,9 @@ void LLDrawPoolBump::renderBump(U32 type, U32 mask)
 
 void LLDrawPoolBump::renderGroupBump(LLSpatialGroup* group, U32 type, U32 mask)
 {					
-	const std::vector<LLDrawInfo*>& draw_info = group->mDrawMap[type];
+	LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type];	
 	
-	for (std::vector<LLDrawInfo*>::const_iterator k = draw_info.begin(); k != draw_info.end(); ++k)
+	for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) 
 	{
 		LLDrawInfo& params = **k;
 		
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index bc35c167ea36f565406f03aafbf918c318e641f3..7597a7057a0c4eecb78f3053f924708cdc613703 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -72,8 +72,8 @@ LLDrawPool *LLDrawPoolWater::instancePool()
 
 void LLDrawPoolWater::prerender()
 {
-	mVertexShaderLevel = gSavedSettings.getBOOL("RenderRippleWater") ?
-				LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT) : 0;
+	mVertexShaderLevel = (gSavedSettings.getBOOL("RenderRippleWater") && gGLManager.mHasCubeMap && gFeatureManagerp->isFeatureAvailable("RenderCubeMap")) ?
+		LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT) : 0;
 
 }
 
@@ -545,7 +545,7 @@ void LLDrawPoolWater::shade()
 	LLCubeMap* skyMap = gSky.mVOSkyp->getCubeMap();
 	
 	gWaterProgram.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB);
-    skyMap->bind();
+	skyMap->bind();
 
 	//bind normal map
 	S32 bumpTex = gWaterProgram.enableTexture(LLShaderMgr::BUMP_MAP);
diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index f3821a8b7a3b33d894227c740d33d5e0547cdc5e..93ff7e430c78a1ea17eff9006972a8e9af04e81e 100644
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -185,8 +185,6 @@ BOOL LLDynamicTexture::updateAllInstances()
 		return TRUE;
 	}
 
-	BOOL started = FALSE;
-		
 	BOOL result = FALSE;
 	for( S32 order = 0; order < ORDER_COUNT; order++ )
 	{
@@ -195,29 +193,22 @@ BOOL LLDynamicTexture::updateAllInstances()
 			dynamicTexture = LLDynamicTexture::sInstances[order].getNextData())
 		{
 			if (dynamicTexture->needsRender())
-			{
-				if (!started)
-				{
-					started = TRUE;
-					LLVertexBuffer::startRender();
-				}
-				
-				dynamicTexture->preRender();
+			{	
+				dynamicTexture->preRender();	// Must be called outside of startRender()
+
+				LLVertexBuffer::startRender();
 				if (dynamicTexture->render())
 				{
 					result = TRUE;
 					sNumRenders++;
 				}
+				LLVertexBuffer::stopRender();
+		
 				dynamicTexture->postRender(result);
 			}
 		}
 	}
 
-	if (started)
-	{
-		LLVertexBuffer::stopRender();
-	}
-	
 	return result;
 }
 
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index 35849552b3e13f2519ea41e1a171c951e6b26831..e1edb5059d19edcd93e283823ad9785e77b075ea 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -382,7 +382,7 @@ void LLFeatureManager::cleanupFeatureTables()
 
 void LLFeatureManager::initCPUFeatureMasks()
 {
-	if (gSysMemory.getPhysicalMemory() <= 256*1024*1024)
+	if (gSysMemory.getPhysicalMemoryClamped() <= 256*1024*1024)
 	{
 		maskFeatures("RAM256MB");
 	}
@@ -474,7 +474,7 @@ extern LLOSInfo gSysOS;
 
 void LLFeatureManager::applyRecommendedFeatures()
 {
-	// see featuretable.txt
+	// see featuretable.txt / featuretable_linux.txt / featuretable_mac.txt
 
 	llinfos << "Applying Recommended Features" << llendl;
 #ifndef LL_RELEASE_FOR_DOWNLOAD
@@ -524,6 +524,10 @@ void LLFeatureManager::applyRecommendedFeatures()
 	// RippleWater
 	BOOL ripple = getRecommendedLevel("RenderRippleWater");
 	gSavedSettings.setBOOL("RenderRippleWater", ripple);
+
+	// Occlusion Culling
+	BOOL occlusion = getRecommendedLevel("UseOcclusion");
+	gSavedSettings.setBOOL("UseOcclusion", occlusion);
 	
 	// Vertex Shaders
 	S32 shaders = getRecommendedLevel("VertexShaderEnable");
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 2e9dba3af48e07ada55837f66a647be5d59d2b7c..aff534974f4533db184be782e4850aea205b4490 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -623,6 +623,15 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
 	volume->updateRelativeXform();
 	doFlexibleUpdate();
 	
+	// Object may have been rotated, which means it needs a rebuild.  See SL-47220
+	BOOL	rotated = FALSE;
+	LLQuaternion cur_rotation = getFrameRotation();
+	if ( cur_rotation != mLastFrameRotation )
+	{
+		mLastFrameRotation = cur_rotation;
+		rotated = TRUE;
+	}
+
 	if (volume->mLODChanged || volume->mFaceMappingChanged ||
 		volume->mVolumeChanged)
 	{
@@ -630,7 +639,7 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
 		volume->mDrawable->setState(LLDrawable::REBUILD_VOLUME);
 	}
 
-	if (!mUpdated || volume->mFaceMappingChanged || volume->mVolumeChanged)
+	if (!mUpdated || volume->mFaceMappingChanged || volume->mVolumeChanged || rotated)
 	{
 		doFlexibleRebuild();
 		volume->genBBoxes(isVolumeGlobal());
diff --git a/indra/newview/llflexibleobject.h b/indra/newview/llflexibleobject.h
index c814f67b911187bc2b1fa07315d120e04b4c23d4..bc9fe958bfb0e14add968f3e4b63c78120f71ced 100644
--- a/indra/newview/llflexibleobject.h
+++ b/indra/newview/llflexibleobject.h
@@ -97,7 +97,7 @@ class LLVolumeImplFlexible : public LLVolumeInterface
 		LLVector3					mAnchorPosition;
 		LLVector3					mParentPosition;
 		LLQuaternion				mParentRotation;
-		LLQuaternion				mInitialAxisRotation;
+		LLQuaternion				mLastFrameRotation;
 		LLQuaternion				mLastSegmentRotation;
 		BOOL						mInitialized;
 		BOOL						mUpdated;
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 8a51c155de4566bb67b97b93b98a7a9ba491ed16..9e6dbccf0fef7e267f792cf87ab69060ea4ae49a 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -99,9 +99,8 @@ LLFloaterAbout::LLFloaterAbout()
 	support.append( gSysCPU.getCPUString() );
 	support.append("\n");
 
-	U32 memory = gSysMemory.getPhysicalMemory() / 1024 / 1024;
-	// For some reason, the reported amount of memory is always wrong by one meg
-	memory++;
+	U32 memory = gSysMemory.getPhysicalMemoryKB() / 1024;
+	// Moved hack adjustment to Windows memory size into llsys.cpp
 
 	LLString mem_text = llformat("Memory: %u MB\n", memory );
 	support.append(mem_text);
@@ -147,8 +146,15 @@ LLFloaterAbout::LLFloaterAbout()
 
 	// Fix views
 	childDisable("credits_editor");
-	childDisable("support_editor");
-	childSetText("support_editor", support);
+
+	LLTextEditor * support_widget = (LLTextEditor *) getChildByName("support_editor", true);
+	if (support_widget)
+	{
+		support_widget->setEnabled( FALSE );
+		support_widget->setTakesFocus( TRUE );
+		support_widget->setText( support );
+		support_widget->setHandleEditKeysDirectly( TRUE );
+	}
 
 	center();
 
diff --git a/indra/newview/llfloateranimpreview.h b/indra/newview/llfloateranimpreview.h
index fe6f19e962a04754dca366dc18b61393d180e261..d55783aab90ab085ddfc94f7c0532d96960a03bf 100644
--- a/indra/newview/llfloateranimpreview.h
+++ b/indra/newview/llfloateranimpreview.h
@@ -82,7 +82,7 @@ class LLFloaterAnimPreview : public LLFloaterNameDesc
 	static void onSaveComplete(const LLUUID& asset_uuid,
 									   LLAssetType::EType type,
 									   void* user_data,
-									   S32 status);
+									   S32 status, LLExtStat ext_status);
 protected:
 	void			draw();
 	void			resetMotion();
diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp
index bc2c340999203d6b19f95ee5ca25f5d836ef132f..dad66c6e9f876146f9f07376a97644bb2ead1509 100644
--- a/indra/newview/llfloaterauction.cpp
+++ b/indra/newview/llfloaterauction.cpp
@@ -35,9 +35,9 @@
 ///----------------------------------------------------------------------------
 
 void auction_j2c_upload_done(const LLUUID& asset_id,
-							   void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
 void auction_tga_upload_done(const LLUUID& asset_id,
-							   void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
 
 ///----------------------------------------------------------------------------
 /// Class llfloaterauction
@@ -238,7 +238,7 @@ void LLFloaterAuction::onClickOK(void* data)
 /// Local function definitions
 ///----------------------------------------------------------------------------
 
-void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLString* name = (LLString*)(user_data);
 	llinfos << "Upload of asset '" << *name << "' " << asset_id
@@ -259,7 +259,7 @@ void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status
 	}
 }
 
-void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLString* name = (LLString*)(user_data);
 	llinfos << "Upload of asset '" << *name << "' " << asset_id
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp
index 0ba0ab89b1111244d46d2980d4091cc4f2e4a3c8..01296ddbae5968fa8336856d9510144f40c8e1b5 100644
--- a/indra/newview/llfloateravatarpicker.cpp
+++ b/indra/newview/llfloateravatarpicker.cpp
@@ -177,29 +177,33 @@ void LLFloaterAvatarPicker::onList(LLUICtrl* ctrl, void* userdata)
 	}
 }
 
+// static callback for inventory picker (select from calling cards)
 void LLFloaterAvatarPicker::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data)
 {
 	LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)data;
-	if (!self)
+	if (self)
 	{
-		return;
+		self->doSelectionChange( items, user_action, data );
 	}
+}
 
-	self->mAvatarIDs.clear();
-	self->mAvatarNames.clear();
-
-	// if we have calling cards, disable select button until 
-	// the inventory picks a valid calling card
-	if (!items.empty())
+// Callback for inventory picker (select from calling cards)
+void LLFloaterAvatarPicker::doSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data)
+{
+	if (!mListNames)
 	{
-		self->childSetEnabled("Select", FALSE);
+		return;
 	}
 
-	if (!self->mListNames)
-	{
-		return;
+	std::vector<LLScrollListItem*> search_items = mListNames->getAllSelected();
+	if ( search_items.size() == 0 )
+	{	// Nothing selected in the search results
+		mAvatarIDs.clear();
+		mAvatarNames.clear();
+		childSetEnabled("Select", FALSE);
 	}
-	
+
+	BOOL	first_calling_card = TRUE;
 	std::deque<LLFolderViewItem*>::const_iterator item_it;
 	for (item_it = items.begin(); item_it != items.end(); ++item_it)
 	{
@@ -210,10 +214,18 @@ void LLFloaterAvatarPicker::onSelectionChange(const std::deque<LLFolderViewItem*
 
 			if (item)
 			{
-				self->mAvatarIDs.push_back(item->getCreatorUUID());
-				self->mAvatarNames.push_back(listenerp->getName());
-				self->childSetEnabled("Select", TRUE);
-				self->mListNames->deselectAllItems();
+				if ( first_calling_card )
+				{	// Have a calling card selected, so clear anything from the search panel
+					first_calling_card = FALSE;
+					mAvatarIDs.clear();
+					mAvatarNames.clear();
+					mListNames->deselectAllItems();
+				}
+
+				// Add calling card info to the selected avatars
+				mAvatarIDs.push_back(item->getCreatorUUID());
+				mAvatarNames.push_back(listenerp->getName());
+				childSetEnabled("Select", TRUE);
 			}
 		}
 	}
diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h
index 694b760f9679893999612b6c21237a17920298c8..ff294b006cd644f744cf04dba0bc1b7020e8b17e 100644
--- a/indra/newview/llfloateravatarpicker.h
+++ b/indra/newview/llfloateravatarpicker.h
@@ -44,6 +44,8 @@ class LLFloaterAvatarPicker : public LLFloater
 	static void onBtnAdd(void* userdata);
 	static void onBtnClose(void* userdata);
 	static void onList(LLUICtrl* ctrl, void* userdata);
+	
+		   void doSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data);
 	static void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data);
 
 	void find();
diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp
index 592cb4186c67d35aec9b5bb34b40795fc92e545d..b3f85ec198508572e04bbdcdc9e80646003785cf 100644
--- a/indra/newview/llfloaterfriends.cpp
+++ b/indra/newview/llfloaterfriends.cpp
@@ -73,12 +73,13 @@ LLPanelFriends::~LLPanelFriends()
 	delete mObserver;
 }
 
-void LLPanelFriends::tick()
+BOOL LLPanelFriends::tick()
 {
 	mEventTimer.stop();
 	mPeriod = 1000000;
 	mAllowRightsChange = TRUE;
 	updateFriends(LLFriendObserver::ADD);
+	return FALSE;
 }
 
 void LLPanelFriends::updateFriends(U32 changed_mask)
diff --git a/indra/newview/llfloaterfriends.h b/indra/newview/llfloaterfriends.h
index 6895e469e514282dc29711ab2d1eb6401570769b..0738b9a036f340e9820f12c4870b8e32e71400cc 100644
--- a/indra/newview/llfloaterfriends.h
+++ b/indra/newview/llfloaterfriends.h
@@ -37,7 +37,7 @@ class LLPanelFriends : public LLPanel, public LLEventTimer
 	 * current instantiation of this floater. There is only once since
 	 * you can currently only look at your local friends.
 	 */
-	virtual void tick();
+	virtual BOOL tick();
 
 	/** 
 	 * @brief This method is called in response to the LLAvatarTracker
diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp
index 6065fc92c93e2c8539fe29eddfee7ef4fb9e031d..d144e667ca4ed1881d5811059b202589aaf368c6 100644
--- a/indra/newview/llfloatergodtools.cpp
+++ b/indra/newview/llfloatergodtools.cpp
@@ -1399,7 +1399,7 @@ void LLPanelRequestTools::onClickRequest(void* data)
 	}
 }
 
-void terrain_download_done(void** data, S32 status)
+void terrain_download_done(void** data, S32 status, LLExtStat ext_status)
 {
 	LLNotifyBox::showXml("TerrainDownloaded");
 }
diff --git a/indra/newview/llfloatergroupinvite.cpp b/indra/newview/llfloatergroupinvite.cpp
index 13ab90cdd39ce745cfea3234766d89df3df511af..a41b24c61c7bda21ca167ac5a8f81a7d89167bec 100644
--- a/indra/newview/llfloatergroupinvite.cpp
+++ b/indra/newview/llfloatergroupinvite.cpp
@@ -87,7 +87,7 @@ LLFloaterGroupInvite::~LLFloaterGroupInvite()
 }
 
 // static
-void LLFloaterGroupInvite::showForGroup(const LLUUID& group_id)
+void LLFloaterGroupInvite::showForGroup(const LLUUID& group_id, std::vector<LLUUID> *agent_ids)
 {
 	// Make sure group_id isn't null
 	if (group_id.isNull())
@@ -111,6 +111,11 @@ void LLFloaterGroupInvite::showForGroup(const LLUUID& group_id)
 
 		fgi->mImpl->mInvitePanelp->clear();
 	}
+
+	if (agent_ids != NULL)
+	{
+		fgi->mImpl->mInvitePanelp->addUsers(*agent_ids);
+	}
 	
 	fgi->center();
 	fgi->open();	/*Flawfinder: ignore*/
diff --git a/indra/newview/llfloatergroupinvite.h b/indra/newview/llfloatergroupinvite.h
index fb47654476f03f5a3e2db45cd5ad422ae9c42cf5..7cf245d15dc004fe29e01519ac323599c74e4beb 100644
--- a/indra/newview/llfloatergroupinvite.h
+++ b/indra/newview/llfloatergroupinvite.h
@@ -19,7 +19,7 @@ class LLFloaterGroupInvite
 public:
 	virtual ~LLFloaterGroupInvite();
 
-	static void showForGroup(const LLUUID &group_id);
+	static void showForGroup(const LLUUID &group_id, std::vector<LLUUID> *agent_ids = NULL);
 
 protected:
 	LLFloaterGroupInvite(const std::string& name,
diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp
index 60cfa3b809d181882814ab12e06fcc9acec70ee7..a9354eb5b83a6632d704e74365b0ac45ca80de5b 100644
--- a/indra/newview/llfloatergroups.cpp
+++ b/indra/newview/llfloatergroups.cpp
@@ -18,6 +18,7 @@
 #include "llfloatergroups.h"
 
 #include "message.h"
+#include "roles_constants.h"
 
 #include "llagent.h"
 #include "llbutton.h"
@@ -36,7 +37,7 @@
 std::map<const LLUUID, LLFloaterGroupPicker*> LLFloaterGroupPicker::sInstances;
 
 // helper functions
-void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id);
+void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 powers_mask = GP_ALL_POWERS);
 
 ///----------------------------------------------------------------------------
 /// Class LLFloaterGroupPicker
@@ -63,7 +64,8 @@ LLFloaterGroupPicker* LLFloaterGroupPicker::createInstance(const LLSD &seed)
 
 LLFloaterGroupPicker::LLFloaterGroupPicker(const LLSD& seed) : 
 	mSelectCallback(NULL),
-	mCallbackUserdata(NULL)
+	mCallbackUserdata(NULL),
+	mPowersMask(GP_ALL_POWERS)
 {
 	mID = seed.asUUID();
 	sInstances.insert(std::make_pair(mID, this));
@@ -81,9 +83,16 @@ void LLFloaterGroupPicker::setSelectCallback(void (*callback)(LLUUID, void*),
 	mCallbackUserdata = userdata;
 }
 
+void LLFloaterGroupPicker::setPowersMask(U64 powers_mask)
+{
+	mPowersMask = powers_mask;
+	postBuild();
+}
+
+
 BOOL LLFloaterGroupPicker::postBuild()
 {
-	init_group_list(LLUICtrlFactory::getScrollListByName(this, "group list"), gAgent.getGroupID());
+	init_group_list(LLUICtrlFactory::getScrollListByName(this, "group list"), gAgent.getGroupID(), mPowersMask);
 
 	childSetAction("OK", onBtnOK, this);
 
@@ -394,7 +403,7 @@ void LLPanelGroups::onGroupList(LLUICtrl* ctrl, void* userdata)
 	if(self) self->enableButtons();
 }
 
-void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id)
+void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 powers_mask)
 {
 	S32 count = gAgent.mGroups.count();
 	LLUUID id;
@@ -407,20 +416,22 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id)
 	{
 		id = gAgent.mGroups.get(i).mID;
 		LLGroupData* group_datap = &gAgent.mGroups.get(i);
-		LLString style = "NORMAL";
-		if(highlight_id == id)
-		{
-			style = "BOLD";
+		if ((group_datap->mPowers & powers_mask) != 0) {
+			LLString style = "NORMAL";
+			if(highlight_id == id)
+			{
+				style = "BOLD";
+			}
+
+			LLSD element;
+			element["id"] = id;
+			element["columns"][0]["column"] = "name";
+			element["columns"][0]["value"] = group_datap->mName;
+			element["columns"][0]["font"] = "SANSSERIF";
+			element["columns"][0]["font-style"] = style;
+
+			group_list->addElement(element, ADD_SORTED);
 		}
-
-		LLSD element;
-		element["id"] = id;
-		element["columns"][0]["column"] = "name";
-		element["columns"][0]["value"] = group_datap->mName;
-		element["columns"][0]["font"] = "SANSSERIF";
-		element["columns"][0]["font-style"] = style;
-
-		group_list->addElement(element, ADD_SORTED);
 	}
 
 	// add "none" to list at top
diff --git a/indra/newview/llfloatergroups.h b/indra/newview/llfloatergroups.h
index 65bed95ea84c94632a647f5393d7bacbea013376..cb6ec25444a8dd7ffe680659ff4b8f06824f3f6c 100644
--- a/indra/newview/llfloatergroups.h
+++ b/indra/newview/llfloatergroups.h
@@ -37,6 +37,7 @@ class LLFloaterGroupPicker : public LLFloater, public LLUIInstanceMgr<LLFloaterG
 	~LLFloaterGroupPicker();
 	void setSelectCallback( void (*callback)(LLUUID, void*), 
 							void* userdata);
+	void setPowersMask(U64 powers_mask);
 	BOOL postBuild();
 
 protected:
@@ -49,6 +50,7 @@ class LLFloaterGroupPicker : public LLFloater, public LLUIInstanceMgr<LLFloaterG
 
 protected:
 	LLUUID mID;
+	U64 mPowersMask;
 	void (*mSelectCallback)(LLUUID id, void* userdata);
 	void* mCallbackUserdata;
 
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index 457a87adb215adb29a5a0927c9941144e788bde5..16875a7e3b41cf832694205e8db181e50e116acc 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -30,6 +30,7 @@
 #include "pipeline.h"
 #include "viewer.h"
 #include "llvieweruictrlfactory.h"
+#include "llviewerimagelist.h"
 
 //static
 S32 LLFloaterImagePreview::sUploadAmount = 10;
@@ -37,9 +38,10 @@ S32 LLFloaterImagePreview::sUploadAmount = 10;
 const S32 PREVIEW_BORDER_WIDTH = 2;
 const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
 const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
-const S32 PREF_BUTTON_HEIGHT = 16;
+const S32 PREF_BUTTON_HEIGHT = 16 + 7 + 16;
 const S32 PREVIEW_TEXTURE_HEIGHT = 300;
 
+
 //-----------------------------------------------------------------------------
 // LLFloaterImagePreview()
 //-----------------------------------------------------------------------------
@@ -86,6 +88,10 @@ BOOL LLFloaterImagePreview::postBuild()
 
 		mSculptedPreview = new LLImagePreviewSculpted(256, 256);
 		mSculptedPreview->setPreviewTarget(mRawImagep, 2.0f);
+
+		if ((mRawImagep->getWidth() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF) &&
+			(mRawImagep->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF))
+			childEnable("lossless_check");
 	}
 	else
 	{
@@ -743,6 +749,7 @@ LLImagePreviewSculpted::LLImagePreviewSculpted(S32 width, S32 height) : LLDynami
 
 	LLVolumeParams volume_params;
 	volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_CIRCLE);
+	volume_params.setSculptID(LLUUID::null, LL_SCULPT_TYPE_SPHERE);
 	mVolume = new LLVolume(volume_params, (F32) MAX_LOD);
 
 	/*
diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp
index 388e8d9cbdacceedd2cbaace082a9d2e209471e9..730d934131213ee79f169cfbe7eccc52352b9de3 100644
--- a/indra/newview/llfloaterinspect.cpp
+++ b/indra/newview/llfloaterinspect.cpp
@@ -35,10 +35,10 @@ LLFloaterInspect::~LLFloaterInspect(void)
 	{
 		if(gToolMgr->getBaseTool() == gToolInspect)
 		{
-			select_tool(gToolNull);
+			gToolMgr->clearTransientTool();
 		}
 		// Switch back to basic toolset
-		gToolMgr->setCurrentToolset(gBasicToolset);
+		gToolMgr->setCurrentToolset(gBasicToolset);	
 	}
 	else
 	{
@@ -65,7 +65,7 @@ void LLFloaterInspect::show(void* ignored)
 	}
 
 	sInstance->open();
-	select_tool(gToolInspect);
+	gToolMgr->setTransientTool(gToolInspect);
 	gSelectMgr->setForceSelection(forcesel);	// restore previouis value
 
 	sInstance->mObjectSelection = gSelectMgr->getSelection();
@@ -236,7 +236,7 @@ void LLFloaterInspect::refresh()
 
 void LLFloaterInspect::onFocusReceived()
 {
-	select_tool(gToolInspect);
+	gToolMgr->setTransientTool(gToolInspect);
 }
 
 void LLFloaterInspect::dirty()
diff --git a/indra/newview/llfloaterpostcard.cpp b/indra/newview/llfloaterpostcard.cpp
index e44dfe7d85d8efaaf661b6887da30d3b3e57b533..fc391ee5201cdc234fb7c48120b72fe547d3c82a 100644
--- a/indra/newview/llfloaterpostcard.cpp
+++ b/indra/newview/llfloaterpostcard.cpp
@@ -271,7 +271,7 @@ void LLFloaterPostcard::onClickPublishHelp(void* data)
 }
 
 // static
-void LLFloaterPostcard::uploadCallback(const LLUUID& asset_id, void *user_data, S32 result) // StoreAssetData callback (fixed)
+void LLFloaterPostcard::uploadCallback(const LLUUID& asset_id, void *user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLFloaterPostcard *self = (LLFloaterPostcard *)user_data;
 	
diff --git a/indra/newview/llfloaterpostcard.h b/indra/newview/llfloaterpostcard.h
index 7ca127877600920e5193fe0ec43296022cc0691d..d029f86345ded9f4a4332fc86ee3bfc83b959609 100644
--- a/indra/newview/llfloaterpostcard.h
+++ b/indra/newview/llfloaterpostcard.h
@@ -38,7 +38,7 @@ class LLFloaterPostcard
 
 	static void uploadCallback(const LLUUID& asset_id,
 							   void *user_data,
-							   S32 result);
+							   S32 result, LLExtStat ext_status);
 
 	static void updateUserInfo(const char *email);
 
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index efbf8a7826a6146506f31588e94917a7bc9d03b1..f61f43fd5e6fab341a6aeb181004c59b4d26e046 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -1463,13 +1463,15 @@ void LLPanelEstateInfo::onClickAddEstateManager(void* user_data)
 	LLCtrlListInterface *list = self->childGetListInterface("estate_manager_name_list");
 	if (!list) return;
 	if (list->getItemCount() >= ESTATE_MAX_MANAGERS)
-	{
+	{	// Tell user they can't add more managers
 		LLString::format_map_t args;
 		args["[MAX_MANAGER]"] = llformat("%d",ESTATE_MAX_MANAGERS);
 		gViewerWindow->alertXml("MaxManagersOnRegion", args);
-		return;
 	}
-	accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd");
+	else
+	{	// Go pick managers to add
+		accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd");
+	}
 }
 
 // static
@@ -1975,7 +1977,7 @@ BOOL LLPanelEstateInfo::postBuild()
 	if (manager_name_list)
 	{
 		manager_name_list->setCommitOnSelectionChange(TRUE);
-		manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS);
+		manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4);	// Allow extras for dupe issue
 	}
 
 	childSetAction("add_estate_manager_btn", onClickAddEstateManager, this);
@@ -2542,7 +2544,7 @@ void LLPanelEstateCovenant::loadInvItem(LLInventoryItem *itemp)
 void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 									   const LLUUID& asset_uuid,
 									   LLAssetType::EType type,
-									   void* user_data, S32 status)
+									   void* user_data, S32 status, LLExtStat ext_status)
 {
 	llinfos << "LLPanelEstateCovenant::onLoadComplete()" << llendl;
 	LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data;
@@ -2953,9 +2955,13 @@ bool LLDispatchSetEstateAccess::operator()(
 		LLNameListCtrl* estate_manager_name_list =
 			LLViewerUICtrlFactory::getNameListByName(panel, "estate_manager_name_list");
 		if (estate_manager_name_list)
-		{
-			estate_manager_name_list->deleteAllItems();
-			for (S32 i = 0; i < num_estate_managers && i < ESTATE_MAX_MANAGERS; i++)
+		{	
+			estate_manager_name_list->deleteAllItems();		// Clear existing entries
+
+			// There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't 
+			// truncate the list unless it's really big.  Go ahead and show the extras so the user doesn't get confused, 
+			// and they can still remove them.
+			for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++)
 			{
 				LLUUID id;
 				memcpy(id.mData, strings[index++].data(), UUID_BYTES);		/* Flawfinder: ignore */
diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h
index 8ab479d6197e00430367d0be00cd301d07ca625e..12e70219d1a23a6354e54223a43dcca0cfa289b5 100644
--- a/indra/newview/llfloaterregioninfo.h
+++ b/indra/newview/llfloaterregioninfo.h
@@ -349,7 +349,7 @@ class LLPanelEstateCovenant : public LLPanelRegionInfo
 	static void onLoadComplete(LLVFS *vfs,
 							   const LLUUID& asset_uuid,
 							   LLAssetType::EType type,
-							   void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
 
 	// Accessor functions
 	static void updateCovenantText(const std::string& string, const LLUUID& asset_id);
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index e1a9a38ccb041d57e3be94ae0230f849f85db842..65509205c26157e036ac3c057dfc97d7bf45621c 100644
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -910,7 +910,7 @@ void LLFloaterReporter::uploadImage()
 
 
 // static
-void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, S32 result) // StoreAssetData callback (fixed)
+void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLUploadDialog::modalUploadFinished();
 
diff --git a/indra/newview/llfloaterreporter.h b/indra/newview/llfloaterreporter.h
index 30de56fb870f1c1665f30c4edd8a3649d6ee3f8f..2fc10b8753c0fede62ea2eeabb4fa9cbf710a8a5 100644
--- a/indra/newview/llfloaterreporter.h
+++ b/indra/newview/llfloaterreporter.h
@@ -74,7 +74,7 @@ class LLFloaterReporter
 	static void onClickObjPicker	(void *userdata);
 	static void onClickSelectAbuser (void *userdata);
 	static void closePickTool	(void *userdata);
-	static void uploadDoneCallback(const LLUUID &uuid, void* user_data, S32 result);
+	static void uploadDoneCallback(const LLUUID &uuid, void* user_data, S32 result, LLExtStat ext_status);
 	static void addDescription(const LLString& description, LLMeanCollisionData *mcd = NULL);
 	static void setDescription(const LLString& description, LLMeanCollisionData *mcd = NULL);
 	
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 5feb8b2f0dd6839308be4f03f52dac5a635e67eb..57f4906b717c2f0139a5ea36ce3b7e0f88449071 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -658,15 +658,17 @@ void LLSnapshotLivePreview::saveTexture()
 		LLVFile::writeFile(formatted->getData(), formatted->getDataSize(), gVFS, new_asset_id, LLAssetType::AT_TEXTURE);
 		std::string pos_string;
 		gAgent.buildLocationString(pos_string);
+		std::string who_took_it;
+		gAgent.buildFullname(who_took_it);
 		upload_new_resource(tid,	// tid
 							LLAssetType::AT_TEXTURE,
-							"Snapshot",
-							pos_string,
+							"Snapshot : " + pos_string,
+							"Taken by " + who_took_it + " at " + pos_string,
 							0,
 							LLAssetType::AT_SNAPSHOT_CATEGORY,
 							LLInventoryType::IT_SNAPSHOT,
 							PERM_ALL,
-							"Snapshot");
+							"Snapshot : " + pos_string);
 	}
 	else
 	{
diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index 0da0958c9b79f9d3bac4aa4e1dccbf29313b5490..22e4004d1a8d0b67d29bf9cb02e6ee0530f9f6d9 100644
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -380,13 +380,18 @@ LLFloaterTools::LLFloaterTools()
 	mSmallHeight = mLargeHeight;
 	if (mTab) mSmallHeight -= mTab->getRect().getHeight();
 	
-	gSavedSettings.setBOOL("ToolboxShowMore", TRUE); // force a toggle initially
-	showMore(FALSE);
+	// force a toggle initially. seems to be needed to correctly initialize 
+	// both "more" and "less" cases. it also seems to be important to begin
+	// with the user's preference first so that it's initial position will
+	// be correct (SL-51192) -MG
+	BOOL show_more = gSavedSettings.getBOOL("ToolboxShowMore"); // get user's preference
+	gSavedSettings.setBOOL("ToolboxShowMore", show_more); // sets up forced toggle below
+	showMore( !show_more ); // does the toggle
+	showMore(  show_more ); // reset the real user's preference
 }
 
 LLFloaterTools::~LLFloaterTools()
 {
-	showMore(FALSE);
 	// children automatically deleted
 }
 
@@ -757,23 +762,20 @@ void LLFloaterTools::showMore(BOOL show_more)
 	{
 		reshape( mRect.getWidth(), mLargeHeight, TRUE);
 		translate( 0, mSmallHeight - mLargeHeight );
-		childSetVisible("button less", true);
-		childSetVisible("button more", false);
 	}
 	else
 	{
 		reshape( mRect.getWidth(), mSmallHeight, TRUE);
 		translate( 0, mLargeHeight - mSmallHeight );
-		childSetVisible("button less", false);
-		childSetVisible("button more", true);
 	}
+	childSetVisible("button less",  show_more);
+	childSetVisible("button more", !show_more);
 }
 
 void LLFloaterTools::showPanel(EInfoPanel panel)
 {
 	llassert(panel >= 0 && panel < PANEL_COUNT);
 	mTab->selectTabByName(PANEL_NAMES[panel]);
-	showMore(TRUE);
 }
 
 void click_show_more(void *userdata)
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index f7bf4de34f3abc73d29e9ee261a824dc988aca65..160fd477b49fe77945000fa7336297fcccf97742 100644
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -247,7 +247,17 @@ void LLFloaterTOS::onContinue( void* userdata )
 	{
 		gAcceptCriticalMessage = TRUE;
 	}
-	gStartupState++;
+
+	// Testing TOS dialog
+	#if ! LL_RELEASE_FOR_DOWNLOAD		
+	if ( LLStartUp::getStartupState() == STATE_LOGIN_WAIT )
+	{
+		LLStartUp::setStartupState( STATE_LOGIN_SHOW );
+	}
+	else 
+	#endif
+
+	LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT );			// Go back and finish authentication
 	self->close(); // destroys this object
 }
 
@@ -257,7 +267,7 @@ void LLFloaterTOS::onCancel( void* userdata )
 	LLFloaterTOS* self = (LLFloaterTOS*) userdata;
 	llinfos << "User disagrees with TOS." << llendl;
 	gViewerWindow->alertXml("MustAgreeToLogIn", login_alert_done);
-	gStartupState = STATE_LOGIN_SHOW;
+	LLStartUp::setStartupState( STATE_LOGIN_SHOW );
 	self->mLoadCompleteCount = 0;  // reset counter for next time we come to TOS
 	self->close(); // destroys this object
 }
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 365926863e68c2e6303f1ff60750edbb0242522b..996e90ed8e88c34f9115dd05e125ad08aec50e7e 100644
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -1222,6 +1222,14 @@ void LLFloaterWorldMap::onLocationCommit( void* userdata )
 
 	LLString str = self->childGetValue("location").asString();
 
+	// Trim any leading and trailing spaces in the search target
+	LLString saved_str = str;
+	LLString::trim( str );
+	if ( str != saved_str )
+	{	// Set the value in the UI if any spaces were removed
+		self->childSetValue("location", str);
+	}
+
 	LLString::toLower(str);
 	gFloaterWorldMap->mCompletingRegionName = str;
 	gWorldMap->mIsTrackingCommit = TRUE;
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index 34a062576f3e2bd4efe66f0e96af7c81cf4f800e..20f00e297d8221d67899eb9d230690db833b4605 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -699,7 +699,15 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask )
 
 BOOL LLFolderViewItem::handleDoubleClick( S32 x, S32 y, MASK mask )
 {
-	preview();
+	if (mListener->getInventoryType() == LLInventoryType::IT_LANDMARK) 
+	{
+		gFocusMgr.setKeyboardFocus(NULL, NULL); // release focus to main window so user can move with arrow keys
+		mListener->performAction(NULL, &gInventory, "teleport");
+	}
+	else
+	{
+		preview();
+	}
 	return TRUE;
 }
 
@@ -2508,6 +2516,7 @@ LLFolderView::LLFolderView( const LLString& name, LLViewerImage* root_folder_ico
 	mShowSelectionContext(FALSE),
 	mShowSingleSelection(FALSE),
 	mArrangeGeneration(0),
+	mUserData(NULL),
 	mSelectCallback(NULL),
 	mSelectionChanged(FALSE),
 	mMinWidth(0),
@@ -4234,73 +4243,89 @@ LLFolderViewItem* LLFolderView::getItemByID(const LLUUID& id)
 	return NULL;
 }
 
-//static
-void LLFolderView::idle(void* user_data)
+
+// Main idle routine
+void LLFolderView::doIdle()
 {
 	LLFastTimer t2(LLFastTimer::FTM_INVENTORY);
-	LLFolderView* self = (LLFolderView*)user_data;
 
 	BOOL debug_filters = gSavedSettings.getBOOL("DebugInventoryFilters");
-	if (debug_filters != self->getDebugFilters())
+	if (debug_filters != getDebugFilters())
 	{
-		self->mDebugFilters = debug_filters;
-		self->arrangeAll();
+		mDebugFilters = debug_filters;
+		arrangeAll();
 	}
 
-	self->mFilter.clearModified();
-	BOOL filter_modified_and_active = self->mCompletedFilterGeneration < self->mFilter.getCurrentGeneration() && 
-										self->mFilter.isNotDefault();
-	self->mNeedsAutoSelect = filter_modified_and_active &&
-							!(gFocusMgr.childHasKeyboardFocus(self) || gFocusMgr.getMouseCapture());
+	mFilter.clearModified();
+	BOOL filter_modified_and_active = mCompletedFilterGeneration < mFilter.getCurrentGeneration() && 
+										mFilter.isNotDefault();
+	mNeedsAutoSelect = filter_modified_and_active &&
+							!(gFocusMgr.childHasKeyboardFocus(this) || gFocusMgr.getMouseCapture());
 	
 	// filter to determine visiblity before arranging
-	self->filterFromRoot();
+	filterFromRoot();
 
 	// automatically show matching items, and select first one
 	// do this every frame until user puts keyboard focus into the inventory window
 	// signaling the end of the automatic update
 	// only do this when mNeedsFilter is set, meaning filtered items have
 	// potentially changed
-	if (self->mNeedsAutoSelect)
+	if (mNeedsAutoSelect)
 	{
 		LLFastTimer t3(LLFastTimer::FTM_AUTO_SELECT);
 		// select new item only if a filtered item not currently selected
-		LLFolderViewItem* selected_itemp = self->mSelectedItems.empty() ? NULL : self->mSelectedItems.back();
-		if ((!selected_itemp || !selected_itemp->getFiltered()) && !self->mAutoSelectOverride)
+		LLFolderViewItem* selected_itemp = mSelectedItems.empty() ? NULL : mSelectedItems.back();
+		if ((!selected_itemp || !selected_itemp->getFiltered()) && !mAutoSelectOverride)
 		{
 			// select first filtered item
 			LLSelectFirstFilteredItem filter;
-			self->applyFunctorRecursively(filter);
+			applyFunctorRecursively(filter);
 		}
-		self->scrollToShowSelection();
+		scrollToShowSelection();
 	}
 
-	self->sanitizeSelection();
+	BOOL is_visible = isInVisibleChain();
 
-	if( self->needsArrange() && self->isInVisibleChain())
+	if ( is_visible )
 	{
-		self->arrangeFromRoot();
+		sanitizeSelection();
+		if( needsArrange() )
+		{
+			arrangeFromRoot();
+		}
 	}
 
-	if (self->mSelectedItems.size() && self->mNeedsScroll)
+	if (mSelectedItems.size() && mNeedsScroll)
 	{
-		self->scrollToShowItem(self->mSelectedItems.back());
+		scrollToShowItem(mSelectedItems.back());
 		// continue scrolling until animated layout change is done
-		if (self->getCompletedFilterGeneration() >= self->mFilter.getMinRequiredGeneration() &&
-			(!self->needsArrange() || !self->isInVisibleChain()))
+		if (getCompletedFilterGeneration() >= mFilter.getMinRequiredGeneration() &&
+			(!needsArrange() || !is_visible))
 		{
-			self->mNeedsScroll = FALSE;
+			mNeedsScroll = FALSE;
 		}
 	}
 
-	if (self->mSelectionChanged && self->mSelectCallback)
+	if (mSelectionChanged && mSelectCallback)
 	{
 		//RN: we use keyboard focus as a proxy for user-explicit actions
-		self->mSelectCallback(self->mSelectedItems, gFocusMgr.childHasKeyboardFocus(self), self->mUserData);
+		mSelectCallback(mSelectedItems, gFocusMgr.childHasKeyboardFocus(this), mUserData);
 	}
-	self->mSelectionChanged = FALSE;
+	mSelectionChanged = FALSE;
 }
 
+
+//static
+void LLFolderView::idle(void* user_data)
+{
+	LLFolderView* self = (LLFolderView*)user_data;
+	if ( self )
+	{	// Do the real idle 
+		self->doIdle();
+	}
+}
+
+
 void LLFolderView::dumpSelectionInformation()
 {
 	llinfos << "LLFolderView::dumpSelectionInformation()" << llendl;
diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h
index 97071862de1ca6f0a1f96b4dfec7ce9c3c630495..79a3b742485884a9213ebd21384f0336ee9b6832 100644
--- a/indra/newview/llfolderview.h
+++ b/indra/newview/llfolderview.h
@@ -839,7 +839,8 @@ class LLFolderView : public LLFolderViewFolder, LLEditMenuHandler
 	void removeItemID(const LLUUID& id);
 	LLFolderViewItem* getItemByID(const LLUUID& id);
 
-	static void idle(void* user_data);
+	void	doIdle();						// Real idle routine
+	static void idle(void* user_data);		// static glue to doIdle()
 
 	BOOL needsAutoSelect() { return mNeedsAutoSelect && !mAutoSelectOverride; }
 	BOOL needsAutoRename() { return mNeedsAutoRename; }
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 3c51d7dcf19f86d03590cdae3fbc3442ebdcce9d..af35a7211d2d91b882ff6a599976ca092e94a3f6 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -877,7 +877,7 @@ void LLGestureManager::runStep(LLMultiGesture* gesture, LLGestureStep* step)
 void LLGestureManager::onLoadComplete(LLVFS *vfs,
 									   const LLUUID& asset_uuid,
 									   LLAssetType::EType type,
-									   void* user_data, S32 status)
+									   void* user_data, S32 status, LLExtStat ext_status)
 {
 	LLLoadInfo* info = (LLLoadInfo*)user_data;
 
diff --git a/indra/newview/llgesturemgr.h b/indra/newview/llgesturemgr.h
index c68ca4f265c5e8d2a9a2891a0d03d8045267e2fa..33d453fc308156282b8089096c3773cf3cf5f8c2 100644
--- a/indra/newview/llgesturemgr.h
+++ b/indra/newview/llgesturemgr.h
@@ -112,7 +112,7 @@ class LLGestureManager
 	static void onLoadComplete(LLVFS *vfs,
 						   const LLUUID& asset_uuid,
 						   LLAssetType::EType type,
-						   void* user_data, S32 status);
+						   void* user_data, S32 status, LLExtStat ext_status);
 
 public:
 	BOOL mValid;
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 8a08bd2a4b78a2e14a858ed634e61d514d996352..073d6cc0888c17080f7a73082eb1917ba38da205 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -68,10 +68,14 @@
 void inc_busy_count()
 {
 // 	gViewerWindow->getWindow()->incBusyCount();
+//  check balance of these calls if this code is changed to ever actually
+//  *do* something!
 }
 void dec_busy_count()
 {
 // 	gViewerWindow->getWindow()->decBusyCount();
+//  check balance of these calls if this code is changed to ever actually
+//  *do* something!
 }
 
 // Function declarations
@@ -886,7 +890,7 @@ BOOL LLItemBridge::removeItem()
 		return FALSE;
 	}
 	// move it to the trash
-	LLPreview::hide(mUUID);
+	LLPreview::hide(mUUID, TRUE);
 	LLInventoryModel* model = mInventoryPanel->getModel();
 	if(!model) return FALSE;
 	LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH);
@@ -1345,6 +1349,17 @@ class LLRightClickInventoryFetchDescendentsObserver : public LLInventoryFetchDes
 
 void LLRightClickInventoryFetchDescendentsObserver::done()
 {
+	// Avoid passing a NULL-ref as mCompleteFolders.front() down to
+	// gInventory.collectDescendents()
+	if( mCompleteFolders.empty() )
+	{
+		llwarns << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << llendl;
+		dec_busy_count();
+		gInventory.removeObserver(this);
+		delete this;
+		return;
+	}
+
 	// What we do here is get the complete information on the items in
 	// the library, and set up an observer that will wait for that to
 	// happen.
@@ -1355,7 +1370,7 @@ void LLRightClickInventoryFetchDescendentsObserver::done()
 								  item_array,
 								  LLInventoryModel::EXCLUDE_TRASH);
 	S32 count = item_array.count();
-#if 0
+#if 0 // HACK/TODO: Why?
 	// This early causes a giant menu to get produced, and doesn't seem to be needed.
 	if(!count)
 	{
@@ -2899,7 +2914,6 @@ void LLGestureBridge::openItem()
 BOOL LLGestureBridge::removeItem()
 {
 	// Force close the preview window, if it exists
-	LLPreview::hide(mUUID);
 	gGestureManager.deactivateGesture(mUUID);
 	return LLItemBridge::removeItem();
 }
@@ -3438,13 +3452,27 @@ class LLWearInventoryCategoryCallback : public LLInventoryCallback
 	{
 		/*
 		 * Do nothing.  We only care about the destructor
+		 *
+		 * The reason for this is that this callback is used in a hack where the
+		 * same callback is given to dozens of items, and the destructor is called
+		 * after the last item has fired the event and dereferenced it -- if all
+		 * the events actually fire!
 		 */
 	}
 
 protected:
 	~LLWearInventoryCategoryCallback()
 	{
-		wear_inventory_category_on_avatar(gInventory.getCategory(mCatID), mAppend);
+		// Is the destructor called by ordinary dereference, or because the app's shutting down?
+		// If the inventory callback manager goes away, we're shutting down, no longer want the callback.
+		if( LLInventoryCallbackManager::is_instantiated() )
+		{
+			wear_inventory_category_on_avatar(gInventory.getCategory(mCatID), mAppend);
+		}
+		else
+		{
+			llwarns << "Dropping unhandled LLWearInventoryCategoryCallback" << llendl;
+		}
 	}
 
 private:
@@ -4194,8 +4222,16 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 		items.push_back("Restore Item");
 	}
 	else
-	{
+	{	// FWIW, it looks like SUPPRESS_OPEN_ITEM is not set anywhere
 		BOOL no_open = ((flags & SUPPRESS_OPEN_ITEM) == SUPPRESS_OPEN_ITEM);
+
+		// If we have clothing, don't add "Open" as it's the same action as "Wear"   SL-18976
+		LLViewerInventoryItem* item = getItem();
+		if( !no_open && item )
+		{
+			no_open = (item->getType() == LLAssetType::AT_CLOTHING);
+		}
+
 		if (!no_open)
 		{
 			items.push_back("Open");
@@ -4222,7 +4258,6 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 										 LLWearableBridge::canEditOnAvatar,
 										 (void*)this));*/
 
-		LLViewerInventoryItem* item = getItem();
 		if( item && (item->getType() == LLAssetType::AT_CLOTHING) )
 		{
 			items.push_back("Take Off");
diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp
index 57684fbc18946c38721b6ec76a6404b2ef7713a1..c8446e718f58978c75bdd6bff6c57f6c6d1b18fe 100644
--- a/indra/newview/lllandmarklist.cpp
+++ b/indra/newview/lllandmarklist.cpp
@@ -57,7 +57,8 @@ void LLLandmarkList::processGetAssetReply(
 	const LLUUID& uuid,
 	LLAssetType::EType type,
 	void* user_data,
-	S32 status)
+	S32 status, 
+	LLExtStat ext_status )
 {
 	if( status == 0 )
 	{
diff --git a/indra/newview/lllandmarklist.h b/indra/newview/lllandmarklist.h
index 15e900b601f4e27d3aea0b76ea671cb0d0338372..2c58fd09b240988dca0361c754926a72dc21373a 100644
--- a/indra/newview/lllandmarklist.h
+++ b/indra/newview/lllandmarklist.h
@@ -35,7 +35,8 @@ class LLLandmarkList
 		const LLUUID& uuid,
 		LLAssetType::EType type,
 		void* user_data,
-		S32 status);
+		S32 status,
+		LLExtStat ext_status );
 
 protected:
 	typedef std::map<LLUUID, LLLandmark*> landmark_list_t;
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index bdb6380368e3587244ea12e8c8feb46364bcef4c..c01ca4d0fa15e6022be02002ed695e68a7b2e29e 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -329,7 +329,7 @@ BOOL LLManipTranslate::handleMouseDownOnPart( S32 x, S32 y, MASK mask )
 	if (!selected_object)
 	{
 		// somehow we lost the object!
-		llwarns << "Translate manip lost the object" << llendl;
+		llwarns << "Translate manip lost the object, no selected object" << llendl;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
@@ -347,9 +347,12 @@ BOOL LLManipTranslate::handleMouseDownOnPart( S32 x, S32 y, MASK mask )
 	if (mManipPart >= LL_YZ_PLANE && mManipPart <= LL_XY_PLANE)
 	{
 		LLCoordGL mouse_pos;
-		gCamera->projectPosAgentToScreen(select_center_agent, mouse_pos);
-
-		if (gSavedSettings.getBOOL("SnapToMouseCursor"))
+		if (!gCamera->projectPosAgentToScreen(select_center_agent, mouse_pos))
+		{
+			// mouse_pos may be nonsense
+			llwarns << "Failed to project object center to screen" << llendl;
+		}
+		else if (gSavedSettings.getBOOL("SnapToMouseCursor"))
 		{
 			LLUI::setCursorPositionScreen(mouse_pos.mX, mouse_pos.mY);
 			x = mouse_pos.mX;
@@ -460,7 +463,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	if (!selectNode)
 	{
 		// somehow we lost the object!
-		llwarns << "Translate manip lost the object" << llendl;
+		llwarns << "Translate manip lost the object, no selectNode" << llendl;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
@@ -469,7 +472,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	if (!object)
 	{
 		// somehow we lost the object!
-		llwarns << "Translate manip lost the object" << llendl;
+		llwarns << "Translate manip lost the object, no object in selectNode" << llendl;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp
index 62c7d40a90fe8a1cb3794c71744f8cbb0d29e088..eb0b7e620a721f4fb21b24b74c58ce5fdcaa98c6 100644
--- a/indra/newview/llmutelist.cpp
+++ b/indra/newview/llmutelist.cpp
@@ -172,7 +172,7 @@ BOOL LLMuteList::isLinden(const LLString& name) const
 BOOL LLMuteList::add(const LLMute& mute, U32 flags)
 {
 	// Can't mute text from Lindens
-	if ((mute.mType == LLMute::AGENT || mute.mType == LLMute::BY_NAME)
+	if ((mute.mType == LLMute::AGENT)
 		&& isLinden(mute.mName) && (flags & LLMute::flagTextChat || flags == 0))
 	{
 		gViewerWindow->alertXml("MuteLinden");
@@ -593,7 +593,7 @@ void LLMuteList::processUseCachedMuteList(LLMessageSystem* msg, void**)
 	gMuteListp->loadFromFile(filename);
 }
 
-void LLMuteList::onFileMuteList(void** user_data, S32 error_code)
+void LLMuteList::onFileMuteList(void** user_data, S32 error_code, LLExtStat ext_status)
 {
 	llinfos << "LLMuteList::processMuteListFile()" << llendl;
 	if (!gMuteListp) return;
diff --git a/indra/newview/llmutelist.h b/indra/newview/llmutelist.h
index f035e4c2b1bf8fbcb94fcca0a90d892427783a3b..a7ac7e3321f1c7fc5ed170a6a2578ffdc1bdd873 100644
--- a/indra/newview/llmutelist.h
+++ b/indra/newview/llmutelist.h
@@ -103,7 +103,7 @@ class LLMuteList
 	static void processMuteListUpdate(LLMessageSystem* msg, void**);
 	static void processUseCachedMuteList(LLMessageSystem* msg, void**);
 
-	static void onFileMuteList(void** user_data, S32 code);
+	static void onFileMuteList(void** user_data, S32 code, LLExtStat ext_status);
 
 private:
 	struct compare_by_name
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index afba55f4aa87385842daad4c9f792dbe1cdc2722..477947003929bff656cebed87f4668a424aa8a73 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -249,7 +249,7 @@ void LLPanelClassified::apply()
 {
 	// Apply is used for automatically saving results, so only
 	// do that if there is a difference, and this is a save not create.
-	if (mDirty && mPaidFor)
+	if (checkDirty() && mPaidFor)
 	{
 		sendClassifiedInfoUpdate();
 	}
@@ -293,7 +293,8 @@ void LLPanelClassified::saveCallback(S32 option, void* data)
 
 BOOL LLPanelClassified::canClose()
 {
-	if (mForceClose || !mDirty) return TRUE;
+	if (mForceClose || !checkDirty()) 
+		return TRUE;
 
 	LLString::format_map_t args;
 	args["[NAME]"] = mNameEditor->getText();
@@ -656,7 +657,7 @@ void LLPanelClassified::refresh()
 		mSetBtn->setVisible(is_self);
 		mSetBtn->setEnabled(is_self);
 
-		mUpdateBtn->setEnabled(is_self && mDirty);
+		mUpdateBtn->setEnabled(is_self && checkDirty());
 		mUpdateBtn->setVisible(is_self);
 	}
 }
@@ -716,29 +717,44 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, LLString text, vo
 
 }
 
-// static
-void LLPanelClassified::callbackConfirmPublish(S32 option, void* data)
-{
-	LLPanelClassified* self = (LLPanelClassified*)data;
 
+// invoked from callbackConfirmPublish
+void LLPanelClassified::confirmPublish(S32 option)
+{
 	// Option 0 = publish
 	if (option != 0) return;
 
-	self->sendClassifiedInfoUpdate();
+	sendClassifiedInfoUpdate();
 
 	// Big hack - assume that top picks are always in a browser,
 	// and non-finder-classifieds are always in a tab container.
-	if (self->mInFinder)
+	if (mInFinder)
 	{
 		// TODO: enable this
-		//LLPanelDirClassifieds* panel = (LLPanelDirClassifieds*)self->getParent();
-		//panel->renameClassified(self->mClassifiedID, self->mNameEditor->getText().c_str());
+		//LLPanelDirClassifieds* panel = (LLPanelDirClassifieds*)getParent();
+		//panel->renameClassified(mClassifiedID, mNameEditor->getText().c_str());
 	}
 	else
 	{
-		LLTabContainerVertical* tab = (LLTabContainerVertical*)self->getParent();
-		tab->setCurrentTabName(self->mNameEditor->getText());
+		LLTabContainerVertical* tab = (LLTabContainerVertical*)getParent();
+		tab->setCurrentTabName(mNameEditor->getText());
 	}
+
+	// Tell all the widgets to reset their dirty state since the ad was just saved
+	mSnapshotCtrl->resetDirty();
+	mNameEditor->resetDirty();
+	mDescEditor->resetDirty();
+	mLocationEditor->resetDirty();
+	mCategoryCombo->resetDirty();
+	mMatureCheck->resetDirty();
+	mAutoRenewCheck->resetDirty();
+}
+
+// static
+void LLPanelClassified::callbackConfirmPublish(S32 option, void* data)
+{
+	LLPanelClassified* self = (LLPanelClassified*)data;
+	self->confirmPublish(option);
 }
 
 // static
@@ -811,13 +827,27 @@ void LLPanelClassified::onClickSet(void* data)
 }
 
 
+BOOL LLPanelClassified::checkDirty()
+{
+	mDirty = FALSE;
+	if	( mSnapshotCtrl )			mDirty |= mSnapshotCtrl->isDirty();
+	if	( mNameEditor )				mDirty |= mNameEditor->isDirty();
+	if	( mDescEditor )				mDirty |= mDescEditor->isDirty();
+	if	( mLocationEditor )			mDirty |= mLocationEditor->isDirty();
+	if	( mCategoryCombo )			mDirty |= mCategoryCombo->isDirty();
+	if	( mMatureCheck )			mDirty |= mMatureCheck->isDirty();
+	if	( mAutoRenewCheck )			mDirty |= mAutoRenewCheck->isDirty();
+
+	return mDirty;
+}
+
 // static
 void LLPanelClassified::onCommitAny(LLUICtrl* ctrl, void* data)
 {
 	LLPanelClassified* self = (LLPanelClassified*)data;
 	if (self)
 	{
-		self->mDirty = true;
+		self->checkDirty();
 	}
 }
 
@@ -825,7 +855,6 @@ void LLPanelClassified::onCommitAny(LLUICtrl* ctrl, void* data)
 void LLPanelClassified::onFocusReceived(LLUICtrl* ctrl, void* data)
 {
 	// allow the data to be saved
-	// Dave/Simon TODO: replace this with better isDirty() functionality
 	onCommitAny(ctrl, data);
 }
 
diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h
index 21f6f9263cd0d91b63ae75d8285c38d70b7c28f0..284016f14980a8c319ff8fc61cd862337cde4c30 100644
--- a/indra/newview/llpanelclassified.h
+++ b/indra/newview/llpanelclassified.h
@@ -71,6 +71,7 @@ class LLPanelClassified : public LLPanel
 
     void sendClassifiedInfoRequest();
 	void sendClassifiedInfoUpdate();
+	void confirmPublish(S32 option);
 
     static void processClassifiedInfoReply(LLMessageSystem* msg, void**);
 
@@ -90,10 +91,11 @@ class LLPanelClassified : public LLPanel
 	static void onCommitAny(LLUICtrl* ctrl, void* data);
 
 	void sendClassifiedClickMessage(const char* type);
+	BOOL checkDirty();		// Update and return mDirty
 
 protected:
 	BOOL mInFinder;
-	bool mDirty;
+	BOOL mDirty;
 	bool mForceClose;
 	LLUUID mClassifiedID;
 	LLUUID mRequestedID;
@@ -114,7 +116,6 @@ class LLPanelClassified : public LLPanel
 	// Values the user may change
 	LLTextureCtrl*	mSnapshotCtrl;
 	LLLineEditor*	mNameEditor;
-	LLLineEditor*	mDateEditor;
 	LLTextEditor*	mDescEditor;
 	LLLineEditor*	mLocationEditor;
 	LLComboBox*		mCategoryCombo;
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 9967a7011183851d1891bb22ca8b7d37616813df..ce51c594137ba4e68431760d965f414d7c3c8484 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -50,7 +50,6 @@ LLPanelGroupGeneral::LLPanelGroupGeneral(const std::string& name,
 	mFounderName(NULL),
 	mInsignia(NULL),
 	mEditCharter(NULL),
-	mEditName(NULL),
 	mBtnJoinGroup(NULL),
 	mListVisibleMembers(NULL),
 	mCtrlShowInGroupList(NULL),
@@ -236,7 +235,7 @@ BOOL LLPanelGroupGeneral::postBuild()
 void LLPanelGroupGeneral::onCommitAny(LLUICtrl* ctrl, void* data)
 {
 	LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
-	self->mChanged = TRUE;
+	self->updateChanged();
 	self->notifyObservers();
 }
 
@@ -791,3 +790,22 @@ void LLPanelGroupGeneral::updateMembers()
 		mListVisibleMembers->setEnabled(FALSE);
 	}
 }
+
+
+void LLPanelGroupGeneral::updateChanged()
+{
+	mChanged = FALSE;
+	if ( mGroupNameEditor )
+		mChanged  = mGroupNameEditor->isDirty();
+	if ( mGroupName )
+		mChanged |= mGroupName->isDirty();
+	if ( mFounderName )
+		mChanged |= mFounderName->isDirty();
+	if ( mInsignia )
+		mChanged |= mInsignia->isDirty();
+	if ( mEditCharter )
+		mChanged |= mEditCharter->isDirty();
+//	if ( mCtrlReceiveNotices )			// "Receive group notices" is different, see onReceiveNotices()
+//		mChanged |= mCtrlReceiveNotices->isDirty();
+}
+
diff --git a/indra/newview/llpanelgroupgeneral.h b/indra/newview/llpanelgroupgeneral.h
index d62cab01333dd263dda92e43ac87300ce96f8413..76a4d791e1c17aa3d45fabcfa4d3736c321d9ace 100644
--- a/indra/newview/llpanelgroupgeneral.h
+++ b/indra/newview/llpanelgroupgeneral.h
@@ -54,6 +54,7 @@ class LLPanelGroupGeneral : public LLPanelGroupTab
     static void joinDlgCB(S32 which, void *userdata);
 
 	void updateMembers();
+	void updateChanged();
 
 	BOOL			mPendingMemberUpdate;
 	BOOL			mChanged;
@@ -68,7 +69,6 @@ class LLPanelGroupGeneral : public LLPanelGroupTab
 	LLNameBox			*mFounderName;
 	LLTextureCtrl		*mInsignia;
 	LLTextEditor		*mEditCharter;
-	LLLineEditor		*mEditName;
 	LLButton			*mBtnJoinGroup;
 	LLButton			*mBtnInfo;
 
diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp
index 12ac66e9fb61ebc8081baff63aa61cac6e3f89ee..538269280efda84f09d6b9369cbae6f6b7c6fe5d 100644
--- a/indra/newview/llpanelgroupinvite.cpp
+++ b/indra/newview/llpanelgroupinvite.cpp
@@ -16,6 +16,9 @@
 #include "llgroupmgr.h"
 #include "llnamelistctrl.h"
 #include "llspinctrl.h"
+#include "lltextbox.h"
+#include "llviewerobject.h"
+#include "llviewerobjectlist.h"
 #include "llvieweruictrlfactory.h"
 
 class LLPanelGroupInvite::impl
@@ -45,7 +48,9 @@ class LLPanelGroupInvite::impl
 
 	LLNameListCtrl	*mInvitees;
 	LLComboBox      *mRoleNames;
-	LLButton		*mRemoveButton;
+	LLButton		*mOKButton;
+ 	LLButton		*mRemoveButton;
+	LLTextBox		*mGroupName;
 
 	void (*mCloseCallback)(void* data);
 
@@ -288,6 +293,8 @@ LLPanelGroupInvite::LLPanelGroupInvite(const std::string& name,
 	: LLPanel(name)
 {
 	mImplementation = new impl(group_id);
+	mPendingUpdate = FALSE;
+	mStoreSelected = LLUUID::null;
 
 	std::string panel_def_file;
 
@@ -309,29 +316,132 @@ void LLPanelGroupInvite::setCloseCallback(void (*close_callback)(void*),
 
 void LLPanelGroupInvite::clear()
 {
+	mStoreSelected = LLUUID::null;
 	mImplementation->mInvitees->deleteAllItems();
 	mImplementation->mRoleNames->clear();
 	mImplementation->mRoleNames->removeall();
+	mImplementation->mOKButton->setEnabled(FALSE);
 }
 
+void LLPanelGroupInvite::addUsers(std::vector<LLUUID>& agent_ids)
+{
+	std::vector<std::string> names;
+	for (S32 i = 0; i < (S32)agent_ids.size(); i++)
+	{
+		LLUUID agent_id = agent_ids[i];
+		LLViewerObject* dest = gObjectList.findObject(agent_id);
+		if(dest && dest->isAvatar())
+		{
+			LLString fullname;
+			LLString::format_map_t args;
+			LLNameValue* nvfirst = dest->getNVPair("FirstName");
+			LLNameValue* nvlast = dest->getNVPair("LastName");
+			if(nvfirst && nvlast)
+			{
+				args["[FIRST]"] = nvfirst->getString();
+				args["[LAST]"] = nvlast->getString();
+				fullname = nvfirst->getString();
+				fullname += " ";
+				fullname += nvlast->getString();
+			}
+			if (!fullname.empty())
+			{
+				names.push_back(fullname);
+			} 
+			else 
+			{
+				llwarns << "llPanelGroupInvite: Selected avatar has no name: " << dest->getID() << llendl;
+				names.push_back("(Unknown)");
+			}
+		}
+	}
+	mImplementation->addUsers(names, agent_ids);
+}
+
+void LLPanelGroupInvite::draw()
+{
+	LLPanel::draw();
+	if (mPendingUpdate)
+	{
+		updateLists();
+	}
+}
+ 
 void LLPanelGroupInvite::update()
+{
+	mPendingUpdate = FALSE;
+	if (mImplementation->mGroupName) 
+	{
+		mImplementation->mGroupName->setText("(loading...)");
+	}
+	if ( mImplementation->mRoleNames ) 
+	{
+		mStoreSelected = mImplementation->mRoleNames->getCurrentID();
+		mImplementation->mRoleNames->clear();
+		mImplementation->mRoleNames->removeall();
+		mImplementation->mRoleNames->add("(loading...)", LLUUID::null, ADD_BOTTOM);
+		mImplementation->mRoleNames->setCurrentByID(LLUUID::null);
+	}
+
+	updateLists();
+}
+
+void LLPanelGroupInvite::updateLists()
 {
 	LLGroupMgrGroupData* gdatap = gGroupMgr->getGroupData(mImplementation->mGroupID);
+	BOOL waiting = FALSE;
 
-	if (!gdatap || !gdatap->isRoleDataComplete())
+	if (gdatap) 
+	{
+		if (gdatap->isGroupPropertiesDataComplete()) 
+		{
+			if (mImplementation->mGroupName) 
+			{
+				mImplementation->mGroupName->setText(gdatap->mName);
+			}
+		} 
+		else 
+		{
+			waiting = TRUE;
+		}
+		if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete()) 
+		{
+			if ( mImplementation->mRoleNames )
+			{
+				mImplementation->mRoleNames->clear();
+				mImplementation->mRoleNames->removeall();
+
+				//add the role names and select the everybody role by default
+				mImplementation->addRoleNames(gdatap);
+				mImplementation->mRoleNames->setCurrentByID(mStoreSelected);
+			}
+		} 
+		else 
+		{
+			waiting = TRUE;
+		}
+	} 
+	else 
 	{
-		gGroupMgr->sendGroupRoleDataRequest(mImplementation->mGroupID);
+		waiting = TRUE;
 	}
+
+	if (waiting) 
+	{
+		if (!mPendingUpdate) 
+		{
+			gGroupMgr->sendGroupPropertiesRequest(mImplementation->mGroupID);
+			gGroupMgr->sendGroupMembersRequest(mImplementation->mGroupID);
+			gGroupMgr->sendGroupRoleDataRequest(mImplementation->mGroupID);
+		}
+		mPendingUpdate = TRUE;
+	} 
 	else
 	{
-		if ( mImplementation->mRoleNames )
+		mPendingUpdate = FALSE;
+		if (mImplementation->mOKButton && mImplementation->mRoleNames->getItemCount()) 
 		{
-			mImplementation->mRoleNames->clear();
-			mImplementation->mRoleNames->removeall();
-
-			//add the role names and select the everybody role by default
-			mImplementation->addRoleNames(gdatap);
-			mImplementation->mRoleNames->setCurrentByID(LLUUID::null);
+			mImplementation->mOKButton->setEnabled(TRUE);
 		}
 	}
 }
@@ -342,6 +452,7 @@ BOOL LLPanelGroupInvite::postBuild()
 
 	mImplementation->mRoleNames = (LLComboBox*) getChildByName("role_name",
 															   recurse);
+	mImplementation->mGroupName = (LLTextBox*) getChildByName("group_name_text", recurse);
 	mImplementation->mInvitees = 
 		(LLNameListCtrl*) getChildByName("invitee_list", recurse);
 	if ( mImplementation->mInvitees )
@@ -370,12 +481,15 @@ BOOL LLPanelGroupInvite::postBuild()
 		mImplementation->mRemoveButton->setEnabled(FALSE);
 	}
 
-	button = (LLButton*) getChildByName("ok_button", recurse);
-	if ( button )
-	{
-		button->setClickedCallback(impl::callbackClickOK);
-		button->setCallbackUserData(mImplementation);
-	}
+	mImplementation->mOKButton = 
+		(LLButton*) getChildByName("ok_button", recurse);
+	if ( mImplementation->mOKButton )
+ 	{
+		mImplementation->mOKButton->
+				setClickedCallback(impl::callbackClickOK);
+		mImplementation->mOKButton->setCallbackUserData(mImplementation);
+		mImplementation->mOKButton->setEnabled(FALSE);
+ 	}
 
 	button = (LLButton*) getChildByName("cancel_button", recurse);
 	if ( button )
diff --git a/indra/newview/llpanelgroupinvite.h b/indra/newview/llpanelgroupinvite.h
index bab39a1a6606e54bff259929f96f77d1c16673d2..d3ef6af83881df773d25d8beaeaf8caed6eb93d0 100644
--- a/indra/newview/llpanelgroupinvite.h
+++ b/indra/newview/llpanelgroupinvite.h
@@ -17,16 +17,22 @@ class LLPanelGroupInvite
 public:
 	LLPanelGroupInvite(const std::string& name, const LLUUID& group_id);
 	~LLPanelGroupInvite();
-
+	
+	void addUsers(std::vector<LLUUID>& agent_ids);
 	void clear();
 	void update();
 
 	void setCloseCallback(void (*close_callback)(void*), void* data);
 
+	virtual void draw();
 	virtual BOOL postBuild();
 protected:
 	class impl;
 	impl* mImplementation;
+
+	BOOL mPendingUpdate;
+	LLUUID mStoreSelected;
+	void updateLists();
 };
 
 #endif
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index 6e1a1b9f09163ca05447656f2e8e4bd0ee77b377..7a05f2bdbf0b87b0fdd49bfb77d9c563a1e22db0 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -119,6 +119,9 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
 	{
 		llwarns << "Duplicate instance of login view deleted" << llendl;
 		delete LLPanelLogin::sInstance;
+
+		// Don't leave bad pointer in gFocusMgr
+		gFocusMgr.setDefaultKeyboardFocus(NULL);
 	}
 
 	LLPanelLogin::sInstance = this;
@@ -505,9 +508,10 @@ void LLPanelLogin::show(const LLRect &rect,
 	{
 		// Grab focus and move cursor to first enabled control
 		sInstance->setFocus(TRUE);
-		// make sure that focus always goes here
-		gFocusMgr.setDefaultKeyboardFocus(sInstance);
 	}
+
+	// Make sure that focus always goes here (and use the latest sInstance that was just created)
+	gFocusMgr.setDefaultKeyboardFocus(sInstance);
 }
 
 // static
@@ -588,35 +592,40 @@ void LLPanelLogin::getFields(LLString &firstname, LLString &lastname, LLString &
 }
 
 
-// static
-void LLPanelLogin::getServer(LLString &server, S32 &domain_name)
+// static.  Return TRUE if user made a choice from the popup
+BOOL LLPanelLogin::getServer(LLString &server, S32 &domain_name)
 {
+	BOOL user_picked = FALSE;
 	if (!sInstance)
 	{
 		llwarns << "Attempted getServer with no login view shown" << llendl;
-		return;
 	}
-
-	LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(sInstance, "server_combo");
-	if (combo)
+	else
 	{
-		LLSD combo_val = combo->getValue();
-		if (LLSD::TypeInteger == combo_val.type())
+		LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(sInstance, "server_combo");
+		if (combo)
 		{
-			domain_name = combo->getValue().asInteger();
+			LLSD combo_val = combo->getValue();
+			if (LLSD::TypeInteger == combo_val.type())
+			{
+				domain_name = combo->getValue().asInteger();
 
-			if ((S32)USERSERVER_OTHER == domain_name)
+				if ((S32)USERSERVER_OTHER == domain_name)
+				{
+					server = gUserServerName;
+				}
+			}
+			else
 			{
-				server = gUserServerName;
+				// no valid selection, return other
+				domain_name = (S32)USERSERVER_OTHER;
+				server = combo_val.asString();
 			}
-		}
-		else
-		{
-			// no valid selection, return other
-			domain_name = (S32)USERSERVER_OTHER;
-			server = combo_val.asString();
+			user_picked = combo->isDirty();
 		}
 	}
+
+	return user_picked;
 }
 
 // static
diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h
index d9d933400f5ca43d4c4681b180cede42eb4c7da4..2c3acfb00cefcab476fa7a04558bca3bb5aba577 100644
--- a/indra/newview/llpanellogin.h
+++ b/indra/newview/llpanellogin.h
@@ -49,7 +49,7 @@ class LLPanelLogin
 	static void getFields(LLString &firstname, LLString &lastname,
 		LLString &password, BOOL &remember);
 
-	static void getServer(LLString &server, S32& domain_name);
+	static BOOL getServer(LLString &server, S32& domain_name);
 	static void getLocation(LLString &location);
 
 	static void close();
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index f699027835b4756d8ef4128b8b70681a647d1fd8..a267c50fde4194349360de3fc0790fa3ba9555e0 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -266,6 +266,10 @@ BOOL	LLPanelObject::postBuild()
 		}
 	}
 
+	mLabelSculptType = gUICtrlFactory->getTextBoxByName(this, "label sculpt type");
+	mCtrlSculptType = gUICtrlFactory->getComboBoxByName(this, "sculpt type control");
+	childSetCommitCallback("sculpt type control", onCommitSculptType, this);
+
 	
 	// Start with everyone disabled
 	clearCtrls();
@@ -1015,7 +1019,10 @@ void LLPanelObject::getState( )
 	mLabelRevolutions->setVisible( revolutions_visible );
 	mSpinRevolutions ->setVisible( revolutions_visible );
 
-	mCtrlSculptTexture->setVisible( sculpt_texture_visible );
+	bool sculpt_type_visible = FALSE; // currently not visible - for LSL setting only
+	mCtrlSculptTexture->setVisible(sculpt_texture_visible);
+	mLabelSculptType->setVisible(sculpt_texture_visible && sculpt_type_visible);
+	mCtrlSculptType->setVisible(sculpt_texture_visible && sculpt_type_visible);
 
 
 	// sculpt texture
@@ -1025,21 +1032,39 @@ void LLPanelObject::getState( )
         LLUUID id;
 		LLSculptParams *sculpt_params = (LLSculptParams *)objectp->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
 
-		LLTextureCtrl*  mTextureCtrl = LLViewerUICtrlFactory::getTexturePickerByName(this,"sculpt texture control");
-		if((mTextureCtrl) && (sculpt_params))
+		
+		if (sculpt_params) // if we have a legal sculpt param block for this object:
 		{
-			mTextureCtrl->setTentative(FALSE);
-			mTextureCtrl->setEnabled(editable);
-			if (editable)
-				mTextureCtrl->setImageAssetID(sculpt_params->getSculptTexture());
-			else
-				mTextureCtrl->setImageAssetID(LLUUID::null);
-				
-
 			if (mObject != objectp)  // we've just selected a new object, so save for undo
+			{
 				mSculptTextureRevert = sculpt_params->getSculptTexture();
-		}
+				mSculptTypeRevert    = sculpt_params->getSculptType();
+			}
+		
+			LLTextureCtrl*  mTextureCtrl = LLViewerUICtrlFactory::getTexturePickerByName(this,"sculpt texture control");
+			if(mTextureCtrl)
+			{
+				mTextureCtrl->setTentative(FALSE);
+				mTextureCtrl->setEnabled(editable);
+				if (editable)
+					mTextureCtrl->setImageAssetID(sculpt_params->getSculptTexture());
+				else
+					mTextureCtrl->setImageAssetID(LLUUID::null);
+			}
+
+			if (mCtrlSculptType)
+			{
+				mCtrlSculptType->setCurrentByIndex(sculpt_params->getSculptType());
+				mCtrlSculptType->setEnabled(editable);
+			}
 
+			if (mLabelSculptType)
+			{
+				mLabelSculptType->setEnabled(TRUE);
+			}
+
+			
+		}
 	}
 
 	
@@ -1174,7 +1199,7 @@ void LLPanelObject::onCommitParametric( LLUICtrl* ctrl, void* userdata )
 		self->mObject->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, TRUE);
 		LLSculptParams *sculpt_params = (LLSculptParams *)self->mObject->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
 		if (sculpt_params)
-			volume_params.setSculptID(sculpt_params->getSculptTexture(), 0);
+			volume_params.setSculptID(sculpt_params->getSculptTexture(), sculpt_params->getSculptType());
 	}
 	else
 	{
@@ -1628,13 +1653,16 @@ void LLPanelObject::sendPosition()
 
 void LLPanelObject::sendSculpt()
 {
-	LLTextureCtrl* mTextureCtrl = gUICtrlFactory->getTexturePickerByName(this,"sculpt texture control");
-	if(!mTextureCtrl)
+	if (mObject.isNull())
 		return;
-
+	
 	LLSculptParams sculpt_params;
-	sculpt_params.setSculptTexture(mTextureCtrl->getImageAssetID());
-	sculpt_params.setSculptType(LL_SCULPT_TYPE_SPHERE);
+
+	if (mCtrlSculptTexture)
+		sculpt_params.setSculptTexture(mCtrlSculptTexture->getImageAssetID());
+
+	if (mCtrlSculptType)
+		sculpt_params.setSculptType(mCtrlSculptType->getCurrentIndex());
 	
 	mObject->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt_params, TRUE);
 }
@@ -1843,7 +1871,9 @@ void LLPanelObject::onSelectSculpt(LLUICtrl* ctrl, void* userdata)
     LLTextureCtrl* mTextureCtrl = gUICtrlFactory->getTexturePickerByName(self, "sculpt texture control");
 
 	if (mTextureCtrl)
+	{
 		self->mSculptTextureRevert = mTextureCtrl->getImageAssetID();
+	}
 	
 	self->sendSculpt();
 }
@@ -1870,7 +1900,6 @@ BOOL LLPanelObject::onDropSculpt(LLUICtrl*, LLInventoryItem* item, void* userdat
 		mTextureCtrl->setImageAssetID(asset);
 		self->mSculptTextureRevert = asset;
 	}
-	
 
 	return TRUE;
 }
@@ -1889,3 +1918,11 @@ void LLPanelObject::onCancelSculpt(LLUICtrl* ctrl, void* userdata)
 	
 	self->sendSculpt();
 }
+
+// static
+void LLPanelObject::onCommitSculptType(LLUICtrl *ctrl, void* userdata)
+{
+	LLPanelObject* self = (LLPanelObject*) userdata;
+
+	self->sendSculpt();
+}
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 8c1bea0108071b844bdda681e9bbc786fd9f9056..0aab79515b91b3620ca6f7cb0f0dc6c4a9c3123a 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -57,7 +57,9 @@ class LLPanelObject : public LLPanel
 	static void     onCommitSculpt(        LLUICtrl* ctrl, void* userdata);
 	static void     onCancelSculpt(        LLUICtrl* ctrl, void* userdata);
 	static void     onSelectSculpt(        LLUICtrl* ctrl, void* userdata);
-	static BOOL     onDropSculpt(LLUICtrl* ctrl, LLInventoryItem* item, void* ud);
+	static BOOL     onDropSculpt(          LLUICtrl* ctrl, LLInventoryItem* item, void* ud);
+	static void     onCommitSculptType(    LLUICtrl *ctrl, void* userdata);
+		
 	
 protected:
 	void			getState();
@@ -143,6 +145,8 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckCastShadows;
 
 	LLTextureCtrl   *mCtrlSculptTexture;
+	LLTextBox       *mLabelSculptType;
+	LLComboBox      *mCtrlSculptType;
 	
 	LLVector3		mCurEulerDegrees;		// to avoid sending rotation when not changed
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
@@ -152,6 +156,7 @@ class LLPanelObject : public LLPanel
 	S32				mSelectedType;			// So we know what selected type we last were
 
 	LLUUID          mSculptTextureRevert;   // so we can revert the sculpt texture on cancel
+	U8              mSculptTypeRevert;      // so we can revert the sculpt type on cancel
 	
 	LLPointer<LLViewerObject> mObject;
 	LLPointer<LLViewerObject> mRootObject;
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index c1885ad898bc305120310c8a9654a6e94700d412..e52710ca75d08c9a34678f02197f0bdc03ec2a3a 100644
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -280,12 +280,18 @@ bool LLPreview::save( const LLUUID& item_uuid, LLPointer<LLInventoryItem>* itemp
 }
 
 // static
-void LLPreview::hide(const LLUUID& item_uuid)
+void LLPreview::hide(const LLUUID& item_uuid, BOOL no_saving /* = FALSE */ )
 {
 	preview_map_t::iterator found_it = LLPreview::sInstances.find(item_uuid);
 	if(found_it != LLPreview::sInstances.end())
 	{
 		LLPreview* instance = found_it->second;
+
+		if ( no_saving )
+		{
+			instance->mForceClose = TRUE;
+		}
+
 		instance->close();
 	}
 }
diff --git a/indra/newview/llpreview.h b/indra/newview/llpreview.h
index 589e1fde21bdfdc992022cb8077ef13cdcdaa185..449093ee91c5e9668ee182865211dd351f4f0e18 100644
--- a/indra/newview/llpreview.h
+++ b/indra/newview/llpreview.h
@@ -61,7 +61,7 @@ class LLPreview : public LLFloater
 
 	static LLPreview* find(const LLUUID& item_uuid);
 	static LLPreview*	show(const LLUUID& item_uuid, BOOL take_focus = TRUE );
-	static void			hide(const LLUUID& item_uuid);
+	static void			hide(const LLUUID& item_uuid, BOOL no_saving = FALSE );
 	static void			rename(const LLUUID& item_uuid, const std::string& new_name);
 	static bool			save(const LLUUID& item_uuid, LLPointer<LLInventoryItem>* itemptr);
 
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index c556e3f4506927c24926023c8eb2bb63c8a961d6..0e0ade17a2a668da8df2aba3f8ed18f33a7525c2 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -246,7 +246,8 @@ BOOL LLPreviewGesture::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 // virtual
 BOOL LLPreviewGesture::canClose()
 {
-	if(!mDirty)
+
+	if(!mDirty || mForceClose)
 	{
 		return TRUE;
 	}
@@ -864,7 +865,7 @@ void LLPreviewGesture::loadAsset()
 void LLPreviewGesture::onLoadComplete(LLVFS *vfs,
 									   const LLUUID& asset_uuid,
 									   LLAssetType::EType type,
-									   void* user_data, S32 status)
+									   void* user_data, S32 status, LLExtStat ext_status)
 {
 	LLUUID* item_idp = (LLUUID*)user_data;
 	LLPreview* preview = LLPreview::find(*item_idp);
@@ -1160,7 +1161,7 @@ void LLPreviewGesture::saveIfNeeded()
 // TODO: This is very similar to LLPreviewNotecard::onSaveComplete.
 // Could merge code.
 // static
-void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLSaveInfo* info = (LLSaveInfo*)user_data;
 	if (info && (status == 0))
diff --git a/indra/newview/llpreviewgesture.h b/indra/newview/llpreviewgesture.h
index 77d7477d917105b66c0d8d32ce87083845534af5..2a122c202c816fbfadc5aa0db14d57638a3fda18 100644
--- a/indra/newview/llpreviewgesture.h
+++ b/indra/newview/llpreviewgesture.h
@@ -67,7 +67,7 @@ class LLPreviewGesture : public LLPreview
 	static void onLoadComplete(LLVFS *vfs,
 							   const LLUUID& asset_uuid,
 							   LLAssetType::EType type,
-							   void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
 
 	void loadUIFromGesture(LLMultiGesture* gesture);
 
@@ -75,7 +75,7 @@ class LLPreviewGesture : public LLPreview
 
 	static void onSaveComplete(const LLUUID& asset_uuid,
 							   void* user_data,
-							   S32 status);
+							   S32 status, LLExtStat ext_status);
 
 	static void handleSaveChangesDialog(S32 option, void* userdata);
 
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index 8650bcf459187af8b68df90af40e452cf111afa2..c7d1addf4211a8056fe3dd77de4057f57176176e 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -329,7 +329,7 @@ void LLPreviewNotecard::loadAsset()
 void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 									   const LLUUID& asset_uuid,
 									   LLAssetType::EType type,
-									   void* user_data, S32 status)
+									   void* user_data, S32 status, LLExtStat ext_status)
 {
 	llinfos << "LLPreviewNotecard::onLoadComplete()" << llendl;
 	LLUUID* item_id = (LLUUID*)user_data;
@@ -517,7 +517,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 }
 
 // static
-void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLSaveNotecardInfo* info = (LLSaveNotecardInfo*)user_data;
 	if(info && (0 == status))
diff --git a/indra/newview/llpreviewnotecard.h b/indra/newview/llpreviewnotecard.h
index 88ce8b36ce49500aedfb233adcd641b63eb5f5df..b92dd9355016ddd047afe6a79771f61fc37e7788 100644
--- a/indra/newview/llpreviewnotecard.h
+++ b/indra/newview/llpreviewnotecard.h
@@ -69,13 +69,13 @@ class LLPreviewNotecard : public LLPreview
 	static void onLoadComplete(LLVFS *vfs,
 							   const LLUUID& asset_uuid,
 							   LLAssetType::EType type,
-							   void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
 
 	static void onClickSave(void* data);
 
 	static void onSaveComplete(const LLUUID& asset_uuid,
 							   void* user_data,
-							   S32 status);
+							   S32 status, LLExtStat ext_status);
 
 	static void handleSaveChangesDialog(S32 option, void* userdata);
 
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 0c112267109be20a5af5ee96e6a39b3c528cf5a2..57a6069aff41d318feabcf3a504f4f5be6c0ba0f 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -271,6 +271,7 @@ LLScriptEdCore::LLScriptEdCore(
 	const LLViewHandle& floater_handle,
 	void (*load_callback)(void*),
 	void (*save_callback)(void*, BOOL),
+	void (*search_replace_callback) (void* userdata),
 	void* userdata,
 	S32 bottom_pad)
 	:
@@ -280,6 +281,7 @@ LLScriptEdCore::LLScriptEdCore(
 	mEditor( NULL ),
 	mLoadCallback( load_callback ),
 	mSaveCallback( save_callback ),
+	mSearchReplaceCallback( search_replace_callback ),
 	mUserdata( userdata ),
 	mForceClose( FALSE ),
 	mLastHelpToken(NULL),
@@ -1008,7 +1010,9 @@ BOOL LLScriptEdCore::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
 {
 	if(getVisible() && getEnabled())
 	{
-		if(('S' == key) && (MASK_CONTROL == (mask & MASK_CONTROL)))
+		bool just_control = MASK_CONTROL == (mask & MASK_MODIFIERS);
+
+		if(('S' == key) && just_control)
 		{
 			if(mSaveCallback)
 			{
@@ -1018,6 +1022,16 @@ BOOL LLScriptEdCore::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
 	
 			return TRUE;
 		}
+
+		if(('F' == key) && just_control)
+		{
+			if(mSearchReplaceCallback)
+			{
+				mSearchReplaceCallback(mUserdata);
+			}
+	
+			return TRUE;
+		}
 	}
 	return FALSE;
 }
@@ -1051,6 +1065,7 @@ void* LLPreviewLSL::createScriptEdPanel(void* userdata)
 								   self->mViewHandle,
 								   LLPreviewLSL::onLoad,
 								   LLPreviewLSL::onSave,
+								   LLPreviewLSL::onSearchReplace,
 								   self,
 								   0);
 
@@ -1200,6 +1215,13 @@ void LLPreviewLSL::open()		/*Flawfinder: ignore*/
 	LLFloater::open();		/*Flawfinder: ignore*/
 }
 
+void LLPreviewLSL::onSearchReplace(void* userdata)
+{
+	LLPreviewLSL* self = (LLPreviewLSL*)userdata;
+	LLScriptEdCore* sec = self->mScriptEd; 
+	LLFloaterScriptSearch::show(sec);
+}
+
 // static
 void LLPreviewLSL::onLoad(void* userdata)
 {
@@ -1366,7 +1388,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename,
 
 
 // static
-void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLScriptSaveInfo* info = reinterpret_cast<LLScriptSaveInfo*>(user_data);
 	if(0 == status)
@@ -1415,7 +1437,7 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32
 }
 
 // static
-void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLUUID* instance_uuid = (LLUUID*)user_data;
 	LLPreviewLSL* self = NULL;
@@ -1454,7 +1476,7 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d
 
 // static
 void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type,
-								   void* user_data, S32 status)
+								   void* user_data, S32 status, LLExtStat ext_status)
 {
 	lldebugs << "LLPreviewLSL::onLoadComplete: got uuid " << asset_uuid
 		 << llendl;
@@ -1559,6 +1581,7 @@ void* LLLiveLSLEditor::createScriptEdPanel(void* userdata)
 								   self->mViewHandle,
 								   &LLLiveLSLEditor::onLoad,
 								   &LLLiveLSLEditor::onSave,
+								   &LLLiveLSLEditor::onSearchReplace,
 								   self,
 								   0);
 
@@ -1773,7 +1796,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 // static
 void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
 									 LLAssetType::EType type,
-									 void* user_data, S32 status)
+									 void* user_data, S32 status, LLExtStat ext_status)
 {
 	lldebugs << "LLLiveLSLEditor::onLoadComplete: got uuid " << asset_id
 		 << llendl;
@@ -1956,6 +1979,15 @@ void LLLiveLSLEditor::draw()
 	}
 }
 
+
+void LLLiveLSLEditor::onSearchReplace(void* userdata)
+{
+	LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata;
+
+	LLScriptEdCore* sec = self->mScriptEd; 
+	LLFloaterScriptSearch::show(sec);
+}
+
 struct LLLiveLSLSaveData
 {
 	LLLiveLSLSaveData(const LLUUID& id, const LLViewerInventoryItem* item, BOOL active);
@@ -2169,7 +2201,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
 	runningCheckbox->setEnabled(TRUE);
 }
 
-void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLLiveLSLSaveData* data = (LLLiveLSLSaveData*)user_data;
 
@@ -2199,7 +2231,7 @@ void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_da
 }
 
 
-void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status) // StoreAssetData callback (fixed)
+void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLLiveLSLSaveData* data = (LLLiveLSLSaveData*)user_data;
 	if(!data)
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 54b27316f7879cd1822d1af066669c15a3af2247..444bb629e6bb7e9191f090684087d4cf9972ddb9 100644
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -47,6 +47,7 @@ class LLScriptEdCore : public LLPanel
 		const LLViewHandle& floater_handle,
 		void (*load_callback)(void* userdata),
 		void (*save_callback)(void* userdata, BOOL close_after_save),
+		void (*search_replace_callback)(void* userdata),
 		void* userdata,
 		S32 bottom_pad = 0);	// pad below bottom row of buttons
 	~LLScriptEdCore();
@@ -110,6 +111,7 @@ class LLScriptEdCore : public LLPanel
 	LLTextEditor*	mEditor;
 	void			(*mLoadCallback)(void* userdata);
 	void			(*mSaveCallback)(void* userdata, BOOL close_after_save);
+	void			(*mSearchReplaceCallback) (void* userdata);
 	void*			mUserdata;
 	LLComboBox		*mFunctions;
 	BOOL			mForceClose;
@@ -149,14 +151,15 @@ class LLPreviewLSL : public LLPreview
 							const LLUUID& item_id,
 							const LLTransactionID& tid);
 
+	static void onSearchReplace(void* userdata);
 	static void onLoad(void* userdata);
 	static void onSave(void* userdata, BOOL close_after_save);
 	
 	static void onLoadComplete(LLVFS *vfs, const LLUUID& uuid,
 							   LLAssetType::EType type,
-							   void* user_data, S32 status);
-	static void onSaveComplete(const LLUUID& uuid, void* user_data, S32 status);
-	static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
+	static void onSaveComplete(const LLUUID& uuid, void* user_data, S32 status, LLExtStat ext_status);
+	static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
 	static LLPreviewLSL* getInstance(const LLUUID& uuid);
 
 	static void* createScriptEdPanel(void* userdata);
@@ -209,14 +212,15 @@ class LLLiveLSLEditor : public LLPreview
 						   const LLTransactionID& tid,
 						   BOOL is_running);
 
+	static void onSearchReplace(void* userdata);
 	static void onLoad(void* userdata);
 	static void onSave(void* userdata, BOOL close_after_save);
 
 	static void onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid,
 							   LLAssetType::EType type,
-							   void* user_data, S32 status);
-	static void onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status);
-	static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status);
+							   void* user_data, S32 status, LLExtStat ext_status);
+	static void onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
+	static void onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status);
 	static void onRunningCheckboxClicked(LLUICtrl*, void* userdata);
 	static void onReset(void* userdata);
 
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 039124c6fd47d0ea03186c3c7377441695130917..42eed7316b0d79ed0710d3412c86203a0bd7c186 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -51,7 +51,7 @@ void sg_assert(BOOL expr)
 #endif
 }
 
-#if !LL_RELEASE_FOR_DOWNLOAD
+#if LL_DEBUG
 void validate_drawable(LLDrawable* drawablep)
 {
 	F64 rad = drawablep->getBinRadius();
@@ -133,10 +133,6 @@ LLSpatialGroup::~LLSpatialGroup()
 
 void LLSpatialGroup::clearDrawMap()
 {
-	for (LLSpatialGroup::draw_map_t::iterator i = mDrawMap.begin(); i != mDrawMap.end(); ++i)
-	{
-		std::for_each(i->second.begin(), i->second.end(), DeletePointer());
-	}
 	mDrawMap.clear();
 }
 
@@ -2303,7 +2299,7 @@ void pushVerts(LLSpatialGroup* group, U32 mask)
 
 	for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
 	{
-		for (std::vector<LLDrawInfo*>::iterator j = i->second.begin(); j != i->second.end(); ++j)
+		for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j) 
 		{
 			params = *j;
 			pushVerts(params, mask);
@@ -2331,7 +2327,7 @@ void pushVertsColorCoded(LLSpatialGroup* group, U32 mask)
 
 	for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
 	{
-		for (std::vector<LLDrawInfo*>::iterator j = i->second.begin(); j != i->second.end(); ++j)
+		for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j) 
 		{
 			params = *j;
 			glColor4f(colors[col].mV[0], colors[col].mV[1], colors[col].mV[2], 0.5f);
@@ -2682,8 +2678,8 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 		
 		for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
 		{
-			std::vector<LLDrawInfo*>& draw_vec = i->second;
-			for (std::vector<LLDrawInfo*>::iterator j = draw_vec.begin(); j != draw_vec.end(); ++j)
+			LLSpatialGroup::drawmap_elem_t& draw_vec = i->second;	
+			for (LLSpatialGroup::drawmap_elem_t::iterator j = draw_vec.begin(); j != draw_vec.end(); ++j)	
 			{
 				LLDrawInfo* draw_info = *j;
 				if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_ANIM))
@@ -2869,6 +2865,11 @@ LLDrawInfo::LLDrawInfo(U32 start, U32 end, U32 count, U32 offset,
 {
 }
 
+LLDrawInfo::~LLDrawInfo()	
+{
+
+}
+
 LLVertexBuffer* LLGeometryManager::createVertexBuffer(U32 type_mask, U32 usage)
 {
 	return new LLVertexBuffer(type_mask, usage);
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index a2f24005df177461aa23790051eda3785dd8344b..9561dca0bbf8a585f709e64d15c523fb3bf42951 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -26,13 +26,17 @@
 class LLSpatialPartition;
 class LLSpatialBridge;
 
-class LLDrawInfo
+class LLDrawInfo : public LLRefCount 
 {
+protected:
+	~LLDrawInfo();	
+	
 public:
 	LLDrawInfo(U32 start, U32 end, U32 count, U32 offset, 
 				LLViewerImage* image, LLVertexBuffer* buffer, 
 				BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0);
 	
+
 	LLPointer<LLVertexBuffer> mVertexBuffer;
 	LLPointer<LLViewerImage> mTexture;
 	LLPointer<LLCubeMap> mReflectionMap;
@@ -58,18 +62,21 @@ class LLDrawInfo
 
 	struct CompareTexturePtr
 	{
-		bool operator()(const LLDrawInfo* const& lhs, const LLDrawInfo* const& rhs)
+		bool operator()(const LLPointer<LLDrawInfo>& lhs, const LLPointer<LLDrawInfo>& rhs)	
 		{
-		
-			return lhs == NULL || rhs == NULL || lhs->mTexture > rhs->mTexture;
+			// sort by pointer, sort NULL down to the end
+			return lhs.get() != rhs.get() 
+						&& (lhs.isNull() || (rhs.notNull() && lhs->mTexture.get() > rhs->mTexture.get()));
 		}
 	};
 
 	struct CompareBump
 	{
-		bool operator()(const LLDrawInfo* const& lhs, const LLDrawInfo* const& rhs)
+		bool operator()(const LLPointer<LLDrawInfo>& lhs, const LLPointer<LLDrawInfo>& rhs) 
 		{
-			return lhs == NULL || rhs == NULL || lhs->mBump > rhs->mBump;
+			// sort by mBump value, sort NULL down to the end
+			return lhs.get() != rhs.get() 
+						&& (lhs.isNull() || (rhs.notNull() && lhs->mBump > rhs->mBump));
 		}
 	};
 };
@@ -82,7 +89,8 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 	typedef std::vector<LLPointer<LLSpatialGroup> > sg_vector_t;
 	typedef std::set<LLPointer<LLSpatialGroup> > sg_set_t;
 	typedef std::vector<LLPointer<LLSpatialBridge> > bridge_list_t;
-	typedef std::map<U32, std::vector<LLDrawInfo*> > draw_map_t;
+	typedef std::vector<LLPointer<LLDrawInfo> > drawmap_elem_t; 
+	typedef std::map<U32, drawmap_elem_t > draw_map_t;	
 	typedef std::map<LLPointer<LLViewerImage>, LLPointer<LLVertexBuffer> > buffer_map_t;
 
 	typedef LLOctreeListener<LLDrawable>	BaseType;
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 74d8aa8e9ac78ad1489ae787f0765d2dd15fbceb..8aa442818e225192df7a2745bb081b652e1b8f5e 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -196,6 +196,9 @@ LLString gInitialOutfitGender;	// "male" or "female"
 
 static bool gUseCircuitCallbackCalled = false;
 
+S32 LLStartUp::gStartupState = STATE_FIRST;
+
+
 //
 // local function declaration
 //
@@ -336,7 +339,7 @@ BOOL idle_startup()
 		gImageList.updateImages(0.01f);
 	}
 
-	if (STATE_FIRST == gStartupState)
+	if ( STATE_FIRST == LLStartUp::getStartupState() )
 	{
 		gViewerWindow->showCursor();
 		gViewerWindow->getWindow()->setCursor(UI_CURSOR_WAIT);
@@ -585,67 +588,49 @@ BOOL idle_startup()
 			llwarns << "Unreliable timers detected (may be bad PCI chipset)!!" << llendl;
 		}
 
-		// Get ready to show the login dialog
-		if (!gConnectToSomething)
+		//
+		// Log on to system
+		//
+		if( !gCmdLineFirstName.empty() 
+			&& !gCmdLineLastName.empty() 
+			&& !gCmdLinePassword.empty())
 		{
-			// Don't use a session token, and generate a random user id
-			gAgentID.generate();
-			gAgentSessionID = LLUUID::null;
+			firstname = gCmdLineFirstName;
+			lastname = gCmdLineLastName;
 
-			gStartupState = STATE_WORLD_INIT;
-			return do_normal_idle;
+			LLMD5 pass((unsigned char*)gCmdLinePassword.c_str());
+			char md5pass[33];		/* Flawfinder: ignore */
+			pass.hex_digest(md5pass);
+			password = md5pass;
+
+			remember_password = gSavedSettings.getBOOL("RememberPassword");
+			show_connect_box = FALSE;
 		}
-		else if (!gRunLocal)
+		else if (gAutoLogin || gSavedSettings.getBOOL("AutoLogin"))
 		{
-			//
-			// Log on to userserver
-			//
-			if( !gCmdLineFirstName.empty() 
-				&& !gCmdLineLastName.empty() 
-				&& !gCmdLinePassword.empty())
-			{
-				firstname = gCmdLineFirstName;
-				lastname = gCmdLineLastName;
-
-				LLMD5 pass((unsigned char*)gCmdLinePassword.c_str());
-				char md5pass[33];		/* Flawfinder: ignore */
-				pass.hex_digest(md5pass);
-				password = md5pass;
-
-				remember_password = gSavedSettings.getBOOL("RememberPassword");
-				show_connect_box = FALSE;
-			}
-			else if (gAutoLogin || gSavedSettings.getBOOL("AutoLogin"))
-			{
-				firstname = gSavedSettings.getString("FirstName");
-				lastname = gSavedSettings.getString("LastName");
-				password = load_password_from_disk();
-				remember_password = TRUE;
-				show_connect_box = FALSE;
-			}
-			else
-			{
-				// if not automatically logging in, display login dialog
-				// until a valid userserver is selected
-				firstname = gSavedSettings.getString("FirstName");
-				lastname = gSavedSettings.getString("LastName");
-				password = load_password_from_disk();
-				remember_password = gSavedSettings.getBOOL("RememberPassword");
-				show_connect_box = TRUE;
-			}
-
-			// Go to the next startup state
-			gStartupState++;
-			return do_normal_idle;
+			firstname = gSavedSettings.getString("FirstName");
+			lastname = gSavedSettings.getString("LastName");
+			password = load_password_from_disk();
+			remember_password = TRUE;
+			show_connect_box = FALSE;
 		}
 		else
 		{
-			gStartupState++;
-			return do_normal_idle;
+			// if not automatically logging in, display login dialog
+			// until a valid userserver is selected
+			firstname = gSavedSettings.getString("FirstName");
+			lastname = gSavedSettings.getString("LastName");
+			password = load_password_from_disk();
+			remember_password = gSavedSettings.getBOOL("RememberPassword");
+			show_connect_box = TRUE;
 		}
+
+		// Go to the next startup state
+		LLStartUp::setStartupState( STATE_LOGIN_SHOW );
+		return do_normal_idle;
 	}
 
-	if (STATE_LOGIN_SHOW == gStartupState)
+	if (STATE_LOGIN_SHOW == LLStartUp::getStartupState())
 	{
 		llinfos << "Initializing Window" << llendl;
 		
@@ -655,45 +640,37 @@ BOOL idle_startup()
 
 		timeout_count = 0;
 
-		if (gConnectToSomething && !gRunLocal)
+		if (show_connect_box)
 		{
-			if (show_connect_box)
+			if (gNoRender)
 			{
-				if (gNoRender)
-				{
-					llerrs << "Need to autologin or use command line with norender!" << llendl;
-				}
-				// Make sure the process dialog doesn't hide things
-				gViewerWindow->setShowProgress(FALSE);
+				llerrs << "Need to autologin or use command line with norender!" << llendl;
+			}
+			// Make sure the process dialog doesn't hide things
+			gViewerWindow->setShowProgress(FALSE);
 
-				// Show the login dialog
-				login_show();
+			// Show the login dialog
+			login_show();
 
-				// connect dialog is already shown, so fill in the names
-				LLPanelLogin::setFields( firstname, lastname, password, remember_password );
-				LLPanelLogin::giveFocus();
+			// connect dialog is already shown, so fill in the names
+			LLPanelLogin::setFields( firstname, lastname, password, remember_password );
+			LLPanelLogin::giveFocus();
 
-				gSavedSettings.setBOOL("FirstRunThisInstall", FALSE);
+			gSavedSettings.setBOOL("FirstRunThisInstall", FALSE);
 
-				gStartupState++;
-			}
-			else
-			{
-				// skip directly to message template verification
-				gStartupState = STATE_LOGIN_CLEANUP;
-			}
+			LLStartUp::setStartupState( STATE_LOGIN_WAIT );		// Wait for user input
 		}
 		else
 		{
-			gMessageSystem->setCircuitProtection(FALSE);
-			gStartupState = STATE_LOGIN_CLEANUP;
+			// skip directly to message template verification
+			LLStartUp::setStartupState( STATE_LOGIN_CLEANUP );
 		}
 
 		timeout.reset();
 		return do_normal_idle;
 	}
 
-	if (STATE_LOGIN_WAIT == gStartupState)
+	if (STATE_LOGIN_WAIT == LLStartUp::getStartupState())
 	{
 		// Don't do anything.  Wait for the login view to call the login_callback,
 		// which will push us to the next state.
@@ -703,7 +680,7 @@ BOOL idle_startup()
 		return do_normal_idle;
 	}
 
-	if (STATE_LOGIN_CLEANUP == gStartupState)
+	if (STATE_LOGIN_CLEANUP == LLStartUp::getStartupState())
 	{
 		if (show_connect_box)
 		{
@@ -771,7 +748,7 @@ BOOL idle_startup()
 		{
 			LLString server_label;
 			S32 domain_name_index;
-			LLPanelLogin::getServer( server_label, domain_name_index );
+			BOOL user_picked_server = LLPanelLogin::getServer( server_label, domain_name_index );
 			gUserServerChoice = (EUserServerDomain) domain_name_index;
 			gSavedSettings.setS32("ServerChoice", gUserServerChoice);
 			if (gUserServerChoice == USERSERVER_OTHER)
@@ -779,14 +756,11 @@ BOOL idle_startup()
 				snprintf(gUserServerName, MAX_STRING, "%s", server_label.c_str());			/* Flawfinder: ignore */
 			}
 
-			// Dave S temp reversion of SL-49082 fix - this code breaks command line urls.  I'll fix this with
-			// the control isDirty() functionality tomorrow.
-
-			//if ( userPickedServer )
-			//{	// User picked a grid from the popup, so clear the stored urls so they will be re-generated from gUserServerChoice
-			//	auth_uris.clear();
-			//	resetURIs();
-			//}
+			if ( user_picked_server )
+			{	// User picked a grid from the popup, so clear the stored urls and they will be re-generated from gUserServerChoice
+				auth_uris.clear();
+				resetURIs();
+			}
 
 			LLString location;
 			LLPanelLogin::getLocation( location );
@@ -849,18 +823,18 @@ BOOL idle_startup()
 		init_colors();
 
 		// skipping over STATE_UPDATE_CHECK because that just waits for input
-		gStartupState = STATE_LOGIN_AUTH_INIT;
+		LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT );
 
 		return do_normal_idle;
 	}
 
-	if (STATE_UPDATE_CHECK == gStartupState)
+	if (STATE_UPDATE_CHECK == LLStartUp::getStartupState())
 	{
 		// wait for user to give input via dialog box
 		return do_normal_idle;
 	}
 
-	if(STATE_LOGIN_AUTH_INIT == gStartupState)
+	if(STATE_LOGIN_AUTH_INIT == LLStartUp::getStartupState())
 	{
 //#define LL_MINIMIAL_REQUESTED_OPTIONS
 		lldebugs << "STATE_LOGIN_AUTH_INIT" << llendl;
@@ -907,10 +881,10 @@ BOOL idle_startup()
 		auth_desc = "Logging in.  ";
 		auth_desc += gSecondLife;
 		auth_desc += " may appear frozen.  Please wait.";
-		++gStartupState;
+		LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE );
 	}
 
-	if (STATE_LOGIN_AUTHENTICATE == gStartupState)
+	if (STATE_LOGIN_AUTHENTICATE == LLStartUp::getStartupState())
 	{
 		lldebugs << "STATE_LOGIN_AUTHENTICATE" << llendl;
 		set_startup_status(progress, auth_desc.c_str(), auth_message.c_str());
@@ -962,11 +936,11 @@ BOOL idle_startup()
 		// reset globals
 		gAcceptTOS = FALSE;
 		gAcceptCriticalMessage = FALSE;
-		++gStartupState;
+		LLStartUp::setStartupState( STATE_LOGIN_NO_DATA_YET );
 		return do_normal_idle;
 	}
 
-	if(STATE_LOGIN_NO_DATA_YET == gStartupState)
+	if(STATE_LOGIN_NO_DATA_YET == LLStartUp::getStartupState())
 	{
 		//lldebugs << "STATE_LOGIN_NO_DATA_YET" << llendl;
 		if (!gUserAuthp)
@@ -985,13 +959,13 @@ BOOL idle_startup()
 			//llinfos << "waiting..." << llendl;
 			return do_normal_idle;
 		}
-		++gStartupState;
+		LLStartUp::setStartupState( STATE_LOGIN_DOWNLOADING );
 		progress += 0.01f;
 		set_startup_status(progress, auth_desc.c_str(), auth_message.c_str());
 		return do_normal_idle;
 	}
 
-	if(STATE_LOGIN_DOWNLOADING == gStartupState)
+	if(STATE_LOGIN_DOWNLOADING == LLStartUp::getStartupState())
 	{
 		lldebugs << "STATE_LOGIN_DOWNLOADING" << llendl;
 		if (!gUserAuthp)
@@ -1010,13 +984,13 @@ BOOL idle_startup()
 			//llinfos << "downloading..." << llendl;
 			return do_normal_idle;
 		}
-		++gStartupState;
+		LLStartUp::setStartupState( STATE_LOGIN_PROCESS_RESPONSE );
 		progress += 0.01f;
 		set_startup_status(progress, "Processing Response...", auth_message.c_str());
 		return do_normal_idle;
 	}
 
-	if(STATE_LOGIN_PROCESS_RESPONSE == gStartupState)
+	if(STATE_LOGIN_PROCESS_RESPONSE == LLStartUp::getStartupState())
 	{
 		lldebugs << "STATE_LOGIN_PROCESS_RESPONSE" << llendl;
 		std::ostringstream emsg;
@@ -1055,7 +1029,7 @@ BOOL idle_startup()
 				}
 				// ignoring the duration & options array for now.
 				// Go back to authenticate.
-				gStartupState = STATE_LOGIN_AUTHENTICATE;
+				LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE );
 				return do_normal_idle;
 			}
 			else
@@ -1078,7 +1052,7 @@ BOOL idle_startup()
 					if (show_connect_box)
 					{
 						llinfos << "Need tos agreement" << llendl;
-						gStartupState = STATE_UPDATE_CHECK;
+						LLStartUp::setStartupState( STATE_UPDATE_CHECK );
 						LLFloaterTOS* tos_dialog = LLFloaterTOS::show(LLFloaterTOS::TOS_TOS,
 																	message_response);
 						tos_dialog->startModal();
@@ -1095,7 +1069,7 @@ BOOL idle_startup()
 					if (show_connect_box)
 					{
 						llinfos << "Need critical message" << llendl;
-						gStartupState = STATE_UPDATE_CHECK;
+						LLStartUp::setStartupState( STATE_UPDATE_CHECK );
 						LLFloaterTOS* tos_dialog = LLFloaterTOS::show(LLFloaterTOS::TOS_CRITICAL_MESSAGE,
 																	message_response);
 						tos_dialog->startModal();
@@ -1119,7 +1093,7 @@ BOOL idle_startup()
 					if (show_connect_box)
 					{
 						update_app(TRUE, auth_message);
-						gStartupState = STATE_UPDATE_CHECK;
+						LLStartUp::setStartupState( STATE_UPDATE_CHECK );
 						return FALSE;
 					}
 					else
@@ -1134,7 +1108,7 @@ BOOL idle_startup()
 					if (show_connect_box)
 					{
 						update_app(FALSE, auth_message);
-						gStartupState = STATE_UPDATE_CHECK;
+						LLStartUp::setStartupState( STATE_UPDATE_CHECK );
 						gSkipOptionalUpdate = TRUE;
 						return FALSE;
 					}
@@ -1157,7 +1131,7 @@ BOOL idle_startup()
 				s << "Previous login attempt failed. Logging in, attempt "
 				  << (auth_uri_num + 1) << ".  ";
 				auth_desc = s.str();
-				gStartupState = STATE_LOGIN_AUTHENTICATE;
+				LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE );
 				auth_uri_num++;
 				return do_normal_idle;
 			}
@@ -1387,7 +1361,7 @@ BOOL idle_startup()
 			   && first_sim.isOk()
 			   && gAgent.mInventoryRootID.notNull())
 			{
-				++gStartupState;
+				LLStartUp::setStartupState( STATE_WORLD_INIT );
 			}
 			else
 			{
@@ -1431,7 +1405,7 @@ BOOL idle_startup()
 	//---------------------------------------------------------------------
 	// World Init
 	//---------------------------------------------------------------------
-	if (STATE_WORLD_INIT == gStartupState)
+	if (STATE_WORLD_INIT == LLStartUp::getStartupState())
 	{
 		set_startup_status(0.40f, "Initializing World...", gAgent.mMOTD.c_str());
 		display_startup();
@@ -1474,38 +1448,26 @@ BOOL idle_startup()
 		// User might have overridden far clip
 		gWorldp->setLandFarClip( gAgent.mDrawDistance );
 
-		if (!gRunLocal)
-		{
-			// Before we create the first region, we need to set the agent's mOriginGlobal
-			// This is necessary because creating objects before this is set will result in a
-			// bad mPositionAgent cache.
+		// Before we create the first region, we need to set the agent's mOriginGlobal
+		// This is necessary because creating objects before this is set will result in a
+		// bad mPositionAgent cache.
 
-			gAgent.initOriginGlobal(from_region_handle(first_sim_handle));
+		gAgent.initOriginGlobal(from_region_handle(first_sim_handle));
 
-			gWorldp->addRegion(first_sim_handle, first_sim);
+		gWorldp->addRegion(first_sim_handle, first_sim);
 
-			LLViewerRegion *regionp = gWorldp->getRegionFromHandle(first_sim_handle);
-			llinfos << "Adding initial simulator " << regionp->getOriginGlobal() << llendl;
-			
-			gStartupState = STATE_SEED_GRANTED_WAIT;
-			regionp->setSeedCapability(first_sim_seed_cap);
-			
-			// Set agent's initial region to be the one we just created.
-			gAgent.setRegion(regionp);
+		LLViewerRegion *regionp = gWorldp->getRegionFromHandle(first_sim_handle);
+		llinfos << "Adding initial simulator " << regionp->getOriginGlobal() << llendl;
+		
+		LLStartUp::setStartupState( STATE_SEED_GRANTED_WAIT );
+		regionp->setSeedCapability(first_sim_seed_cap);
+		
+		// Set agent's initial region to be the one we just created.
+		gAgent.setRegion(regionp);
 
-			// Set agent's initial position, which will be read by LLVOAvatar when the avatar
-			// object is created.  I think this must be done after setting the region.  JC
-			gAgent.setPositionAgent(agent_start_position_region);
-		}
-		else
-		{
-			// With one simulator, assume region is at 0,0, hence has regionHandle 0
-			// VEFFECT: Login
-			gWorldp->addRegion(0, gAgentSimHost);
-			gAgent.setRegion(gWorldp->getRegionFromHandle(0));
-			
-			gStartupState = STATE_SEED_CAP_GRANTED;
-		}
+		// Set agent's initial position, which will be read by LLVOAvatar when the avatar
+		// object is created.  I think this must be done after setting the region.  JC
+		gAgent.setPositionAgent(agent_start_position_region);
 
 		display_startup();
 		return do_normal_idle;
@@ -1515,7 +1477,7 @@ BOOL idle_startup()
 	//---------------------------------------------------------------------
 	// Wait for Seed Cap Grant
 	//---------------------------------------------------------------------
-	if(STATE_SEED_GRANTED_WAIT == gStartupState)
+	if(STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
 	{
 		llinfos << "Waiting for seed grant ...." << llendl;
 		return do_normal_idle;
@@ -1526,7 +1488,7 @@ BOOL idle_startup()
 	// Seed Capability Granted
 	// no newMessage calls should happen before this point
 	//---------------------------------------------------------------------
-	if (STATE_SEED_CAP_GRANTED == gStartupState)
+	if (STATE_SEED_CAP_GRANTED == LLStartUp::getStartupState())
 	{
 		update_texture_fetch();
 
@@ -1659,42 +1621,35 @@ BOOL idle_startup()
 		// For all images pre-loaded into viewer cache, decode them.
 		// Need to do this AFTER we init the sky
 		gImageList.decodeAllImages(2.f);
-		gStartupState++;
+		LLStartUp::setStartupState( STATE_QUICKTIME_INIT );
 
 		// JC - Do this as late as possible to increase likelihood Purify
 		// will run.
-		if (!gRunLocal)
+		LLMessageSystem* msg = gMessageSystem;
+		if (!msg->mOurCircuitCode)
 		{
-			LLMessageSystem* msg = gMessageSystem;
-			if (!msg->mOurCircuitCode)
-			{
-				llwarns << "Attempting to connect to simulator with a zero circuit code!" << llendl;
-			}
-
-			gUseCircuitCallbackCalled = FALSE;
-
-			msg->enableCircuit(first_sim, TRUE);
-			// now, use the circuit info to tell simulator about us!
-			llinfos << "viewer: UserLoginLocationReply() Enabling " << first_sim << " with code " << msg->mOurCircuitCode << llendl;
-			msg->newMessageFast(_PREHASH_UseCircuitCode);
-			msg->nextBlockFast(_PREHASH_CircuitCode);
-			msg->addU32Fast(_PREHASH_Code, msg->mOurCircuitCode);
-			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			msg->addUUIDFast(_PREHASH_ID, gAgent.getID());
-			msg->sendReliable(
-				first_sim,
-				MAX_TIMEOUT_COUNT,
-				FALSE,
-				TIMEOUT_SECONDS,
-				use_circuit_callback,
-				NULL);
+			llwarns << "Attempting to connect to simulator with a zero circuit code!" << llendl;
 		}
 
+		gUseCircuitCallbackCalled = FALSE;
+
+		msg->enableCircuit(first_sim, TRUE);
+		// now, use the circuit info to tell simulator about us!
+		llinfos << "viewer: UserLoginLocationReply() Enabling " << first_sim << " with code " << msg->mOurCircuitCode << llendl;
+		msg->newMessageFast(_PREHASH_UseCircuitCode);
+		msg->nextBlockFast(_PREHASH_CircuitCode);
+		msg->addU32Fast(_PREHASH_Code, msg->mOurCircuitCode);
+		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+		msg->addUUIDFast(_PREHASH_ID, gAgent.getID());
+		msg->sendReliable(
+			first_sim,
+			MAX_TIMEOUT_COUNT,
+			FALSE,
+			TIMEOUT_SECONDS,
+			use_circuit_callback,
+			NULL);
+
 		timeout.reset();
-		if (!gConnectToSomething)
-		{
-			gStartupState = STATE_MISC;
-		}
 
 		return do_normal_idle;
 	}
@@ -1702,7 +1657,7 @@ BOOL idle_startup()
 	//---------------------------------------------------------------------
 	// LLMediaEngine Init
 	//---------------------------------------------------------------------
-	if (STATE_QUICKTIME_INIT == gStartupState)
+	if (STATE_QUICKTIME_INIT == LLStartUp::getStartupState())
 	{
 		if (gViewerWindow)
 		{
@@ -1737,20 +1692,20 @@ BOOL idle_startup()
 		}
 		#endif
 
-		gStartupState++;
+		LLStartUp::setStartupState( STATE_WORLD_WAIT );
 		return do_normal_idle;
 	}
 
 	//---------------------------------------------------------------------
 	// Agent Send
 	//---------------------------------------------------------------------
-	if(STATE_WORLD_WAIT == gStartupState)
+	if(STATE_WORLD_WAIT == LLStartUp::getStartupState())
 	{
 		//llinfos << "Waiting for simulator ack...." << llendl;
 		set_startup_status(0.49f, "Waiting for region handshake...", gAgent.mMOTD.c_str());
 		if(gGotUseCircuitCodeAck)
 		{
-			++gStartupState;
+			LLStartUp::setStartupState( STATE_AGENT_SEND );
 		}
 		LLMessageSystem* msg = gMessageSystem;
 		while (msg->checkAllMessages(gFrameCount, gServicePump))
@@ -1763,7 +1718,7 @@ BOOL idle_startup()
 	//---------------------------------------------------------------------
 	// Agent Send
 	//---------------------------------------------------------------------
-	if (STATE_AGENT_SEND == gStartupState)
+	if (STATE_AGENT_SEND == LLStartUp::getStartupState())
 	{
 		llinfos << "Connecting to region..." << llendl;
 		set_startup_status(0.50f, "Connecting to region...", gAgent.mMOTD.c_str());
@@ -1774,7 +1729,7 @@ BOOL idle_startup()
 			_PREHASH_AgentMovementComplete,
 			process_agent_movement_complete);
 		LLViewerRegion* regionp = gAgent.getRegion();
-		if(!gRunLocal && regionp)
+		if(regionp)
 		{
 			send_complete_agent_movement(regionp->getHost());
 			gAssetStorage->setUpstream(regionp->getHost());
@@ -1782,10 +1737,6 @@ BOOL idle_startup()
 			msg->newMessageFast(_PREHASH_EconomyDataRequest);
 			gAgent.sendReliableMessage();
 		}
-		else
-		{
-			gStartupState++;
-		}
 
 		// Create login effect
 		// But not on first login, because you can't see your avatar then
@@ -1797,7 +1748,7 @@ BOOL idle_startup()
 			gHUDManager->sendEffects();
 		}
 
-		gStartupState++;
+		LLStartUp::setStartupState( STATE_AGENT_WAIT );		// Go to STATE_AGENT_WAIT
 
 		timeout.reset();
 		return do_normal_idle;
@@ -1806,14 +1757,13 @@ BOOL idle_startup()
 	//---------------------------------------------------------------------
 	// Agent Wait
 	//---------------------------------------------------------------------
-	if (STATE_AGENT_WAIT == gStartupState)
+	if (STATE_AGENT_WAIT == LLStartUp::getStartupState())
 	{
 		LLMessageSystem* msg = gMessageSystem;
 		while (msg->checkAllMessages(gFrameCount, gServicePump))
 		{
 			if (gAgentMovementCompleted)
 			{
-				gStartupState++;
 				// Sometimes we have more than one message in the
 				// queue. break out of this loop and continue
 				// processing. If we don't, then this could skip one
@@ -1827,183 +1777,187 @@ BOOL idle_startup()
 			}
 		}
 		msg->processAcks();
+
+		if (gAgentMovementCompleted)
+		{
+			LLStartUp::setStartupState( STATE_INVENTORY_SEND );
+		}
+
 		return do_normal_idle;
 	}
 
 	//---------------------------------------------------------------------
 	// Inventory Send
 	//---------------------------------------------------------------------
-	if (STATE_INVENTORY_SEND == gStartupState)
+	if (STATE_INVENTORY_SEND == LLStartUp::getStartupState())
 	{
 		if (!gUserAuthp)
 		{
 			llerrs << "No userauth in STATE_INVENTORY_SEND!" << llendl;
 		}
 
-		if (gConnectToSomething && !gRunLocal)
+		// unpack thin inventory
+		LLUserAuth::options_t options;
+		options.clear();
+		//bool dump_buffer = false;
+		
+		if(gUserAuthp->getOptions("inventory-lib-root", options)
+			&& !options.empty())
 		{
-			// unpack thin inventory
-			LLUserAuth::options_t options;
-			options.clear();
-			//bool dump_buffer = false;
-			
-			if(gUserAuthp->getOptions("inventory-lib-root", options)
-			   && !options.empty())
+			// should only be one
+			LLUserAuth::response_t::iterator it;
+			it = options[0].find("folder_id");
+			if(it != options[0].end())
 			{
-				// should only be one
-				LLUserAuth::response_t::iterator it;
-				it = options[0].find("folder_id");
-				if(it != options[0].end())
-				{
-					gInventoryLibraryRoot.set((*it).second.c_str());
-				}
+				gInventoryLibraryRoot.set((*it).second.c_str());
 			}
- 			options.clear();
-			if(gUserAuthp->getOptions("inventory-lib-owner", options)
-			   && !options.empty())
+		}
+ 		options.clear();
+		if(gUserAuthp->getOptions("inventory-lib-owner", options)
+			&& !options.empty())
+		{
+			// should only be one
+			LLUserAuth::response_t::iterator it;
+			it = options[0].find("agent_id");
+			if(it != options[0].end())
 			{
-				// should only be one
-				LLUserAuth::response_t::iterator it;
-				it = options[0].find("agent_id");
-				if(it != options[0].end())
-				{
-					gInventoryLibraryOwner.set((*it).second.c_str());
-				}
+				gInventoryLibraryOwner.set((*it).second.c_str());
 			}
- 			options.clear();
- 			if(gUserAuthp->getOptions("inventory-skel-lib", options)
-			   && gInventoryLibraryOwner.notNull())
+		}
+ 		options.clear();
+ 		if(gUserAuthp->getOptions("inventory-skel-lib", options)
+			&& gInventoryLibraryOwner.notNull())
+ 		{
+ 			if(!gInventory.loadSkeleton(options, gInventoryLibraryOwner))
  			{
- 				if(!gInventory.loadSkeleton(options, gInventoryLibraryOwner))
- 				{
- 					llwarns << "Problem loading inventory-skel-lib" << llendl;
- 				}
+ 				llwarns << "Problem loading inventory-skel-lib" << llendl;
  			}
- 			options.clear();
- 			if(gUserAuthp->getOptions("inventory-skeleton", options))
+ 		}
+ 		options.clear();
+ 		if(gUserAuthp->getOptions("inventory-skeleton", options))
+ 		{
+ 			if(!gInventory.loadSkeleton(options, gAgent.getID()))
  			{
- 				if(!gInventory.loadSkeleton(options, gAgent.getID()))
- 				{
- 					llwarns << "Problem loading inventory-skel-targets"
-							<< llendl;
- 				}
+ 				llwarns << "Problem loading inventory-skel-targets"
+						<< llendl;
  			}
-
-			options.clear();
- 			if(gUserAuthp->getOptions("buddy-list", options))
- 			{
-				LLUserAuth::options_t::iterator it = options.begin();
-				LLUserAuth::options_t::iterator end = options.end();
-				LLAvatarTracker::buddy_map_t list;
-				LLUUID agent_id;
-				S32 has_rights = 0, given_rights = 0;
-				for (; it != end; ++it)
+ 		}
+
+		options.clear();
+ 		if(gUserAuthp->getOptions("buddy-list", options))
+ 		{
+			LLUserAuth::options_t::iterator it = options.begin();
+			LLUserAuth::options_t::iterator end = options.end();
+			LLAvatarTracker::buddy_map_t list;
+			LLUUID agent_id;
+			S32 has_rights = 0, given_rights = 0;
+			for (; it != end; ++it)
+			{
+				LLUserAuth::response_t::const_iterator option_it;
+				option_it = (*it).find("buddy_id");
+				if(option_it != (*it).end())
 				{
-					LLUserAuth::response_t::const_iterator option_it;
-					option_it = (*it).find("buddy_id");
-					if(option_it != (*it).end())
-					{
-						agent_id.set((*option_it).second.c_str());
-					}
-					option_it = (*it).find("buddy_rights_has");
-					if(option_it != (*it).end())
-					{
-						has_rights = atoi((*option_it).second.c_str());
-					}
-					option_it = (*it).find("buddy_rights_given");
-					if(option_it != (*it).end())
-					{
-						given_rights = atoi((*option_it).second.c_str());
-					}
-					list[agent_id] = new LLRelationship(given_rights, has_rights, false);
+					agent_id.set((*option_it).second.c_str());
 				}
-				LLAvatarTracker::instance().addBuddyList(list);
- 			}
-
-			options.clear();
- 			if(gUserAuthp->getOptions("ui-config", options))
- 			{
-				LLUserAuth::options_t::iterator it = options.begin();
-				LLUserAuth::options_t::iterator end = options.end();
-				for (; it != end; ++it)
+				option_it = (*it).find("buddy_rights_has");
+				if(option_it != (*it).end())
 				{
-					LLUserAuth::response_t::const_iterator option_it;
-					option_it = (*it).find("allow_first_life");
-					if(option_it != (*it).end())
-					{
-						if (option_it->second == "Y")
-						{
-							LLPanelAvatar::sAllowFirstLife = TRUE;
-						}
-					}
+					has_rights = atoi((*option_it).second.c_str());
 				}
- 			}
-
-			options.clear();
-			if(gUserAuthp->getOptions("event_categories", options))
-			{
-				LLEventInfo::loadCategories(options);
-			}
-			if(gUserAuthp->getOptions("event_notifications", options))
-			{
-				gEventNotifier.load(options);
+				option_it = (*it).find("buddy_rights_given");
+				if(option_it != (*it).end())
+				{
+					given_rights = atoi((*option_it).second.c_str());
+				}
+				list[agent_id] = new LLRelationship(given_rights, has_rights, false);
 			}
-			options.clear();
-			if(gUserAuthp->getOptions("classified_categories", options))
+			LLAvatarTracker::instance().addBuddyList(list);
+ 		}
+
+		options.clear();
+ 		if(gUserAuthp->getOptions("ui-config", options))
+ 		{
+			LLUserAuth::options_t::iterator it = options.begin();
+			LLUserAuth::options_t::iterator end = options.end();
+			for (; it != end; ++it)
 			{
-				LLClassifiedInfo::loadCategories(options);
+				LLUserAuth::response_t::const_iterator option_it;
+				option_it = (*it).find("allow_first_life");
+				if(option_it != (*it).end())
+				{
+					if (option_it->second == "Y")
+					{
+						LLPanelAvatar::sAllowFirstLife = TRUE;
+					}
+				}
 			}
-			gInventory.buildParentChildMap();
-			gInventory.addChangedMask(LLInventoryObserver::ALL, LLUUID::null);
-			gInventory.notifyObservers();
+ 		}
 
-			// set up callbacks
-			LLMessageSystem* msg = gMessageSystem;
-			LLInventoryModel::registerCallbacks(msg);
-			LLAvatarTracker::instance().registerCallbacks(msg);
-			LLLandmark::registerCallbacks(msg);
-
-			// request mute list
-			gMuteListp->requestFromServer(gAgent.getID());
-
-			// Get L$ and ownership credit information
-			msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
-			msg->nextBlockFast(_PREHASH_AgentData);
-			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			msg->nextBlockFast(_PREHASH_MoneyData);
-			msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
-			gAgent.sendReliableMessage();
+		options.clear();
+		if(gUserAuthp->getOptions("event_categories", options))
+		{
+			LLEventInfo::loadCategories(options);
+		}
+		if(gUserAuthp->getOptions("event_notifications", options))
+		{
+			gEventNotifier.load(options);
+		}
+		options.clear();
+		if(gUserAuthp->getOptions("classified_categories", options))
+		{
+			LLClassifiedInfo::loadCategories(options);
+		}
+		gInventory.buildParentChildMap();
+		gInventory.addChangedMask(LLInventoryObserver::ALL, LLUUID::null);
+		gInventory.notifyObservers();
 
-			// request all group information
-			// *FIX: This will not do the right thing if the message
-			// gets there before the requestuserserverconnection
-			// circuit is completed.
-			gAgent.sendAgentDataUpdateRequest();
+		// set up callbacks
+		LLMessageSystem* msg = gMessageSystem;
+		LLInventoryModel::registerCallbacks(msg);
+		LLAvatarTracker::instance().registerCallbacks(msg);
+		LLLandmark::registerCallbacks(msg);
 
+		// request mute list
+		gMuteListp->requestFromServer(gAgent.getID());
 
-			// NOTE: removed as part of user-privacy
-			// enhancements. this information should be available from
-			// login. 2006-10-16 Phoenix.
-			// get the users that have been granted modify powers
-			//msg->newMessageFast(_PREHASH_RequestGrantedProxies);
-			//msg->nextBlockFast(_PREHASH_AgentData);
-			//msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			//msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			//gAgent.sendReliableMessage();
+		// Get L$ and ownership credit information
+		msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
+		msg->nextBlockFast(_PREHASH_AgentData);
+		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+		msg->nextBlockFast(_PREHASH_MoneyData);
+		msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
+		gAgent.sendReliableMessage();
 
-			BOOL shown_at_exit = gSavedSettings.getBOOL("ShowInventory");
+		// request all group information
+		// *FIX: This will not do the right thing if the message
+		// gets there before the requestuserserverconnection
+		// circuit is completed.
+		gAgent.sendAgentDataUpdateRequest();
 
-			// Create the inventory views
-			LLInventoryView::showAgentInventory();
 
-			// Hide the inventory if it wasn't shown at exit
-			if(!shown_at_exit)
-			{
-				LLInventoryView::toggleVisibility(NULL);
-			}
+		// NOTE: removed as part of user-privacy
+		// enhancements. this information should be available from
+		// login. 2006-10-16 Phoenix.
+		// get the users that have been granted modify powers
+		//msg->newMessageFast(_PREHASH_RequestGrantedProxies);
+		//msg->nextBlockFast(_PREHASH_AgentData);
+		//msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+		//msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+		//gAgent.sendReliableMessage();
+
+		BOOL shown_at_exit = gSavedSettings.getBOOL("ShowInventory");
+
+		// Create the inventory views
+		LLInventoryView::showAgentInventory();
+
+		// Hide the inventory if it wasn't shown at exit
+		if(!shown_at_exit)
+		{
+			LLInventoryView::toggleVisibility(NULL);
 		}
-		gStartupState++;
+
+		LLStartUp::setStartupState( STATE_MISC );
 		return do_normal_idle;
 	}
 
@@ -2011,14 +1965,8 @@ BOOL idle_startup()
 	//---------------------------------------------------------------------
 	// Misc
 	//---------------------------------------------------------------------
-	if (STATE_MISC == gStartupState)
+	if (STATE_MISC == LLStartUp::getStartupState())
 	{
-		// Create a few objects if we don't actually have a world
-		if (!gConnectToSomething)
-		{
-			// could add them here
-		}
-
 		// We have a region, and just did a big inventory download.
 		// We can estimate the user's connection speed, and set their
 		// max bandwidth accordingly.  JC
@@ -2037,7 +1985,7 @@ BOOL idle_startup()
 			{
 				llinfos << "Fast network connection, increasing max bandwidth to " 
 					<< FASTER_RATE_BPS/1024.f 
-					<< " Kbps" << llendl;
+					<< " kbps" << llendl;
 				gViewerThrottle.setMaxBandwidth(FASTER_RATE_BPS / 1024.f);
 			}
 			else if (rate_bps > FAST_RATE_BPS
@@ -2045,7 +1993,7 @@ BOOL idle_startup()
 			{
 				llinfos << "Fast network connection, increasing max bandwidth to " 
 					<< FAST_RATE_BPS/1024.f 
-					<< " Kbps" << llendl;
+					<< " kbps" << llendl;
 				gViewerThrottle.setMaxBandwidth(FAST_RATE_BPS / 1024.f);
 			}
 		}
@@ -2197,12 +2145,12 @@ BOOL idle_startup()
 			}
 		}
 
-		gStartupState++;
+		LLStartUp::setStartupState( STATE_PRECACHE );
 		timeout.reset();
 		return do_normal_idle;
 	}
 
-	if (STATE_PRECACHE == gStartupState)
+	if (STATE_PRECACHE == LLStartUp::getStartupState())
 	{
 		do_normal_idle = TRUE;
 		
@@ -2211,7 +2159,7 @@ BOOL idle_startup()
 		if(((timeout_frac > 1.f) && gAgent.getAvatarObject())
 		   || (timeout_frac > 3.f))
 		{
-			gStartupState++;
+			LLStartUp::setStartupState( STATE_WEARABLES_WAIT );
 		}
 		else
 		{
@@ -2223,7 +2171,7 @@ BOOL idle_startup()
 		return do_normal_idle;
 	}
 
-	if (STATE_WEARABLES_WAIT == gStartupState)
+	if (STATE_WEARABLES_WAIT == LLStartUp::getStartupState())
 	{
 		do_normal_idle = TRUE;
 
@@ -2234,13 +2182,13 @@ BOOL idle_startup()
 
 		if(gAgent.getWearablesLoaded() || !gAgent.isGenderChosen())
 		{
-			gStartupState++;
+			LLStartUp::setStartupState( STATE_CLEANUP );
 		}
 		else if (wearables_time > MAX_WEARABLES_TIME)
 		{
 			gViewerWindow->alertXml("ClothingLoading");
 			gViewerStats->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG);
-			gStartupState++;
+			LLStartUp::setStartupState( STATE_CLEANUP );
 		}
 		else
 		{
@@ -2252,7 +2200,7 @@ BOOL idle_startup()
 		return do_normal_idle;
 	}
 
-	if (STATE_CLEANUP == gStartupState)
+	if (STATE_CLEANUP == LLStartUp::getStartupState())
 	{
 		set_startup_status(1.0, "", NULL);
 
@@ -2324,7 +2272,7 @@ BOOL idle_startup()
 			gUserAuthp = NULL;
 		}
 
-		gStartupState++;
+		LLStartUp::setStartupState( STATE_STARTED );
 
 		// Unmute audio if desired and setup volumes
 		audio_update_volume();
@@ -2338,7 +2286,7 @@ BOOL idle_startup()
 		return do_normal_idle;
 	}
 
-	llwarns << "Reached end of idle_startup for state " << gStartupState << llendl;
+	llwarns << "Reached end of idle_startup for state " << LLStartUp::getStartupState() << llendl;
 	return do_normal_idle;
 }
 
@@ -2398,7 +2346,7 @@ void login_callback(S32 option, void *userdata)
 
 	if (CONNECT_OPTION == option)
 	{
-		gStartupState++;
+		LLStartUp::setStartupState( STATE_LOGIN_CLEANUP );
 		return;
 	}
 	else if (QUIT_OPTION == option)
@@ -2665,7 +2613,7 @@ void update_dialog_callback(S32 option, void *userdata)
 #if !LL_RELEASE_FOR_DOWNLOAD
 	if (option == 2)
 	{
-		gStartupState++;
+		LLStartUp::setStartupState( STATE_WORLD_INIT ); 
 		return;
 	}
 #endif
@@ -2681,7 +2629,7 @@ void update_dialog_callback(S32 option, void *userdata)
 		}
 		else
 		{
-			gStartupState++;
+			LLStartUp::setStartupState( STATE_WORLD_INIT );
 		}
 		return;
 	}
@@ -3066,7 +3014,7 @@ void init_stat_view()
 	stat_barp->mDisplayHistory = FALSE;
 
 	stat_barp = stat_viewp->addStat("Packet Loss", &(gViewerStats->mPacketsLostPercentStat));
-	stat_barp->setUnitLabel(" %%");
+	stat_barp->setUnitLabel(" %");
 	stat_barp->mMinBar = 0.f;
 	stat_barp->mMaxBar = 5.f;
 	stat_barp->mTickSpacing = 1.f;
@@ -3086,16 +3034,6 @@ void init_stat_view()
 	stat_barp->mPerSec = FALSE;
 	stat_barp->mDisplayMean = FALSE;
 
-	stat_barp = stat_viewp->addStat("Ping User", &(gViewerStats->mUserserverPingStat));
-	stat_barp->setUnitLabel(" msec");
-	stat_barp->mMinBar = 0.f;
-	stat_barp->mMaxBar = 1000.f;
-	stat_barp->mTickSpacing = 100.f;
-	stat_barp->mLabelSpacing = 200.f;
-	stat_barp->mDisplayBar = FALSE;
-	stat_barp->mPerSec = FALSE;
-	stat_barp->mDisplayMean = FALSE;
-
 
 	stat_viewp = new LLStatView("advanced stat view", "Advanced", "OpenDebugStatAdvanced", rect);
 	gDebugView->mStatViewp->addChildAtEnd(stat_viewp);
@@ -3717,17 +3655,31 @@ void release_start_screen()
 	gStartImageGL = NULL;
 }
 
+// static
 bool LLStartUp::canGoFullscreen()
 {
-	return gStartupState >= STATE_WORLD_INIT;
+	return LLStartUp::getStartupState() >= STATE_WORLD_INIT;
 }
 
+
+// static
+void LLStartUp::setStartupState( S32 state )
+{
+	llinfos << "Startup state changing from " << gStartupState << " to " << state << llendl;
+	gStartupState = state;
+}
+
+
 void reset_login()
 {
-	gStartupState = STATE_LOGIN_SHOW;
+	LLStartUp::setStartupState( STATE_LOGIN_SHOW );
 
 	if ( gViewerWindow )
 	{	// Hide menus and normal buttons
 		gViewerWindow->setNormalControlsVisible( FALSE );
 	}
+
+	// Hide any other stuff
+	if ( gFloaterMap )
+		gFloaterMap->setVisible( FALSE );
 }
diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h
index 4137c62a9291937a5ce611b7fd9bfa7b7bd7bd0b..9e1ff3c1516d190283ea445ad3d2ed14fede2acd 100644
--- a/indra/newview/llstartup.h
+++ b/indra/newview/llstartup.h
@@ -22,38 +22,32 @@ extern const char* SCREEN_HOME_FILENAME;
 extern const char* SCREEN_LAST_FILENAME;
 
 enum EStartupState{
-	STATE_FIRST,
-	STATE_LOGIN_SHOW,
-	STATE_LOGIN_WAIT,
-	STATE_LOGIN_CLEANUP,
-	STATE_UPDATE_CHECK,
-	STATE_LOGIN_AUTH_INIT,
-	STATE_LOGIN_AUTHENTICATE,
-	STATE_LOGIN_NO_DATA_YET,
-	STATE_LOGIN_DOWNLOADING,
-	STATE_LOGIN_PROCESS_RESPONSE,
-	STATE_WORLD_INIT,
-	STATE_SEED_GRANTED_WAIT,
-	STATE_SEED_CAP_GRANTED,
-	STATE_QUICKTIME_INIT,
-	STATE_WORLD_WAIT,
-	STATE_AGENT_SEND,
-	STATE_AGENT_WAIT,
-	STATE_INVENTORY_SEND,
-	STATE_MISC,
-	STATE_PRECACHE,
-	STATE_WEARABLES_WAIT,
-	//STATE_INVENTORY_WAIT,
-	//STATE_TOS_AGREEMENT_START,
-	//STATE_TOS_AGREEMENT_WAIT,
-	//STATE_CRITICAL_MESSAGE_START,
-	//STATE_CRITICAL_MESSAGE_WAIT,
-	STATE_CLEANUP,
-	STATE_STARTED
+	STATE_FIRST,					// Initial startup
+	STATE_LOGIN_SHOW,				// Show login screen
+	STATE_LOGIN_WAIT,				// Wait for user input at login screen
+	STATE_LOGIN_CLEANUP,			// Get rid of login screen and start login
+	STATE_UPDATE_CHECK,				// Wait for user at a dialog box (updates, term-of-service, etc)
+	STATE_LOGIN_AUTH_INIT,			// Start login to SL servers
+	STATE_LOGIN_AUTHENTICATE,		// Do authentication voodoo
+	STATE_LOGIN_NO_DATA_YET,		// Waiting for authentication replies to start
+	STATE_LOGIN_DOWNLOADING,		// Waiting for authentication replies to download
+	STATE_LOGIN_PROCESS_RESPONSE,	// Check authentication reply
+	STATE_WORLD_INIT,				// Start building the world
+	STATE_SEED_GRANTED_WAIT,		// Wait for seed cap grant
+	STATE_SEED_CAP_GRANTED,			// Have seed cap grant 
+	STATE_QUICKTIME_INIT,			// Initialzie QT
+	STATE_WORLD_WAIT,				// Waiting for simulator
+	STATE_AGENT_SEND,				// Connect to a region
+	STATE_AGENT_WAIT,				// Wait for region
+	STATE_INVENTORY_SEND,			// Do inventory transfer
+	STATE_MISC,						// Do more things (set bandwidth, start audio, save location, etc)
+	STATE_PRECACHE,					// Wait a bit for textures to download
+	STATE_WEARABLES_WAIT,			// Wait for clothing to download
+	STATE_CLEANUP,					// Final cleanup
+	STATE_STARTED					// Up and running in-world
 };
 
-// exorted symbol
-extern S32 gStartupState;
+// exported symbols
 extern BOOL gAgentMovementCompleted;
 extern bool gUseQuickTime;
 extern bool gQuickTimeInitialized;
@@ -65,6 +59,13 @@ class LLStartUp
 	static bool canGoFullscreen();
 		// returns true if we are far enough along in startup to allow
 		// going full screen
+
+	// Always use this to set gStartupState so changes are logged
+	static void	setStartupState( S32 state );
+	static S32	getStartupState()				{ return gStartupState;		};
+
+protected:
+	static S32 gStartupState;			// Do not set directly, use LLStartup::setStartupState
 };
 
 
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 3df559dee5890934062e3a1de9b5b595c63ba43e..635f74d94f2098a6408b84f5b12c6f4864d1c79a 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -137,7 +137,7 @@ LLStatusBar::LLStatusBar(const std::string& name, const LLRect& rect)
 	LLString text = childGetText("bandwidth_tooltip") + " ";
 	LLUIString bandwidth_tooltip = text;	// get the text from XML until this widget is XML driven
 	mSGBandwidth->setLabel(bandwidth_tooltip.getString().c_str());
-	mSGBandwidth->setUnits("Kbps");
+	mSGBandwidth->setUnits("kbps");
 	mSGBandwidth->setPrecision(0);
 	addChild(mSGBandwidth);
 	x -= SIM_STAT_WIDTH + 2;
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index 178c83f61e4aaec4f8e9e42b7b5cdd3bf8f73719..a0fd9f7d8eea7913cc1e56b2bd343d2ce1a458ea 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -462,7 +462,7 @@ void LLTexLayerSetBuffer::readBackAndUpload(U8* baked_bump_data)
 
 
 // static
-void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, void* userdata, S32 result) // StoreAssetData callback (not fixed)
+void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, void* userdata, S32 result, LLExtStat ext_status) // StoreAssetData callback (not fixed)
 {
 	LLBakedUploadData* baked_upload_data = (LLBakedUploadData*)userdata;
 
diff --git a/indra/newview/lltexlayer.h b/indra/newview/lltexlayer.h
index d60d4eab6c30316f1cd4f85d7332b53dc2493116..e4387b2f180f3cfec6538e6838000a9b5e1552b4 100644
--- a/indra/newview/lltexlayer.h
+++ b/indra/newview/lltexlayer.h
@@ -201,7 +201,7 @@ class LLTexLayerSetBuffer : public LLDynamicTexture
 	void					readBackAndUpload(U8* baked_bump_data);
 	static void				onTextureUploadComplete( const LLUUID& uuid,
 													 void* userdata,
-													 S32 result);
+													 S32 result, LLExtStat ext_status);
 	static void				dumpTotalByteCount();
 
 private:
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 4ac08f2a81a3d58c6c6fad3c086884c09ed78830..e912a720937da423e5e12e1c5f41c1770d8b9f38 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -109,7 +109,7 @@ class LLFloaterTexturePicker : public LLFloater
 	void			setCanApplyImmediately(BOOL b);
 
 	void			setDirty( BOOL b ) { mIsDirty = b; }
-	BOOL			isDirty() { return mIsDirty; }
+	BOOL			isDirty() const { return mIsDirty; }
 	void			setActive( BOOL active );
 
 	LLTextureCtrl*	getOwner() const { return mOwner; }
@@ -888,7 +888,8 @@ LLTextureCtrl::LLTextureCtrl(
 	mNonImmediateFilterPermMask( PERM_NONE ),
 	mCanApplyImmediately( FALSE ),
 	mNeedsRawImageData( FALSE ),
-	mValid( TRUE )
+	mValid( TRUE ),
+	mDirty( FALSE )
 {
 	mCaption = new LLTextBox( label, 
 		LLRect( 0, BTN_HEIGHT_SMALL, mRect.getWidth(), 0 ),
@@ -1050,6 +1051,18 @@ void LLTextureCtrl::setValid(BOOL valid )
 	}
 }
 
+// virtual 
+BOOL	LLTextureCtrl::isDirty() const		
+{ 
+	return mDirty;	
+}
+
+// virtual 
+void	LLTextureCtrl::resetDirty()
+{ 
+	mDirty = FALSE;	
+}
+
 
 // virtual
 void LLTextureCtrl::clear()
@@ -1166,6 +1179,7 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op)
 
 	if( floaterp && mEnabled)
 	{
+		mDirty = (op != TEXTURE_CANCEL);
 		if( floaterp->isDirty() )
 		{
 			setTentative( FALSE );
diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h
index fa4e71d266eae50ca966a345a7ece2c4700037ac..6b562e049266035e3c962ca413c70f9eb418e83d 100644
--- a/indra/newview/lltexturectrl.h
+++ b/indra/newview/lltexturectrl.h
@@ -67,6 +67,9 @@ class LLTextureCtrl
 	virtual void	setVisible( BOOL visible );
 	virtual void	setEnabled( BOOL enabled );
 
+	virtual BOOL	isDirty() const;
+	virtual void	resetDirty();
+
 	void			setValid(BOOL valid);
 
 	// LLUICtrl interface
@@ -149,6 +152,7 @@ class LLTextureCtrl
 	BOOL					 mNeedsRawImageData;
 	LLViewBorder*			 mBorder;
 	BOOL					 mValid;
+	BOOL					 mDirty;
 };
 
 // XUI HACK: When floaters converted, switch this file to lltexturepicker.h/cpp
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index 6a65942785151b1f5c3e7d63e56c457213e7ceb7..05355a707a710bb7e8366b94243602010bba541d 100644
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -783,9 +783,10 @@ void LLToolGrab::onMouseCaptureLost()
 			LLVector3 grab_point_agent = mGrabObject->getRenderPosition();
 
 			LLCoordGL gl_point;
-			gCamera->projectPosAgentToScreen(grab_point_agent, gl_point);
-
-			LLUI::setCursorPositionScreen(gl_point.mX, gl_point.mY);
+			if (gCamera->projectPosAgentToScreen(grab_point_agent, gl_point))
+			{
+				LLUI::setCursorPositionScreen(gl_point.mX, gl_point.mY);
+			}
 		}
 		else
 		{
diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp
index 49f21909a543736fff04671dcb8289d5368a2a51..41679a03696ffe3851093c17117ca5160d613988 100644
--- a/indra/newview/lltoolmorph.cpp
+++ b/indra/newview/lltoolmorph.cpp
@@ -133,6 +133,8 @@ void LLVisualParamHint::preRender(BOOL clear_depth)
 	avatarp->updateComposites();
 	avatarp->updateVisualParams();
 	avatarp->updateGeometry(avatarp->mDrawable);
+	avatarp->updateLOD();
+
 	LLDynamicTexture::preRender(clear_depth);
 }
 
diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp
index 42ef25ac4e24a99b12cd527604b112c361bfd67b..4166cc16fe1abc8fae2928aeb0c6794098c5c77a 100644
--- a/indra/newview/lltracker.cpp
+++ b/indra/newview/lltracker.cpp
@@ -87,15 +87,6 @@ void LLTracker::stopTracking(void* userdata)
 // static virtual
 void LLTracker::drawHUDArrow()
 {
-	/* tracking autopilot destination has been disabled 
-	   -- 2004.01.09, Leviathan
-	// Draw dot for autopilot target
-	if (gAgent.getAutoPilot())
-	{
-		instance()->drawMarker( gAgent.getAutoPilotTargetGlobal(), gTrackColor );
-		return;
-	}
-	*/
 	switch (getTrackingStatus())
 	{ 
 	case TRACKING_AVATAR:
@@ -459,7 +450,6 @@ void LLTracker::renderBeacon(LLVector3d pos_global,
 	if (dist > 0.99f * gCamera->getFar())
 	{
 		color_frac = 0.4f;
-	//	pos_global = gAgent.getCameraPositionGlobal() + 0.99f*(gCamera->getFar()/dist)*to_vec;
 	}
 	else
 	{
@@ -484,7 +474,6 @@ void LLTracker::renderBeacon(LLVector3d pos_global,
 		
 		draw_shockwave(1024.f, gRenderStartTime.getElapsedTimeF32(), 32, fogged_color);
 
-		//glScalef(1.f, 1.f, 1000.f);
 		glColor4fv(fogged_color.mV);
 		const U32 BEACON_VERTS = 256;
 		const F32 step = 1024.0f/BEACON_VERTS;
@@ -534,24 +523,30 @@ void LLTracker::renderBeacon(LLVector3d pos_global,
 			glEnd();
 		}
 							
-		//gCylinder.render(1000);
 	glPopMatrix();
 
-	char text[1024];		/* Flawfinder: ignore */
-	snprintf(text, sizeof(text), "%.0f m", to_vec.magVec());		/* Flawfinder: ignore */
+	if (!gCamera || to_vec.magVec() > gCamera->getFar())
+	{
+		hud_textp->clearString();
+	}
+	else
+	{
+		char text[1024];		/* Flawfinder: ignore */
+		snprintf(text, sizeof(text), "%.0f m", to_vec.magVec());		/* Flawfinder: ignore */
 
-	LLWString wstr;
-	wstr += utf8str_to_wstring(label);
-	wstr += '\n';
-	wstr += utf8str_to_wstring(text);
+		LLWString wstr;
+		wstr += utf8str_to_wstring(label);
+		wstr += '\n';
+		wstr += utf8str_to_wstring(text);
 
-	hud_textp->setFont(LLFontGL::sSansSerif);
-	hud_textp->setZCompare(FALSE);
-	hud_textp->setColor(LLColor4(1.f, 1.f, 1.f, llmax(0.2f, llmin(1.f,(dist-FADE_DIST)/FADE_DIST))));
+		hud_textp->setFont(LLFontGL::sSansSerif);
+		hud_textp->setZCompare(FALSE);
+		hud_textp->setColor(LLColor4(1.f, 1.f, 1.f, llmax(0.2f, llmin(1.f,(dist-FADE_DIST)/FADE_DIST))));
 
-	hud_textp->setString(wstr);
-	hud_textp->setVertAlignment(LLHUDText::ALIGN_VERT_CENTER);
-	hud_textp->setPositionAgent(pos_agent);
+		hud_textp->setString(wstr);
+		hud_textp->setVertAlignment(LLHUDText::ALIGN_VERT_CENTER);
+		hud_textp->setPositionAgent(pos_agent);
+	}
 }
 
 
@@ -623,6 +618,14 @@ void LLTracker::drawMarker(const LLVector3d& pos_global, const LLColor4& color)
 		return;
 	}
 
+	LLVector3d to_vec = pos_global - gAgent.getCameraPositionGlobal();
+	to_vec.mdV[2] = 0;
+
+	if (to_vec.magVec() > gCamera->getFar())
+	{	//only draw arrow if lateral distance to object is less than view distance.
+		return;
+	}
+
 	// get position
 	LLVector3 pos_local = gAgent.getPosAgentFromGlobal(pos_global);
 
diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp
index 8ef77fa49664820744b26af61109907deb9b21c1..55918f4b611cb848f1a6de8444f224d37ac37f37 100644
--- a/indra/newview/llviewerassetstorage.cpp
+++ b/indra/newview/llviewerassetstorage.cpp
@@ -68,7 +68,7 @@ void LLViewerAssetStorage::storeAssetData(
 				delete req;
 				if (callback)
 				{
-					callback(asset_id, user_data, LL_ERR_ASSET_REQUEST_FAILED);
+					callback(asset_id, user_data, LL_ERR_ASSET_REQUEST_FAILED, LL_EXSTAT_VFS_CORRUPT);
 				}
 				return;
 			}
@@ -97,7 +97,7 @@ void LLViewerAssetStorage::storeAssetData(
 					llwarns << "Probable corruption in VFS file, aborting store asset data" << llendl;
 					if (callback)
 					{
-						callback(asset_id, user_data,  LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE);
+						callback(asset_id, user_data, LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_VFS_CORRUPT);
 					}
 					return;
 				}
@@ -122,7 +122,7 @@ void LLViewerAssetStorage::storeAssetData(
 			llwarns << "AssetStorage: attempt to upload non-existent vfile " << asset_id << ":" << LLAssetType::lookup(asset_type) << llendl;
 			if (callback)
 			{
-				callback(asset_id, user_data,  LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE);
+				callback(asset_id, user_data,  LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE);
 			}
 		}
 	}
@@ -131,7 +131,7 @@ void LLViewerAssetStorage::storeAssetData(
 		llwarns << "Attempt to move asset store request upstream w/o valid upstream provider" << llendl;
 		if (callback)
 		{
-			callback(asset_id, user_data, LL_ERR_CIRCUIT_GONE);
+			callback(asset_id, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM);
 		}
 	}
 }
@@ -200,7 +200,7 @@ void LLViewerAssetStorage::storeAssetData(
 	{
 		if (callback)
 		{
-			callback(asset_id, user_data, LL_ERR_CANNOT_OPEN_FILE);
+			callback(asset_id, user_data, LL_ERR_CANNOT_OPEN_FILE, LL_EXSTAT_BLOCKED_FILE);
 		}
 	}
 }
diff --git a/indra/newview/llviewerassetstorage.h b/indra/newview/llviewerassetstorage.h
index 7817e6450fb51aacce71fff3a8916bc92b4863f0..64c0a96795c935701e472c66b74f1f61ca91070b 100644
--- a/indra/newview/llviewerassetstorage.h
+++ b/indra/newview/llviewerassetstorage.h
@@ -17,8 +17,6 @@ class LLVFile;
 class LLViewerAssetStorage : public LLAssetStorage
 {
 public:
-	typedef void (*LLStoreAssetCallback)(const LLUUID &transaction_id, void *user_data, S32 status);
-
 	LLViewerAssetStorage(LLMessageSystem *msg, LLXferManager *xfer,
 				   LLVFS *vfs, const LLHost &upstream_host);
 
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index fa2a12b34a9a8b824afe4479f835f50a037506f2..5bae78367ee298b385a334b3eff940083f5f7d41 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -15,6 +15,7 @@
 #include "lldir.h"
 #include "lldynamictexture.h"
 #include "lldrawpoolalpha.h"
+#include "llfeaturemanager.h"
 #include "llframestats.h"
 #include "llgl.h"
 #include "llglheaders.h"
@@ -197,7 +198,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
 	// Bail out if we're in the startup state and don't want to try to
 	// render the world.
 	//
-	if (gStartupState < STATE_STARTED)
+	if (LLStartUp::getStartupState() < STATE_STARTED)
 	{
 		display_startup();
 		return;
@@ -295,12 +296,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
 			}
 			break;
 
-		case LLAgent::TELEPORT_CANCELLING:
-			gViewerWindow->setProgressCancelButtonVisible(FALSE, "Cancel");
-			gViewerWindow->setProgressPercent(  100.f );
-			gViewerWindow->setProgressString("Canceling...");
-			break;
-
 		case LLAgent::TELEPORT_NONE:
 			// No teleport in progress
 			gViewerWindow->setShowProgress(FALSE);
@@ -410,7 +405,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
 	}
 	else
 	{
-		LLPipeline::sUseOcclusion = gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery;
+		LLPipeline::sUseOcclusion = gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery && gFeatureManagerp->isFeatureAvailable("UseOcclusion");
 	}
 
 	stop_glerror();
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index ad977a4c4641a060703f562a6968841c067f2d8a..a9b2e574942c901f8b08c646dbfb867134de5d7e 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -23,6 +23,9 @@
 
 #include "llinventoryview.h"
 
+#include "llviewerregion.h"
+#include "llviewerobjectlist.h"
+
 ///----------------------------------------------------------------------------
 /// Local function declarations, constants, enums, and typedefs
 ///----------------------------------------------------------------------------
@@ -531,13 +534,27 @@ void inventory_reliable_callback(void**, S32 status)
 	}
 }
 */
+LLInventoryCallbackManager *LLInventoryCallbackManager::sInstance = NULL;
+
 LLInventoryCallbackManager::LLInventoryCallbackManager() :
 	mLastCallback(0)
 {
+	if( sInstance != NULL )
+	{
+		llwarns << "LLInventoryCallbackManager::LLInventoryCallbackManager: unexpected multiple instances" << llendl;
+		return;
+	}
+	sInstance = this;
 }
 
 LLInventoryCallbackManager::~LLInventoryCallbackManager()
 {
+	if( sInstance != this )
+	{
+		llwarns << "LLInventoryCallbackManager::~LLInventoryCallbackManager: unexpected multiple instances" << llendl;
+		return;
+	}
+	sInstance = NULL;
 }
 
 U32 LLInventoryCallbackManager::registerCB(LLPointer<LLInventoryCallback> cb)
@@ -681,29 +698,56 @@ void move_inventory_item(
 	gAgent.sendReliableMessage();
 }
 
-void _copy_inventory_from_notecard_hdr(const LLUUID& object_id, const LLUUID& notecard_inv_id)
+class LLCopyInventoryFromNotecardResponder : public LLHTTPClient::Responder
 {
-	LLMessageSystem* msg = gMessageSystem;
-	msg->newMessageFast(_PREHASH_CopyInventoryFromNotecard);
-	msg->nextBlock(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->nextBlock(_PREHASH_NotecardData);
-	msg->addUUIDFast(_PREHASH_NotecardItemID, notecard_inv_id);
-	msg->addUUIDFast(_PREHASH_ObjectID, object_id);
-}
+public:
+	//If we get back a normal response, handle it here
+	virtual void result(const LLSD& content)
+	{
+		// What do we do here?
+		llinfos << "CopyInventoryFromNotecard request successful." << llendl;
+	}
+
+	//If we get back an error (not found, etc...), handle it here
+	virtual void error(U32 status, const std::string& reason)
+	{
+		llinfos << "LLCopyInventoryFromNotecardResponder::error "
+			<< status << ": " << reason << llendl;
+	}
+};
 
-void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecard_inv_id, const LLInventoryItem *src)
+void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecard_inv_id, const LLInventoryItem *src, U32 callback_id)
 {
-	LLMessageSystem* msg = gMessageSystem;
-	/*
-	 * I was going to handle multiple inventory items here, but then I realized that
-	 * we are only handling one at a time.  Perhaps you can only select one at a 
-	 * time from the notecard?
-	 */
-	_copy_inventory_from_notecard_hdr(object_id, notecard_inv_id);
-	msg->nextBlockFast(_PREHASH_InventoryData);
-	msg->addUUIDFast(_PREHASH_ItemID, src->getUUID());
-	msg->addUUIDFast(_PREHASH_FolderID, gInventory.findCategoryUUIDForType(src->getType()));
-	gAgent.sendReliableMessage();
+	LLSD body;
+	LLViewerRegion* viewer_region = NULL;
+	if(object_id.notNull())
+	{
+		LLViewerObject* vo = gObjectList.findObject(object_id);
+		if(vo)
+		{
+			viewer_region = vo->getRegion();
+		}
+	}
+
+	// Fallback to the agents region if for some reason the 
+	// object isn't found in the viewer.
+	if(!viewer_region)
+	{
+		viewer_region = gAgent.getRegion();
+	}
+
+	if(viewer_region)
+	{
+		std::string url = viewer_region->getCapability("CopyInventoryFromNotecard");
+		if (!url.empty())
+		{
+			body["notecard-id"] = notecard_inv_id;
+			body["object-id"] = object_id;
+			body["item-id"] = src->getUUID();
+			body["folder-id"] = gInventory.findCategoryUUIDForType(src->getType());
+			body["callback-id"] = (LLSD::Integer)callback_id;
+
+			LLHTTPClient::post(url, body, new LLCopyInventoryFromNotecardResponder());
+		}
+	}
 }
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index 84cdadaf9b2560fa3295fc4e39e3783abab695b4..1a78008457f4f4de1102188ad33b9eac20f57b08 100644
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -214,6 +214,9 @@ class LLInventoryCallbackManager
 private:
 	std::map<U32, LLPointer<LLInventoryCallback> > mMap;
 	U32 mLastCallback;
+	static LLInventoryCallbackManager *sInstance;
+public:
+	static bool is_instantiated() { return sInstance != NULL; }
 };
 extern LLInventoryCallbackManager gInventoryCallbacks;
 
@@ -249,7 +252,8 @@ void move_inventory_item(
 
 void copy_inventory_from_notecard(const LLUUID& object_id,
 								  const LLUUID& notecard_inv_id,
-								  const LLInventoryItem *src);
+								  const LLInventoryItem *src,
+								  U32 callback_id = 0);
 
 
 #endif // LL_LLVIEWERINVENTORY_H
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index abcdb8cdbd5e2ef3f3e5b395c5135102e82976d2..0fea0ffb30ed28d690725a229fc6056fc24c3dc0 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -20,6 +20,7 @@
 #include "indra_constants.h"
 #include "llassetstorage.h"
 #include "llchat.h"
+#include "llfeaturemanager.h"
 #include "llfocusmgr.h"
 #include "llfontgl.h"
 #include "llinstantmessage.h"
@@ -78,6 +79,7 @@
 #include "llfloatergesture.h"
 #include "llfloatergodtools.h"
 #include "llfloatergroupinfo.h"
+#include "llfloatergroupinvite.h"
 #include "llfloatergroups.h"
 #include "llfloaterhtml.h"
 #include "llfloaterhtmlhelp.h"
@@ -391,7 +393,7 @@ void toggle_debug_menus(void*);
 void toggle_map( void* user_data );
 void export_info_callback(LLAssetInfo *info, void **user_data, S32 result);
 void export_data_callback(LLVFS *vfs, const LLUUID& uuid, LLAssetType::EType type, void **user_data, S32 result);
-void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result);
+void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status);
 BOOL menu_check_build_tool( void* user_data );
 void handle_reload_settings(void*);
 void focus_here(void*);
@@ -1206,7 +1208,7 @@ void init_debug_rendering_menu(LLMenuGL* menu)
 
 	LLMenuItemCheckGL* item;
 	item = new LLMenuItemCheckGL("Object-Object Occlusion", menu_toggle_control, NULL, menu_check_control, (void*)"UseOcclusion", 'O', MASK_CONTROL|MASK_SHIFT);
-	item->setEnabled(gGLManager.mHasOcclusionQuery);
+	item->setEnabled(gGLManager.mHasOcclusionQuery && gFeatureManagerp->isFeatureAvailable("UseOcclusion"));
 	menu->append(item);
 	
 	
@@ -5080,6 +5082,43 @@ class LLToolsLookAtSelection : public view_listener_t
 	}
 };
 
+void callback_invite_to_group(LLUUID group_id, void *user_data)
+{
+	std::vector<LLUUID> agent_ids;
+	agent_ids.push_back(*(LLUUID *)user_data);
+	
+	LLFloaterGroupInvite::showForGroup(group_id, &agent_ids);
+}
+
+void invite_to_group(const LLUUID& dest_id)
+{
+	LLViewerObject* dest = gObjectList.findObject(dest_id);
+	if(dest && dest->isAvatar())
+	{
+		LLFloaterGroupPicker* widget;
+		widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
+		if (widget)
+		{
+			widget->center();
+			widget->setPowersMask(GP_MEMBER_INVITE);
+			widget->setSelectCallback(callback_invite_to_group, (void *)&dest_id);
+		}
+	}
+}
+
+class LLAvatarInviteToGroup : public view_listener_t
+{
+	bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
+	{
+		LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
+		if(avatar)
+		{
+			invite_to_group(avatar->getID());
+		}
+		return true;
+	}
+};
+
 class LLAvatarAddFriend : public view_listener_t
 {
 	bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
@@ -7414,7 +7453,7 @@ class LLViewToggleRenderType : public view_listener_t
 	bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
 	{
 		LLString type = userdata.asString();
-		if (type == "particles")
+		if (type == "hideparticles")
 		{
 			LLPipeline::toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
 		}
@@ -7428,7 +7467,7 @@ class LLViewCheckRenderType : public view_listener_t
 	{
 		LLString type = userdata["data"].asString();
 		bool new_value = false;
-		if (type == "particles")
+		if (type == "hideparticles")
 		{
 			new_value = LLPipeline::toggleRenderTypeControlNegated((void *)LLPipeline::RENDER_TYPE_PARTICLES);
 		}
@@ -7730,6 +7769,7 @@ void initialize_menus()
 	addMenu(new LLAvatarDebug(), "Avatar.Debug");
 	addMenu(new LLAvatarVisibleDebug(), "Avatar.VisibleDebug");
 	addMenu(new LLAvatarEnableDebug(), "Avatar.EnableDebug");
+	addMenu(new LLAvatarInviteToGroup(), "Avatar.InviteToGroup");
 	addMenu(new LLAvatarGiveCard(), "Avatar.GiveCard");
 	addMenu(new LLAvatarEject(), "Avatar.Eject");
 	addMenu(new LLAvatarSendIM(), "Avatar.SendIM");
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 7215f7948f7df073960fb5b4c0fcfb5b7e26e701..9d8a4b002653bef1199e6f8fc1e8fc4879595cd4 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -776,7 +776,7 @@ void upload_new_resource(const LLString& src_filename, std::string name,
 	}
 }
 
-void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result) // StoreAssetData callback (fixed)
+void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLResourceData* data = (LLResourceData*)user_data;
 	//LLAssetType::EType pref_loc = data->mPreferredLocation;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index cbaa1e2f2e543cb7b6f60e4b9438b2a98891ce1a..a9eff5d5f5bd4603405bce2a2c528b0523938768 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -73,6 +73,7 @@
 #include "llimpanel.h"
 #include "llinventorymodel.h"
 #include "llinventoryview.h"
+#include "llkeyframemotion.h" 
 #include "llmenugl.h"
 #include "llmutelist.h"
 #include "llnetmap.h"
@@ -554,6 +555,15 @@ void join_group_callback(S32 option, void* user_data)
 	LLJoinGroupData* data = (LLJoinGroupData*)user_data;
 	BOOL delete_context_data = TRUE;
 	bool accept_invite = false;
+
+	if (option == 2 && data && !data->mGroupID.isNull())
+	{
+		LLFloaterGroupInfo::showFromUUID(data->mGroupID);
+		LLString::format_map_t args;
+		args["[MESSAGE]"] = data->mMessage;
+		LLNotifyBox::showXml("JoinGroup", args, &join_group_callback, data);
+		return;
+	}
 	if(option == 0 && data && !data->mGroupID.isNull())
 	{
 		// check for promotion or demotion.
@@ -744,7 +754,7 @@ bool check_offer_throttle(const std::string& from_name, bool check_only)
 		//llinfos << "Throttle Not Expired, Count: " << throttle_count << llendl;
 		// When downloading the initial inventory we get a lot of new items
 		// coming in and can't tell that from spam.  JC
-		if (gStartupState >= STATE_STARTED
+		if (LLStartUp::getStartupState() >= STATE_STARTED
 			&& throttle_count >= OFFER_THROTTLE_MAX_COUNT)
 		{
 			if (!throttle_logged)
@@ -2143,7 +2153,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
 	{
 		is_muted = gMuteListp->isMuted(from_id, from_name, LLMute::flagTextChat)
 				   || gMuteListp->isMuted(owner_id);
-		is_linden = gMuteListp->isLinden(from_name);
+		is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT && gMuteListp->isLinden(from_name);
 	}
 
 	BOOL is_audible = (CHAT_AUDIBLE_FULLY == chat.mAudible);
@@ -2300,16 +2310,16 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
 		}
 
 		// truth table:
-		// LINDEN	BUSY	MUTED	OWNED_BY_YOU			DISPLAY		STORE IN HISTORY
-		// F		F		F		F						Yes			Yes
-		// F		F		F		T						Yes			Yes
-		// F		F		T		F						No			No
-		// F		F		T		T						No			No
-		// F		T		F		F						No			Yes
-		// F		T		F		T						Yes			Yes
-		// F		T		T		F						No			No
-		// F		T		T		T						No			No
-		// T		*		*		*						Yes			Yes
+		// LINDEN	BUSY	MUTED	OWNED_BY_YOU	TASK		DISPLAY		STORE IN HISTORY
+		// F		F		F		F				*			Yes			Yes
+		// F		F		F		T				*			Yes			Yes
+		// F		F		T		F				*			No			No
+		// F		F		T		T				*			No			No
+		// F		T		F		F				*			No			Yes
+		// F		T		F		T				*			Yes			Yes
+		// F		T		T		F				*			No			No
+		// F		T		T		T				*			No			No
+		// T		*		*		*				F			Yes			Yes
 
 		chat.mMuted = is_muted && !is_linden;
 		
@@ -2408,47 +2418,103 @@ class LLFetchInWelcomeArea : public LLInventoryFetchDescendentsObserver
 	{
 		LLIsType is_landmark(LLAssetType::AT_LANDMARK);
 		LLIsType is_card(LLAssetType::AT_CALLINGCARD);
-		LLInventoryModel::cat_array_t cats;
-		LLInventoryModel::item_array_t items;
+
+		LLInventoryModel::cat_array_t	card_cats;
+		LLInventoryModel::item_array_t	card_items;
+		LLInventoryModel::cat_array_t	land_cats;
+		LLInventoryModel::item_array_t	land_items;
+
 		folder_ref_t::iterator it = mCompleteFolders.begin();
 		folder_ref_t::iterator end = mCompleteFolders.end();
 		for(; it != end; ++it)
 		{
 			gInventory.collectDescendentsIf(
 				(*it),
-				cats,
-				items,
+				land_cats,
+				land_items,
 				LLInventoryModel::EXCLUDE_TRASH,
 				is_landmark);
 			gInventory.collectDescendentsIf(
 				(*it),
-				cats,
-				items,
+				card_cats,
+				card_items,
 				LLInventoryModel::EXCLUDE_TRASH,
 				is_card);
 		}
-		S32 count = items.count();
-		for(S32 i = 0; i < count; ++i)
-		{
-			LLString::format_map_t args;
-			args["[NAME]"] = items[i]->getName();
-			switch(items[i]->getType())
-			{
-			case LLAssetType::AT_LANDMARK:
-			  	LLNotifyBox::showXml("TeleportToLandmark",args);
-				break;
-			case LLAssetType::AT_CALLINGCARD:
-			  	LLNotifyBox::showXml("TeleportToPerson",args);
-				break;
-			default:
-				break;
-			}
+		LLString::format_map_t args;
+		if ( land_items.count() > 0 )
+		{	// Show notification that they can now teleport to landmarks.  Use a random landmark from the inventory
+			S32 random_land = ll_rand( land_items.count() - 1 );
+			args["[NAME]"] = land_items[random_land]->getName();
+			LLNotifyBox::showXml("TeleportToLandmark",args);
+		}
+		if ( card_items.count() > 0 )
+		{	// Show notification that they can now contact people.  Use a random calling card from the inventory
+			S32 random_card = ll_rand( card_items.count() - 1 );
+			args["[NAME]"] = card_items[random_card]->getName();
+			LLNotifyBox::showXml("TeleportToPerson",args);
 		}
+
 		gInventory.removeObserver(this);
 		delete this;
 	}
 };
 
+
+
+class LLPostTeleportNotifiers : public LLEventTimer 
+{
+public:
+	LLPostTeleportNotifiers();
+	virtual ~LLPostTeleportNotifiers();
+
+	//function to be called at the supplied frequency
+	virtual BOOL tick();
+};
+
+LLPostTeleportNotifiers::LLPostTeleportNotifiers() : LLEventTimer( 2.0 )
+{
+};
+
+LLPostTeleportNotifiers::~LLPostTeleportNotifiers()
+{
+}
+
+BOOL LLPostTeleportNotifiers::tick()
+{
+	BOOL all_done = FALSE;
+	if ( gAgent.getTeleportState() == LLAgent::TELEPORT_NONE )
+	{
+		// get callingcards and landmarks available to the user arriving.
+		LLInventoryFetchDescendentsObserver::folder_ref_t folders;
+		LLUUID folder_id;
+		folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD);
+		if(folder_id.notNull()) 
+			folders.push_back(folder_id);
+		folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
+		if(folder_id.notNull()) 
+			folders.push_back(folder_id);
+		if(!folders.empty())
+		{
+			LLFetchInWelcomeArea* fetcher = new LLFetchInWelcomeArea;
+			fetcher->fetchDescendents(folders);
+			if(fetcher->isEverythingComplete())
+			{
+				fetcher->done();
+			}
+			else
+			{
+				gInventory.addObserver(fetcher);
+			}
+		}
+		all_done = TRUE;
+	}
+
+	return all_done;
+}
+
+
+
 // Teleport notification from the simulator
 // We're going to pretend to be a new agent
 void process_teleport_finish(LLMessageSystem* msg, void**)
@@ -2494,26 +2560,9 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
 	{
 		gAgent.setHomePosRegion(region_handle, pos);
 
-		// get callingcards and landmarks available to the user arriving.
-		LLInventoryFetchDescendentsObserver::folder_ref_t folders;
-		LLUUID folder_id;
-		folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD);
-		if(folder_id.notNull()) folders.push_back(folder_id);
-		folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
-		if(folder_id.notNull()) folders.push_back(folder_id);
-		if(!folders.empty())
-		{
-			LLFetchInWelcomeArea* fetcher = new LLFetchInWelcomeArea;
-			fetcher->fetchDescendents(folders);
-			if(fetcher->isEverythingComplete())
-			{
-				fetcher->done();
-			}
-			else
-			{
-				gInventory.addObserver(fetcher);
-			}
-		}
+		// Create a timer that will send notices when teleporting is all finished.  Since this is 
+		// based on the LLEventTimer class, it will be managed by that class and not orphaned or leaked.
+		new LLPostTeleportNotifiers();
 	}
 
 	LLHost sim_host(sim_ip, sim_port);
@@ -2646,6 +2695,8 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 
 	llinfos << "Changing home region to " << x << ":" << y << llendl;
 
+	LLKeyframeDataCache::clear();
+
 	// set our upstream host the new simulator and shuffle things as
 	// appropriate.
 	LLVector3 shift_vector = regionp->getPosRegionFromGlobal(
@@ -4007,12 +4058,10 @@ void process_alert_core(const char* buffer, BOOL modal)
 	else if( !strcmp( buffer, "Home position set." ) )
 	{
 		// save the home location image to disk
-		char temp_str[LL_MAX_PATH];		/* Flawfinder: ignore */
-		strncpy(temp_str, gDirUtilp->getLindenUserDir().c_str(), LL_MAX_PATH -1);		/* Flawfinder: ignore */
-		temp_str[LL_MAX_PATH -1] = '\0';
-		strcat(temp_str, "/");		/* Flawfinder: ignore */	
-		strcat(temp_str,SCREEN_HOME_FILENAME);		/* Flawfinder: ignore */
-		gViewerWindow->saveSnapshot(temp_str, gViewerWindow->getWindowWidth(), gViewerWindow->getWindowHeight(), FALSE, FALSE);
+		LLString snap_filename = gDirUtilp->getLindenUserDir();
+		snap_filename += gDirUtilp->getDirDelimiter();
+		snap_filename += SCREEN_HOME_FILENAME;
+		gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidth(), gViewerWindow->getWindowHeight(), FALSE, FALSE);
 	}
 
 	// Translate system messages here.
@@ -4563,7 +4612,16 @@ void process_teleport_failed(LLMessageSystem *msg, void**)
 	msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, STD_STRING_BUF_SIZE, reason);
 
 	LLStringBase<char>::format_map_t args;
-	args["[REASON]"] = LLAgent::sTeleportErrorMessages[reason];
+	LLString big_reason = LLAgent::sTeleportErrorMessages[reason];
+	if ( big_reason.size() > 0 )
+	{	// Substitute verbose reason from the local map
+		args["[REASON]"] = big_reason;
+	}
+	else
+	{	// Nothing found in the map - use what the server returned
+		args["[REASON]"] = reason;
+	}
+
 	gViewerWindow->alertXml("CouldNotTeleportReason", args);
 
 	if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
@@ -5028,7 +5086,7 @@ void process_load_url(LLMessageSystem* msg, void**)
 }
 
 
-void callback_download_complete(void** data, S32 result)
+void callback_download_complete(void** data, S32 result, LLExtStat ext_status)
 {
 	LLString* filepath = (LLString*)data;
 	LLString::format_map_t args;
@@ -5165,7 +5223,7 @@ void callbackCacheEstateOwnerName(
 void onCovenantLoadComplete(LLVFS *vfs,
 					const LLUUID& asset_uuid,
 					LLAssetType::EType type,
-					void* user_data, S32 status)
+					void* user_data, S32 status, LLExtStat ext_status)
 {
 	llinfos << "onCovenantLoadComplete()" << llendl;
 	std::string covenant_text;
diff --git a/indra/newview/llviewermessage.h b/indra/newview/llviewermessage.h
index ccfd1f7277b5f3ddc943819cdfaeb83116fb47f2..93519f77369875294f311556c482d86ace771419 100644
--- a/indra/newview/llviewermessage.h
+++ b/indra/newview/llviewermessage.h
@@ -160,7 +160,7 @@ void process_covenant_reply(LLMessageSystem* msg, void**);
 void onCovenantLoadComplete(LLVFS *vfs,
 							const LLUUID& asset_uuid,
 							LLAssetType::EType type,
-							void* user_data, S32 status);
+							void* user_data, S32 status, LLExtStat ext_status);
 void callbackCacheEstateOwnerName(
 		const LLUUID& id,
 		const char* first,
@@ -199,3 +199,4 @@ void process_feature_disabled_message(LLMessageSystem* msg, void**);
 
 #endif
 
+
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bbb69594da90d8e74e1255ad4b825238bc3c619c..2d39bec6a7d2d2071451d4fb8f3f835883bdd13d 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2418,7 +2418,7 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data)
 								LLXferManager::HIGH_PRIORITY);
 }
 
-void LLViewerObject::processTaskInvFile(void** user_data, S32 error_code)
+void LLViewerObject::processTaskInvFile(void** user_data, S32 error_code, LLExtStat ext_status)
 {
 	LLFilenameAndTask* ft = (LLFilenameAndTask*)user_data;
 	LLViewerObject* object = NULL;
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index f52466cc2d6e896ee5d9609e7ec37f16c808cfe9..a7cc4c818cfbd45d1043b284c3230f53fe6fa165 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -519,7 +519,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount
 	// inventory functionality
 	//
 
-	static void processTaskInvFile(void** user_data, S32 error_code);
+	static void processTaskInvFile(void** user_data, S32 error_code, LLExtStat ext_status);
 	void loadTaskInvFile(const char* filename);
 	void doInventoryCallback();
 	
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 2ac131ac91da1620ace6a91f19c4d0b07898c6f0..b029e604221d0fae34432bf301008dfdf8695420 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -634,13 +634,33 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	
 	std::vector<LLViewerObject*> kill_list;
 	S32 num_active_objects = 0;
+	LLViewerObject *objectp = NULL;	
 	
+	// Make a copy of the list in case something in idleUpdate() messes with it
+	std::vector<LLViewerObject*> idle_list;
+	idle_list.reserve( mActiveObjects.size() );
+
+ 	for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
+		active_iter != mActiveObjects.end(); active_iter++)
+	{
+		objectp = *active_iter;
+		if (objectp)
+		{
+			idle_list.push_back( objectp );
+		}
+		else
+		{	// There shouldn't be any NULL pointers in the list, but they have caused
+			// crashes before.  This may be idleUpdate() messing with the list.
+			llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl;
+		}
+	}
+
 	if (gSavedSettings.getBOOL("FreezeTime"))
 	{
-		for (std::set<LLPointer<LLViewerObject> >::iterator iter = mActiveObjects.begin();
-			iter != mActiveObjects.end(); iter++)
+		for (std::vector<LLViewerObject*>::iterator iter = idle_list.begin();
+			iter != idle_list.end(); iter++)
 		{
-			LLViewerObject *objectp = *iter;
+			objectp = *iter;
 			if (objectp->getPCode() == LLViewerObject::LL_VO_CLOUDS ||
 				objectp->isAvatar())
 			{
@@ -650,10 +670,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	}
 	else
 	{
-		for (std::set<LLPointer<LLViewerObject> >::iterator iter = mActiveObjects.begin();
-			iter != mActiveObjects.end(); iter++)
+		for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin();
+			idle_iter != idle_list.end(); idle_iter++)
 		{
-			LLViewerObject *objectp = *iter;
+			objectp = *idle_iter;
 			if (!objectp->idleUpdate(agent, world, frame_time))
 			{
 				//  If Idle Update returns false, kill object!
@@ -664,10 +684,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 				num_active_objects++;
 			}
 		}
-		for (std::vector<LLViewerObject*>::iterator iter = kill_list.begin();
-			iter != kill_list.end(); iter++)
+		for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin();
+			kill_iter != kill_list.end(); kill_iter++)
 		{
-			LLViewerObject *objectp = *iter;
+			objectp = *kill_iter;
 			killObject(objectp);
 		}
 	}
@@ -1079,6 +1099,8 @@ U32 LLViewerObjectList::renderObjectsForSelect(LLCamera &camera, BOOL pick_parce
 			iter != pick_drawables.end(); iter++)
 		{
 			LLDrawable* drawablep = *iter;
+			if( !drawablep )
+				continue;
 
 			LLViewerObject* last_objectp = NULL;
 			for (S32 face_num = 0; face_num < drawablep->getNumFaces(); face_num++)
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index c3841cdd98d7a40bcb8778598304041cec274be2..81af21069e2c382551eec320e7434bb26a4db8af 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1187,9 +1187,9 @@ class BaseCapabilitiesComplete : public LLHTTPClient::Responder
 		llinfos << "BaseCapabilitiesComplete::error "
 			<< statusNum << ": " << reason << llendl;
 		
-		if (STATE_SEED_GRANTED_WAIT == gStartupState)
+		if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
 		{
-			gStartupState = STATE_SEED_CAP_GRANTED;
+			LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED );
 		}
     }
 
@@ -1203,9 +1203,9 @@ class BaseCapabilitiesComplete : public LLHTTPClient::Responder
 				<< iter->first << llendl;
 		}
 		
-		if (STATE_SEED_GRANTED_WAIT == gStartupState)
+		if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
 		{
-			gStartupState = STATE_SEED_CAP_GRANTED;
+			LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED );
 		}
 	}
 
@@ -1256,6 +1256,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	capabilityNames.append("ChatSessionRequest");
 	capabilityNames.append("ProvisionVoiceAccountRequest");
 	capabilityNames.append("ServerReleaseNotes");
+	capabilityNames.append("CopyInventoryFromNotecard");
 
 	llinfos << "posting to seed " << url << llendl;
 
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 2fff820602562a1eb5fa82d41b7ea87a45bbebf3..96117ce502e01fb68f4e4204dda558efc584f752 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -35,6 +35,68 @@
 
 extern BOOL gPacificDaylightTime;
 
+///----------------------------------------------------------------------------
+/// Class LLEmbeddedNotecardOpener
+///----------------------------------------------------------------------------
+class LLEmbeddedNotecardOpener : public LLInventoryCallback
+{
+	LLViewerTextEditor* mTextEditor;
+
+public:
+	LLEmbeddedNotecardOpener()
+		: mTextEditor(NULL)
+	{
+	}
+
+	void setEditor(LLViewerTextEditor* e) {mTextEditor = e;}
+
+	// override
+	void fire(const LLUUID& inv_item)
+	{
+		if(!mTextEditor)
+		{
+			// The parent text editor may have vanished by now. 
+            // In that case just quit.
+			return;
+		}
+
+		LLInventoryItem* item = gInventory.getItem(inv_item);
+		if(!item)
+		{
+			llwarns << "Item add reported, but not found in inventory!: " << inv_item << llendl;
+		}
+		else
+		{
+			// See if we can bring an existing preview to the front
+			if(!LLPreview::show(item->getUUID(), true))
+			{
+				if(!gSavedSettings.getBOOL("ShowNewInventory"))
+				{
+					// There isn't one, so make a new preview
+					S32 left, top;
+					gFloaterView->getNewFloaterPosition(&left, &top);
+					LLRect rect = gSavedSettings.getRect("NotecardEditorRect");
+					rect.translate(left - rect.mLeft, top - rect.mTop);
+					LLPreviewNotecard* preview;
+					preview = new LLPreviewNotecard("preview notecard", 
+													rect, 
+													LLString("Embedded Note: ") + item->getName(),
+													item->getUUID(), 
+													LLUUID::null, 
+													item->getAssetUUID(),
+													true, 
+													(LLViewerInventoryItem*)item);
+					preview->setSourceID(LLUUID::null);
+					preview->setFocus(TRUE);
+
+					// Force to be entirely onscreen.
+					gFloaterView->adjustToFitScreen(preview, FALSE);
+				}
+			}
+		}
+	}
+};
+
 ////////////////////////////////////////////////////////////
 // LLEmbeddedItems
 //
@@ -477,14 +539,21 @@ LLViewerTextEditor::LLViewerTextEditor(const LLString& name,
 									   const LLFontGL* font,
 									   BOOL allow_embedded_items)
 	: LLTextEditor(name, rect, max_length, default_text, font, allow_embedded_items),
-	  mDragItemSaved(FALSE)
+	  mDragItemSaved(FALSE),
+	  mInventoryCallback(new LLEmbeddedNotecardOpener)
 {
 	mEmbeddedItemList = new LLEmbeddedItems(this);
+	mInventoryCallback->setEditor(this);
 }
 
 LLViewerTextEditor::~LLViewerTextEditor()
 {
 	delete mEmbeddedItemList;
+	
+	
+	// The inventory callback may still be in use by gInventoryCallbackManager...
+	// so set its reference to this to null.
+	mInventoryCallback->setEditor(NULL); 
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -1259,22 +1328,14 @@ void LLViewerTextEditor::openEmbeddedLandmark( LLInventoryItem* item )
 	open_landmark((LLViewerInventoryItem*)item, "   preview landmark", FALSE, item->getUUID(), TRUE);
 }
 
-
 void LLViewerTextEditor::openEmbeddedNotecard( LLInventoryItem* item, BOOL saved )
 {
 	if (saved)
 	{
-		// Pop-up the notecard floater.
-		// Note: Previously would copy to inventory and rely on autodisplay to view.
-		// Now that autodisplay can be turned off, we need to make this case display always. 
-		// besides, there's no point adding to inventory -MG
-		open_notecard(
-			(LLViewerInventoryItem*)item,
-			LLString("Embedded Note: ") + item->getName(), // title
-			mObjectID,
-			FALSE, // show_keep_discard
-			LLUUID::null, // source_id
-			TRUE); // take_focus
+		// An LLInventoryItem needs to be in an inventory to be opened.
+		// This will give the item to the viewer's agent.
+		// The callback will attempt to open it if its not already opened.
+		copyInventory(item, gInventoryCallbacks.registerCB(mInventoryCallback));
 	}
 	else
 	{
@@ -1349,11 +1410,11 @@ bool LLViewerTextEditor::importStream(std::istream& str)
 	return success;
 }
 
-void LLViewerTextEditor::copyInventory(LLInventoryItem* item)
+void LLViewerTextEditor::copyInventory(const LLInventoryItem* item, U32 callback_id)
 {
 	copy_inventory_from_notecard(mObjectID,
 								 mNotecardInventoryID,
-								 item);
+								 item, callback_id);
 }
 
 bool LLViewerTextEditor::hasEmbeddedInventory()
diff --git a/indra/newview/llviewertexteditor.h b/indra/newview/llviewertexteditor.h
index a57b3fec7e58d7a1375a0692ac6478f4cfa19059..58ca74156a6fc501e5539e599fed5db0035ea709 100644
--- a/indra/newview/llviewertexteditor.h
+++ b/indra/newview/llviewertexteditor.h
@@ -13,7 +13,7 @@
 
 class LLInventoryItem;
 class LLEmbeddedItems;
-
+class LLEmbeddedNotecardOpener;
 
 //
 // Classes
@@ -66,7 +66,7 @@ class LLViewerTextEditor : public LLTextEditor
 		// Appends Second Life time, small font, grey
 		// If this starts a line, you need to prepend a newline.
 
-	void copyInventory(LLInventoryItem* item);
+	void copyInventory(const LLInventoryItem* item, U32 callback_id = 0);
 
 	// returns true if there is embedded inventory.
 	// *HACK: This is only useful because the notecard verifier may
@@ -103,6 +103,8 @@ class LLViewerTextEditor : public LLTextEditor
 
 	LLUUID mObjectID;
 	LLUUID mNotecardInventoryID;
+
+	LLPointer<LLEmbeddedNotecardOpener> mInventoryCallback;
 };
 
 #endif  // LL_VIEWERTEXTEDITOR_H
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index dbce01246f0603944a9136d1e28e92d4159cbff7..b19b676fd60d8676c239c65f3ec5bc364937bec6 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1285,7 +1285,7 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
 		{
 			if (!gQuit)
 			{
-				if (gStartupState >= STATE_STARTED)
+				if (LLStartUp::getStartupState() >= STATE_STARTED)
 				{
 					// if we're in world, show a progress bar to hide reloading of textures
 					llinfos << "Restoring GL during activate" << llendl;
@@ -2726,27 +2726,11 @@ BOOL LLViewerWindow::handlePerFrameHover()
 
 	gPipeline.sRenderProcessBeacons = FALSE;
 	KEY key = gKeyboard->currentKey();
-	if (((mask & MASK_CONTROL) && ('N' == key || 'n' == key)) || (gFloaterTools && gFloaterTools->getVisible()) || gSavedSettings.getBOOL("BeaconAlwaysOn"))
+	if (((mask & MASK_CONTROL) && ('N' == key || 'n' == key)) || gSavedSettings.getBOOL("BeaconAlwaysOn"))
 	{
 		gPipeline.sRenderProcessBeacons = TRUE;
 	}
 
-/*
-	// Show joints while in edit mode and hold down alt key.
-	if (gHUDManager)
-	{
-		BOOL menuOption = gSavedSettings.getBOOL("AltShowsPhysical");
-		if (menuOption
-			|| (gFloaterTools && gFloaterTools->getVisible()))
-		{
-			gHUDManager->toggleShowPhysical( mask & MASK_ALT );
-		}
-		else
-		{
-			gHUDManager->toggleShowPhysical( FALSE );
-		}
-	}
-*/
 	BOOL handled = FALSE;
 
 	BOOL handled_by_top_ctrl = FALSE;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 60cce34b72cf1ab133e28b99c54896673449f38a..27247630238d363a93e183f037c80c4051f68719 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1352,6 +1352,7 @@ void LLVOAvatar::initClass()
 	if (!skeleton_node)
 	{
 		llerrs << "No skeleton in avatar configuration file: " << xmlFile << llendl;
+		return;
 	}
 	
 	LLString skeleton_file_name;
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 31c2a282d1079d63a071289e235788be3673ac2a..95a5b140f631b50c190414d0293b3bda2f7684c8 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -1319,7 +1319,7 @@ void LLVoiceClient::stateMachine()
 							CloseHandle(pinfo.hThread); // stops leaks - nothing else
 						}		
 						
-						delete args2;
+						delete[] args2;
 #else	// LL_WINDOWS
 						// This should be the same for mac and linux
 						{
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 4c0855be29c6707faf300689b1b540907b6a07a0..e4315ca951b46e90f9d56b06062608d77b1013fe 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -458,7 +458,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 	buffer->getTexCoordStrider(texcoordsp);
 	buffer->getIndexStrider(indicesp);
 
-	std::vector<LLDrawInfo*>& draw_vec = group->mDrawMap[mRenderPass];
+	LLSpatialGroup::drawmap_elem_t& draw_vec = group->mDrawMap[mRenderPass];	
 
 	for (std::vector<LLFace*>::iterator i = mFaceList.begin(); i != mFaceList.end(); ++i)
 	{
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index b8a06f4816e4cf81bc6b56f72d99419455666b3f..49af54d5aa3a36110799918ce15e662c198c6538 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -11,6 +11,7 @@
 #include "llvosky.h"
 
 #include "imageids.h"
+#include "llfeaturemanager.h"
 #include "llviewercontrol.h"
 #include "llframetimer.h"
 #include "timing.h"
@@ -577,7 +578,7 @@ void LLVOSky::initCubeMap()
 	{
 		mCubeMap->init(images);
 	}
-	else if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap)
+	else if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && gFeatureManagerp->isFeatureAvailable("RenderCubeMap"))
 	{
 		mCubeMap = new LLCubeMap();
 		mCubeMap->init(images);
@@ -614,7 +615,8 @@ void LLVOSky::restoreGL()
 
 	calcBrightnessScaleAndColors();
 
-	if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap)
+	if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap
+	    && gFeatureManagerp->isFeatureAvailable("RenderCubeMap"))
 	{
 		LLCubeMap* cube_map = getCubeMap();
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 57b046c08253c0cb6a33862d7aa412a0d97d8042..afe1ae6f5e1703a6babe2bdd1402588477bab786 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2066,7 +2066,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 	}
 
 	//add face to drawmap
-	std::vector<LLDrawInfo*>& draw_vec = group->mDrawMap[type];
+	LLSpatialGroup::drawmap_elem_t& draw_vec = group->mDrawMap[type];	
 
 	S32 idx = draw_vec.size()-1;
 
@@ -2091,7 +2091,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		U32 end = start + facep->getGeomCount()-1;
 		U32 offset = facep->getIndicesStart();
 		U32 count = facep->getIndicesCount();
-		LLDrawInfo* draw_info = new LLDrawInfo(start,end,count,offset,tex, 
+		LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex, 
 			facep->mVertexBuffer, fullbright, bump); 
 		draw_info->mVSize = facep->getVirtualSize();
 		draw_vec.push_back(draw_info);
@@ -2131,7 +2131,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 		U32 end = start + facep->getGeomCount()-1;
 		U32 offset = facep->getIndicesStart();
 		U32 count = facep->getIndicesCount();
-		LLDrawInfo* draw_info = new LLDrawInfo(start,end,count,offset,tex, 
+		LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex, 
 			facep->mVertexBuffer, fullbright, bump); 
 		draw_info->mVSize = facep->getVirtualSize();
 		draw_vec.push_back(draw_info);
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index 9e85e293d49ff5884767c39ceb8351da01cd5349..11f471b2464b64560cfd8e8fcc1d02c9023b1cce 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -914,7 +914,7 @@ void LLWearable::saveNewAsset()
 }
 
 // static
-void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userdata, S32 status) // StoreAssetData callback (fixed)
+void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userdata, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	LLWearableSaveData* data = (LLWearableSaveData*)userdata;
 	const char* type_name = LLWearable::typeToTypeName(data->mType);
@@ -983,3 +983,4 @@ void LLWearable::dump()
 	}
 }
 
+
diff --git a/indra/newview/llwearable.h b/indra/newview/llwearable.h
index 22572981a3491d58ed6b06c220b0c7bb543be549..1c8270e2a2e831c3eddf8f7cdde4ea8ad942ea56 100644
--- a/indra/newview/llwearable.h
+++ b/indra/newview/llwearable.h
@@ -88,7 +88,7 @@ class LLWearable
 	static LLAssetType::EType typeToAssetType( EWearableType wearable_type );
 
 	void				saveNewAsset();
-	static void			onSaveNewAssetComplete( const LLUUID& asset_uuid, void* user_data, S32 status );
+	static void			onSaveNewAssetComplete( const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status );
 
 	BOOL				isMatchedToInventoryItem( LLViewerInventoryItem* item );
 
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp
index b00decac9a863e3f2efbcb8a00c5805a4b598833..0d95442d69bbbb97534adafea0c6b6f07c50bdca 100644
--- a/indra/newview/llwearablelist.cpp
+++ b/indra/newview/llwearablelist.cpp
@@ -73,7 +73,7 @@ void LLWearableList::getAsset( const LLAssetID& assetID, const LLString& wearabl
 }
 
 // static
-void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID& uuid, void* userdata, S32 status )
+void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID& uuid, void* userdata, S32 status, LLExtStat ext_status )
 {
 	BOOL success = FALSE;
 	LLWearableArrivedData* data = (LLWearableArrivedData*) userdata;
diff --git a/indra/newview/llwearablelist.h b/indra/newview/llwearablelist.h
index 587ea9e50791fa3e7c9623c0832111abfc5679a8..cd5a479d112b98938b0263a6ed8598aa5d0bf7fe 100644
--- a/indra/newview/llwearablelist.h
+++ b/indra/newview/llwearablelist.h
@@ -39,7 +39,7 @@ class LLWearableList
 	LLWearable*			createNewWearable( EWearableType type );
 	
 	// Pseudo-private
-	static void	 	    processGetAssetReply(const char* filename, const LLAssetID& assetID, void* user_data, S32 status);
+	static void	 	    processGetAssetReply(const char* filename, const LLAssetID& assetID, void* user_data, S32 status, LLExtStat ext_status);
 
 protected:
 	LLPtrSkipMap< const LLUUID, LLWearable* > mList;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2858854a9a1c9d0c9e74d36ac61a8938576e50b6..f4c442b0ad32a2c36d37fd2922247537fc64858a 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -478,7 +478,7 @@ class LLOctreeDirtyTexture : public LLOctreeTraveler<LLDrawable>
 		{
 			for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
 			{
-				for (std::vector<LLDrawInfo*>::iterator j = i->second.begin(); j != i->second.end(); ++j)
+				for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j) 
 				{
 					LLDrawInfo* params = *j;
 					if (mTextures.find(params->mTexture) != mTextures.end())
@@ -1631,10 +1631,10 @@ void LLPipeline::postSort(LLCamera& camera)
 		}
 		for (LLSpatialGroup::draw_map_t::iterator j = group->mDrawMap.begin(); j != group->mDrawMap.end(); ++j)
 		{
-			std::vector<LLDrawInfo*>& src_vec = j->second;
-			std::vector<LLDrawInfo*>& dest_vec = mRenderMap[j->first];
+			LLSpatialGroup::drawmap_elem_t& src_vec = j->second;	
+			LLSpatialGroup::drawmap_elem_t& dest_vec = mRenderMap[j->first];  
 
-			for (std::vector<LLDrawInfo*>::iterator k = src_vec.begin(); k != src_vec.end(); ++k)
+			for (LLSpatialGroup::drawmap_elem_t::iterator k = src_vec.begin(); k != src_vec.end(); ++k) 
 			{
 				dest_vec.push_back(*k);
 			}
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 9a7336186c437214da3de88c7efdfe239cd71f0d..161a55ea529db1b912108f82245d39700deacc45 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -373,7 +373,7 @@ class LLPipeline
 	LLVector3				mSunDir;
 
 	LLSpatialGroup::sg_vector_t mActiveGroups;
-	std::vector<LLDrawInfo*> mRenderMap[LLRenderPass::NUM_RENDER_TYPES];
+	LLSpatialGroup::drawmap_elem_t mRenderMap[LLRenderPass::NUM_RENDER_TYPES];	
 	std::vector<LLSpatialGroup* > mAlphaGroups;
 	std::vector<LLSpatialGroup* > mAlphaGroupsPostWater;
 	LLSpatialGroup::sg_vector_t mVisibleGroups;
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 041dfd1b81a72d6afdb49ce543d0c35e4b4d25c4..a20ebece11c69f899f25bd59615a336a3d9afbdf 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -487,7 +487,7 @@ def construct(self):
                         self.path("libuuid.so", "libuuid.so.1")
                         self.path("libSDL-1.2.so.0")
                         self.path("libELFIO.so")
-                        #self.path("libresolv.so") - don't bundle
+                        self.path("libresolv.so", "libresolv.so.2")
                         #self.path("libtcmalloc.so.0") - bugged
                         #self.path("libstacktrace.so.0") - probably bugged
                         self.path("libllkdu.so", "../bin/libllkdu.so") # llkdu goes in bin for some reason
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 4b789e2db3eace31a2395c74f1a41d6f538e6320..4572941248b40f0a3bb3f49af4e4d3ea3bdbad2f 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -5655,10 +5655,10 @@ version 2.0
 
 // 
 // Inventory update messages 
-//
+// UDP DEPRECATED - Now a viewer capability.
 
 {
-	CopyInventoryFromNotecard Low 265 NotTrusted Zerocoded
+	CopyInventoryFromNotecard Low 265 NotTrusted Zerocoded UDPDeprecated
 	{
 		AgentData			Single
 		{	AgentID			LLUUID	}