diff --git a/indra/llaudio/llstreamingaudio_fmod.h b/indra/llaudio/llstreamingaudio_fmod.h
index 9970f0d03bc39af1ac4976ee60915f97cf687c5c..a189b548ddc88df8d6750331dfbca64fb3e6e6c8 100644
--- a/indra/llaudio/llstreamingaudio_fmod.h
+++ b/indra/llaudio/llstreamingaudio_fmod.h
@@ -30,6 +30,8 @@
 
 #include "stdtypes.h" // from llcommon
 
+#include <list>
+
 #include "llstreamingaudio.h"
 
 class LLAudioStreamManagerFMOD;
diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index 0a6a8f9fa6b4a095d404085ed4900264c0aa32d1..5138be071187cb6637cb0c7525b75c650d9b1af2 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -32,6 +32,7 @@
 
 #include "llcharacter.h"
 #include "llstring.h"
+#include "llfasttimer.h"
 
 #define SKEL_HEADER "Linden Skeleton 1.0"
 
diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h
index dc3c58cf645204c6667dfe62d403ba41e4a0c8b3..a9cde545f2b0a1013def4f8aed8b2ae385987a1e 100644
--- a/indra/llcharacter/lljoint.h
+++ b/indra/llcharacter/lljoint.h
@@ -31,6 +31,7 @@
 // Header Files
 //-----------------------------------------------------------------------------
 #include <string>
+#include <list>
 
 #include "linked_lists.h"
 #include "v3math.h"
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index 829dda999378d04735344fe25f5f50d33ed65e1f..5524bba2965be64e9df1b271b610bb07ac26dda6 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -28,8 +28,9 @@
 // Header Files
 //-----------------------------------------------------------------------------
 #include "linden_common.h"
-
 #include "llmotioncontroller.h"
+
+#include "llfasttimer.h"
 #include "llkeyframemotion.h"
 #include "llmath.h"
 #include "lltimer.h"
diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h
index 510725ffc63aaba6e567f29ebc59773fa9083c55..c77d96c1c9c29f19479a6764c6e9d01523c0a598 100644
--- a/indra/llcommon/llapr.h
+++ b/indra/llcommon/llapr.h
@@ -32,16 +32,6 @@
 #if LL_LINUX || LL_SOLARIS
 #include <sys/param.h>  // Need PATH_MAX in APR headers...
 #endif
-#if LL_WINDOWS
-	// Limit Windows API to small and manageable set.
-	// If you get undefined symbols, find the appropriate
-	// Windows header file and include that in your .cpp file.
-	#define WIN32_LEAN_AND_MEAN
-	#include <winsock2.h>
-	#include <windows.h>
-	#undef min
-	#undef max
-#endif
 
 #include <boost/noncopyable.hpp>
 
@@ -340,7 +330,7 @@ class LLThreadLocalPointer : public LLThreadLocalPointerBase
 
 
 	LLThreadLocalPointer(const LLThreadLocalPointer<T>& other)
-	:	LLThreadLocalPointerBase(other)
+		:	LLThreadLocalPointerBase(other)
 	{
 		set(other.get());		
 	}
diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp
index 5569b4102d655929a40b536c550d8a3d4344ea1e..2efe39e15831f19469609fa67f9685d08462f328 100644
--- a/indra/llcommon/lldate.cpp
+++ b/indra/llcommon/lldate.cpp
@@ -39,6 +39,7 @@
 
 #include "lltimer.h"
 #include "llstring.h"
+#include "llfasttimer.h"
 
 static const F64 DATE_EPOCH = 0.0;
 
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index cced0bdfa971f9aab2eaa0c305aaef1ea0293cd5..d007f76e5ff6221a2af10ea6d60256c697005c06 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -58,22 +58,22 @@ namespace LLTrace
 //////////////////////////////////////////////////////////////////////////////
 // statics
 
-S32 Time::sCurFrameIndex = -1;
-S32 Time::sLastFrameIndex = -1;
-U64 Time::sLastFrameTime = Time::getCPUClockCount64();
-bool Time::sPauseHistory = 0;
-bool Time::sResetHistory = 0;
-LLThreadLocalPointer<Time::CurTimerData> Time::sCurTimerData;
-bool Time::sLog = FALSE;
-std::string Time::sLogName = "";
-bool Time::sMetricLog = FALSE;
+S32 BlockTimer::sCurFrameIndex = -1;
+S32 BlockTimer::sLastFrameIndex = -1;
+U64 BlockTimer::sLastFrameTime = BlockTimer::getCPUClockCount64();
+bool BlockTimer::sPauseHistory = 0;
+bool BlockTimer::sResetHistory = 0;
+LLThreadLocalPointer<CurTimerData> BlockTimer::sCurTimerData;
+bool BlockTimer::sLog = false;
+std::string BlockTimer::sLogName = "";
+bool BlockTimer::sMetricLog = false;
 static LLMutex*			sLogLock = NULL;
 static std::queue<LLSD> sLogQueue;
 
 #if LL_LINUX || LL_SOLARIS
-U64 Time::sClockResolution = 1000000000; // Nanosecond resolution
+U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution
 #else
-U64 Time::sClockResolution = 1000000; // Microsecond resolution
+U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution
 #endif
 
 // FIXME: move these declarations to the relevant modules
@@ -114,15 +114,22 @@ BlockTimer& BlockTimer::getRootTimer()
 	return root_timer;
 }
 
+void BlockTimer::pushLog(LLSD log)
+{
+	LLMutexLock lock(sLogLock);
+
+	sLogQueue.push(log);
+}
+
 
 //static
 #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__))
-U64 Time::countsPerSecond() // counts per second for the *32-bit* timer
+U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
 {
 	return sClockResolution >> 8;
 }
 #else // windows or x86-mac or x86-linux or x86-solaris
-U64 Time::countsPerSecond() // counts per second for the *32-bit* timer
+U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
 {
 #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS
 	//getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz
@@ -225,7 +232,7 @@ S32 BlockTimer::getDepth()
 // static
 void BlockTimer::processTimes()
 {
-	if (Time::getCurFrameIndex() < 0) return;
+	if (getCurFrameIndex() < 0) return;
 
 	buildHierarchy();
 	accumulateTimings();
@@ -243,7 +250,7 @@ struct SortTimerByName
 //static
 void BlockTimer::buildHierarchy()
 {
-	if (Time::getCurFrameIndex() < 0 ) return;
+	if (getCurFrameIndex() < 0 ) return;
 
 	// set up initial tree
 	{
@@ -254,11 +261,11 @@ void BlockTimer::buildHierarchy()
 			
 			// bootstrap tree construction by attaching to last timer to be on stack
 			// when this timer was called
-			if (timer.mLastCaller && timer.mParent == &BlockTimer::getRootTimer())
+			if (timer.getPrimaryAccumulator().mLastCaller && timer.mParent == &BlockTimer::getRootTimer())
 			{
-				timer.setParent(timer.mLastCaller);
+				timer.setParent(timer.getPrimaryAccumulator().mLastCaller);
 				// no need to push up tree on first use, flag can be set spuriously
-				timer.mMoveUpTree = false;
+				timer.getPrimaryAccumulator().mMoveUpTree = false;
 			}
 		}
 	}
@@ -274,14 +281,14 @@ void BlockTimer::buildHierarchy()
 		// skip root timer
 		if (timerp == &BlockTimer::getRootTimer()) continue;
 
-		if (timerp->mMoveUpTree)
+		if (timerp->getPrimaryAccumulator().mMoveUpTree)
 		{
-			// since ancestors have already been visited, reparenting won't affect tree traversal
+			// since ancestors have already been visited, re-parenting won't affect tree traversal
 			//step up tree, bringing our descendants with us
 			LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() <<
 				" to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL;
 			timerp->setParent(timerp->getParent()->getParent());
-			timerp->mMoveUpTree = false;
+			timerp->getPrimaryAccumulator().mMoveUpTree = false;
 
 			// don't bubble up any ancestors until descendants are done bubbling up
 			it.skipAncestors();
@@ -308,21 +315,23 @@ void BlockTimer::accumulateTimings()
 	U32 cur_time = getCPUClockCount32();
 
 	// walk up stack of active timers and accumulate current time while leaving timing structures active
-	Time* cur_timer = sCurTimerData.mCurTimer;
+	Time* cur_timer = sCurTimerData->mCurTimer;
 	// root defined by parent pointing to self
-	CurTimerData* cur_data = &sCurTimerData;
+	CurTimerData* cur_data = sCurTimerData.get();
+	TimerAccumulator& accumulator = sCurTimerData->mTimerData->getPrimaryAccumulator();
 	while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer)
 	{
 		U32 cumulative_time_delta = cur_time - cur_timer->mStartTime;
 		U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime;
 		cur_data->mChildTime = 0;
-		cur_data->mTimerData->mSelfTimeCounter += self_time_delta;
-		cur_data->mTimerData->mTotalTimeCounter += cumulative_time_delta;
+		accumulator.mSelfTimeCounter += self_time_delta;
+		accumulator.mTotalTimeCounter += cumulative_time_delta;
 
 		cur_timer->mStartTime = cur_time;
 
 		cur_data = &cur_timer->mLastTimerData;
 		cur_data->mChildTime += cumulative_time_delta;
+		accumulator = cur_data->mTimerData->getPrimaryAccumulator();
 
 		cur_timer = cur_timer->mLastTimerData.mCurTimer;
 	}
@@ -333,13 +342,14 @@ void BlockTimer::accumulateTimings()
 		++it)
 	{
 		BlockTimer* timerp = (*it);
-		timerp->mTreeTimeCounter = timerp->mSelfTimeCounter;
+		TimerAccumulator& accumulator = timerp->getPrimaryAccumulator();
+		timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter;
 		for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it)
 		{
 			timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter;
 		}
 
-		S32 cur_frame = sCurFrameIndex;
+		S32 cur_frame = getCurFrameIndex();
 		if (cur_frame >= 0)
 		{
 			// update timer history
@@ -347,8 +357,8 @@ void BlockTimer::accumulateTimings()
 
 			timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter;
 			timerp->mCountAverage       = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1);
-			timerp->mCallHistory[hidx]  = timerp->mCalls;
-			timerp->mCallAverage        = ((U64)timerp->mCallAverage * cur_frame + timerp->mCalls) / (cur_frame+1);
+			timerp->mCallHistory[hidx]  = accumulator.mCalls;
+			timerp->mCallAverage        = ((U64)timerp->mCallAverage * cur_frame + accumulator.mCalls) / (cur_frame+1);
 		}
 	}
 }
@@ -377,15 +387,19 @@ void BlockTimer::resetFrame()
 		LLSD sd;
 
 		{
-			for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
+			for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), 
+					end_it = LLInstanceTracker<BlockTimer>::endInstances(); 
+				it != end_it; 
+				++it)
 			{
 				BlockTimer& timer = *it;
-				sd[timer.getName()]["Time"] = (LLSD::Real) (timer.mSelfTimeCounter*iclock_freq);	
-				sd[timer.getName()]["Calls"] = (LLSD::Integer) timer.mCalls;
+				TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
+				sd[timer.getName()]["Time"] = (LLSD::Real) (accumulator.mSelfTimeCounter*iclock_freq);	
+				sd[timer.getName()]["Calls"] = (LLSD::Integer) accumulator.mCalls;
 				
 				// computing total time here because getting the root timer's getCountHistory
 				// doesn't work correctly on the first frame
-				total_time = total_time + timer.mSelfTimeCounter * iclock_freq;
+				total_time = total_time + accumulator.mSelfTimeCounter * iclock_freq;
 			}
 		}
 
@@ -399,13 +413,17 @@ void BlockTimer::resetFrame()
 	}
 
 	// reset for next frame
-	for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
+	for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(),
+			end_it = LLInstanceTracker<BlockTimer>::endInstances();
+		it != end_it;
+		++it)
 	{
 		BlockTimer& timer = *it;
-		timer.mSelfTimeCounter = 0;
-		timer.mCalls = 0;
-		timer.mLastCaller = NULL;
-		timer.mMoveUpTree = false;
+		TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
+		accumulator.mSelfTimeCounter = 0;
+		accumulator.mCalls = 0;
+		accumulator.mLastCaller = NULL;
+		accumulator.mMoveUpTree = false;
 	}
 }
 
@@ -419,7 +437,7 @@ void BlockTimer::reset()
 	U32 cur_time = getCPUClockCount32();
 
 	// root defined by parent pointing to self
-	CurTimerData* cur_data = &sCurTimerData;
+	CurTimerData* cur_data = sCurTimerData.get();
 	Time* cur_timer = cur_data->mCurTimer;
 	while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer)
 	{
@@ -432,7 +450,10 @@ void BlockTimer::reset()
 
 	// reset all history
 	{
-		for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
+		for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), 
+				end_it = LLInstanceTracker<BlockTimer>::endInstances(); 
+			it != end_it; 
+			++it)
 		{
 			BlockTimer& timer = *it;
 			if (&timer != &BlockTimer::getRootTimer()) 
@@ -453,13 +474,13 @@ void BlockTimer::reset()
 
 U32 BlockTimer::getHistoricalCount(S32 history_index) const
 {
-	S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM;
+	S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM;
 	return mCountHistory[history_idx];
 }
 
 U32 BlockTimer::getHistoricalCalls(S32 history_index ) const
 {
-	S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM;
+	S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM;
 	return mCallHistory[history_idx];
 }
 
@@ -479,10 +500,10 @@ std::vector<BlockTimer*>& BlockTimer::getChildren()
 }
 
 //static
-void Time::nextFrame()
+void BlockTimer::nextFrame()
 {
-	countsPerSecond(); // good place to calculate clock frequency
-	U64 frame_time = getCPUClockCount64();
+	BlockTimer::countsPerSecond(); // good place to calculate clock frequency
+	U64 frame_time = BlockTimer::getCPUClockCount64();
 	if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff)
 	{
 		llinfos << "Slow frame, fast timers inaccurate" << llendl;
@@ -505,7 +526,7 @@ void Time::dumpCurTimes()
 	// accumulate timings, etc.
 	BlockTimer::processTimes();
 	
-	F64 clock_freq = (F64)countsPerSecond();
+	F64 clock_freq = (F64)BlockTimer::countsPerSecond();
 	F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds
 
 	// walk over timers in depth order and output timings
@@ -533,13 +554,6 @@ void Time::dumpCurTimes()
 	}
 }
 
-//static 
-void Time::reset()
-{
-	BlockTimer::reset();
-}
-
-
 //static
 void Time::writeLog(std::ostream& os)
 {
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index f5e6d874a2beb6956736eb64315eb5c6a7433874..69a6773b12f73c366a41d6cd5ac190ccaaf0bbe4 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -28,60 +28,77 @@
 #define LL_FASTTIMER_H
 
 #include "llinstancetracker.h"
+#include "lltrace.h"
 
 #define FAST_TIMER_ON 1
+#define LL_FASTTIMER_USE_RDTSC 1
 
 class LLMutex;
 
-#include "lltrace.h"
-
-#define LL_FASTTIMER_USE_RDTSC 1
-
 namespace LLTrace
 {
+struct CurTimerData
+{
+	class Time*			mCurTimer;
+	class BlockTimer*	mTimerData;
+	U64					mChildTime;
+};
 
 class Time
 {
 public:
+	friend class BlockTimer;
 	typedef Time self_t;
 	typedef class BlockTimer DeclareTimer;
 
-public:
 	Time(BlockTimer& timer);
 	~Time();
 
 public:
-	static bool				sLog;
-	static bool				sMetricLog;
-	static std::string		sLogName;
-	static bool 			sPauseHistory;
-	static bool 			sResetHistory;
-
-	// call this once a frame to reset timers
-	static void nextFrame();
-
 	// dumps current cumulative frame stats to log
 	// call nextFrame() to reset timers
 	static void dumpCurTimes();
 
-	// call this to reset timer hierarchy, averages, etc.
-	static void reset();
+	static void writeLog(std::ostream& os);
 
-	static U64 countsPerSecond();
-	static S32 getLastFrameIndex() { return sLastFrameIndex; }
-	static S32 getCurFrameIndex() { return sCurFrameIndex; }
+private:
 
-	static void writeLog(std::ostream& os);
+	U64				mStartTime;
+	CurTimerData	mLastTimerData;
+};
 
-	struct CurTimerData
-	{
-		Time*				mCurTimer;
-		BlockTimer*			mTimerData;
-		U64					mChildTime;
-	};
-	static LLThreadLocalPointer<CurTimerData>	sCurTimerData;
+// stores a "named" timer instance to be reused via multiple Time stack instances
+class BlockTimer 
+:	public TraceType<TimerAccumulator>,
+	public LLInstanceTracker<BlockTimer>
+{
+public:
+	BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer());
+	~BlockTimer();
 
-private:
+	enum { HISTORY_NUM = 300 };
+
+	BlockTimer* getParent() const { return mParent; }
+	void setParent(BlockTimer* parent);
+	S32 getDepth();
+
+	typedef std::vector<BlockTimer*>::const_iterator child_const_iter;
+	child_const_iter beginChildren();
+	child_const_iter endChildren();
+	std::vector<BlockTimer*>& getChildren();
+
+	void setCollapsed(bool collapsed)	{ mCollapsed = collapsed; }
+	bool getCollapsed() const			{ return mCollapsed; }
+
+	U32 getCountAverage() const { return mCountAverage; }
+	U32 getCallAverage() const	{ return mCallAverage; }
+
+	U32 getHistoricalCount(S32 history_index = 0) const;
+	U32 getHistoricalCalls(S32 history_index = 0) const;
+
+	static BlockTimer& getRootTimer();
+	static void pushLog(LLSD sd);
+	friend class Time;
 
 
 	//////////////////////////////////////////////////////////////////////////////
@@ -106,14 +123,14 @@ class Time
 	//#undef _interlockedbittestandset
 	//#undef _interlockedbittestandreset
 
-	//inline U32 Time::getCPUClockCount32()
+	//inline U32 BlockTimer::getCPUClockCount32()
 	//{
 	//	U64 time_stamp = __rdtsc();
 	//	return (U32)(time_stamp >> 8);
 	//}
 	//
 	//// return full timer value, *not* shifted by 8 bits
-	//inline U64 Time::getCPUClockCount64()
+	//inline U64 BlockTimer::getCPUClockCount64()
 	//{
 	//	return __rdtsc();
 	//}
@@ -220,64 +237,7 @@ class Time
 
 #endif
 
-	static U64	sClockResolution;
-	static S32	sCurFrameIndex;
-	static S32	sLastFrameIndex;
-	static U64	sLastFrameTime;
-
-	U64							mStartTime;
-	Time::CurTimerData	mLastTimerData;
-};
-
-struct TimerAccumulator
-{
-	void addSamples(const TimerAccumulator& other);
-	void reset(const TimerAccumulator* other);
-
-	//
-	// members
-	//
-	U64 						mSelfTimeCounter,
-								mTotalTimeCounter;
-	U32 						mCalls;
-	BlockTimer*					mLastCaller;	// used to bootstrap tree construction
-	U16							mActiveCount;	// number of timers with this ID active on stack
-	bool						mMoveUpTree;	// needs to be moved up the tree of timers at the end of frame
-};
-
-// stores a "named" timer instance to be reused via multiple Time stack instances
-class BlockTimer 
-:	public TraceType<TimerAccumulator>,
-	public LLInstanceTracker<BlockTimer>
-{
-public:
-	BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer());
-	~BlockTimer();
-
-	enum { HISTORY_NUM = 300 };
-
-	BlockTimer* getParent() const { return mParent; }
-	void setParent(BlockTimer* parent);
-	S32 getDepth();
-
-	typedef std::vector<BlockTimer*>::const_iterator child_const_iter;
-	child_const_iter beginChildren();
-	child_const_iter endChildren();
-	std::vector<BlockTimer*>& getChildren();
-
-	void setCollapsed(bool collapsed)	{ mCollapsed = collapsed; }
-	bool getCollapsed() const			{ return mCollapsed; }
-
-	U32 getCountAverage() const { return mCountAverage; }
-	U32 getCallAverage() const	{ return mCallAverage; }
-
-	U32 getHistoricalCount(S32 history_index = 0) const;
-	U32 getHistoricalCalls(S32 history_index = 0) const;
-
-	static BlockTimer& getRootTimer();
-
-private:
-	friend class Time;
+	static U64 countsPerSecond();
 
 	// recursive call to gather total time from children
 	static void accumulateTimings();
@@ -289,6 +249,12 @@ class BlockTimer
 	static void buildHierarchy();
 	static void resetFrame();
 	static void reset();
+	// call this once a frame to reset timers
+	static void nextFrame();
+	static S32 getLastFrameIndex() { return sLastFrameIndex; }
+	static S32 getCurFrameIndex() { return sCurFrameIndex; }
+
+
 
 	// sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete
 	U32 						mTreeTimeCounter; 
@@ -304,12 +270,25 @@ class BlockTimer
 	std::vector<BlockTimer*>	mChildren;
 	bool						mCollapsed;				// don't show children
 	bool						mNeedsSorting;			// sort children whenever child added
+
+	// statics
+	static std::string							sLogName;
+	static bool									sMetricLog;
+	static bool									sLog;	
+	static LLThreadLocalPointer<CurTimerData>	sCurTimerData;
+	static U64									sClockResolution;
+	static S32									sCurFrameIndex;
+	static S32									sLastFrameIndex;
+	static U64									sLastFrameTime;
+	static bool 								sPauseHistory;
+	static bool 								sResetHistory;
+
 };
 
 LL_FORCE_INLINE Time::Time(BlockTimer& timer)
 {
 #if FAST_TIMER_ON
-	mStartTime = getCPUClockCount64();
+	mStartTime = BlockTimer::getCPUClockCount64();
 
 	TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
 	accumulator.mActiveCount++;
@@ -317,7 +296,7 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer)
 	// keep current parent as long as it is active when we are
 	accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0);
 
-	CurTimerData* cur_timer_data = Time::sCurTimerData.get();
+	CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get();
 	// store top of stack
 	mLastTimerData = *cur_timer_data;
 	// push new information
@@ -330,8 +309,8 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer)
 LL_FORCE_INLINE Time::~Time()
 {
 #if FAST_TIMER_ON
-	U64 total_time = getCPUClockCount64() - mStartTime;
-	CurTimerData* cur_timer_data = Time::sCurTimerData.get();
+	U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime;
+	CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get();
 	TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator();
 	accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime;
 	accumulator.mTotalTimeCounter += total_time;
@@ -344,7 +323,7 @@ LL_FORCE_INLINE Time::~Time()
 	// we are only tracking self time, so subtract our total time delta from parents
 	mLastTimerData.mChildTime += total_time;
 
-	*sCurTimerData = mLastTimerData;
+	*BlockTimer::sCurTimerData = mLastTimerData;
 #endif
 }
 
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index c51d042a3d312d908d5c8b56cd47341ee43dad51..5917d7a420c5ddd56de0b1b4a0fab195fde59f1a 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -28,7 +28,7 @@
  */
 
 #if LL_WINDOWS
-#include <windows.h>
+#include "llwin32headerslean.h"
 #include <stdlib.h>                 // Windows errno
 #else
 #include <errno.h>
diff --git a/indra/llcommon/llfindlocale.cpp b/indra/llcommon/llfindlocale.cpp
index cd7c0c7c09da5328bc559f5ef797efadd0abbd9d..f019bd0c647f675bba5c3fbfd57d499812189dfc 100644
--- a/indra/llcommon/llfindlocale.cpp
+++ b/indra/llcommon/llfindlocale.cpp
@@ -33,7 +33,7 @@
 #include <ctype.h>
 
 #ifdef WIN32
-#include <windows.h>
+#include "llwin32headers.h"
 #include <winnt.h>
 #endif
 
diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp
index 32d4eec607924096f5d5833c044526c7a4de886a..d72e10d2fa8e46f2a6ed06957e0eabd9df62208b 100644
--- a/indra/llcommon/llinitparam.cpp
+++ b/indra/llcommon/llinitparam.cpp
@@ -28,6 +28,7 @@
 #include "linden_common.h"
 
 #include "llinitparam.h"
+#include "llformat.h"
 
 
 namespace LLInitParam
diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h
index 3d4e4331c0e3de207124a5194828b168469d4788..502f93cbb8684b5c8af626487472e8c5044af559 100644
--- a/indra/llcommon/llinitparam.h
+++ b/indra/llcommon/llinitparam.h
@@ -29,6 +29,7 @@
 #define LL_LLPARAM_H
 
 #include <vector>
+#include <list>
 #include <boost/function.hpp>
 #include <boost/type_traits/is_convertible.hpp>
 #include <boost/unordered_map.hpp>
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index afaf36666876aac84354637155364afd3f355e4d..7c4ab6cf98119d7fafdd5cead932037813b9ecba 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -32,7 +32,6 @@
 //#endif
 
 #if defined(LL_WINDOWS)
-//# include <windows.h>
 # include <psapi.h>
 #elif defined(LL_DARWIN)
 # include <sys/types.h>
diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp
index a1b0a684c5c86faf89d967bcc6a4a15f7896f711..43d98be47b32696db9630164bd1939cadbfe0c5c 100644
--- a/indra/llcommon/llmetricperformancetester.cpp
+++ b/indra/llcommon/llmetricperformancetester.cpp
@@ -31,6 +31,7 @@
 #include "llsdserialize.h"
 #include "lltreeiterators.h"
 #include "llmetricperformancetester.h"
+#include "llfasttimer.h"
 
 //----------------------------------------------------------------------------------------------
 // LLMetricPerformanceTesterBasic : static methods and testers management
@@ -90,7 +91,7 @@ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::s
 // Return TRUE if this metric is requested or if the general default "catch all" metric is requested
 BOOL LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name)
 {
-	return (LLFastTimer::sMetricLog && ((LLFastTimer::sLogName == name) || (LLFastTimer::sLogName == DEFAULT_METRIC_NAME)));
+	return (LLTrace::BlockTimer::sMetricLog && ((LLTrace::BlockTimer::sLogName == name) || (LLTrace::BlockTimer::sLogName == DEFAULT_METRIC_NAME)));
 }
 
 /*static*/ 
@@ -193,8 +194,7 @@ void LLMetricPerformanceTesterBasic::preOutputTestResults(LLSD* sd)
 
 void LLMetricPerformanceTesterBasic::postOutputTestResults(LLSD* sd)
 {
-	LLMutexLock lock(LLFastTimer::sLogLock);
-	LLFastTimer::sLogQueue.push((*sd));
+	LLTrace::BlockTimer::pushLog(*sd);
 }
 
 void LLMetricPerformanceTesterBasic::outputTestResults() 
diff --git a/indra/llcommon/llmortician.h b/indra/llcommon/llmortician.h
index 319955ef9377acb172cddf1c7c1286800b0c46fb..9517e2db5e2eabb1424f7d87f637f20bb50b311d 100644
--- a/indra/llcommon/llmortician.h
+++ b/indra/llcommon/llmortician.h
@@ -28,6 +28,7 @@
 #define LLMORTICIAN_H
 
 #include "stdtypes.h"
+#include <list>
 
 class LL_COMMON_API LLMortician 
 {
diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h
index d711ce2f743c98c18b1727937710b2e46d622163..2fe084afcdc722a71de57f11b68d758daa5d899f 100644
--- a/indra/llcommon/llprocess.h
+++ b/indra/llcommon/llprocess.h
@@ -38,8 +38,7 @@
 #include <stdexcept>
 
 #if LL_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>                // HANDLE (eye roll)
+#include "llwin32headerslean.h"	// for HANDLE
 #elif LL_LINUX
 #if defined(Status)
 #undef Status
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 87a5930c14bb70e995066d61b52b300310b9e854..6fe53396ca1ff0d8ef40a3ad3c0eb1e977d3eff9 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -32,9 +32,7 @@
 //#include <memory>
 
 #if LL_WINDOWS
-#	define WIN32_LEAN_AND_MEAN
-#	include <winsock2.h>
-#	include <windows.h>
+#	include "llwin32headerslean.h"
 #	define _interlockedbittestandset _renamed_interlockedbittestandset
 #	define _interlockedbittestandreset _renamed_interlockedbittestandreset
 #	include <intrin.h>
diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h
index 1181c2d4339352826dcda469550d9113636cff86..7cfc265c628b3346928f595a734b04d0ebed5213 100644
--- a/indra/llcommon/llsdparam.h
+++ b/indra/llcommon/llsdparam.h
@@ -30,6 +30,7 @@
 
 #include "llinitparam.h"
 #include "boost/function.hpp"
+#include "llfasttimer.h"
 
 struct LL_COMMON_API LLParamSDParserUtilities
 {
diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp
index ccd7ef91c2ed54d97bed8ddd971827c58fbe49c5..e0e905638079cad672f6e3adf61e7d81a0316a41 100644
--- a/indra/llcommon/llstacktrace.cpp
+++ b/indra/llcommon/llstacktrace.cpp
@@ -32,7 +32,7 @@
 #include <iostream>
 #include <sstream>
 
-#include "windows.h"
+#include "llwin32headerslean.h"
 #include "Dbghelp.h"
 
 typedef USHORT NTAPI RtlCaptureStackBackTrace_Function(
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index fa0eb9f72c7a501b92bf26d6c2accc25d9993138..9600928ad5ebf3232594fd1b97ba570959cc8a2b 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -28,11 +28,10 @@
 
 #include "llstring.h"
 #include "llerror.h"
+#include "llfasttimer.h"
 
 #if LL_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
+#include "llwin32headerslean.h"
 #include <winnls.h> // for WideCharToMultiByte
 #endif
 
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 119efc795755ced045686dd04edab1387ac42260..9d81ac25dd5e6a349afffdaf66c9cb1c74d6d509 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -31,8 +31,9 @@
 #include <cstdio>
 #include <locale>
 #include <iomanip>
+#include <algorithm>
 #include "llsd.h"
-#include "llfasttimer.h"
+#include "llformat.h"
 
 #if LL_LINUX || LL_SOLARIS
 #include <wctype.h>
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 6073bcd0a6cc8713b0d2bdbe6be3635c1be57b6c..00b72ce1d82bfcbb819042bb337e0d2bfad638be 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -42,6 +42,7 @@
 #include "llprocessor.h"
 #include "llerrorcontrol.h"
 #include "llevents.h"
+#include "llformat.h"
 #include "lltimer.h"
 #include "llsdserialize.h"
 #include "llsdutil.h"
@@ -58,9 +59,7 @@
 using namespace llsd;
 
 #if LL_WINDOWS
-#	define WIN32_LEAN_AND_MEAN
-#	include <winsock2.h>
-#	include <windows.h>
+#	include "llwin32headerslean.h"
 #   include <psapi.h>               // GetPerformanceInfo() et al.
 #elif LL_DARWIN
 #	include <errno.h>
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index 23cebf4336783a8b9d5f5362b3dbf06eea91bca5..26063beff08d36f7a0253731ee1117378d261e98 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -31,11 +31,9 @@
 #include "u64.h"
 
 #if LL_WINDOWS
-#	define WIN32_LEAN_AND_MEAN
-#	include <winsock2.h>
-#	include <windows.h>
+#	include "llwin32headerslean.h"
 #elif LL_LINUX || LL_SOLARIS || LL_DARWIN
-#       include <errno.h>
+#   include <errno.h>
 #	include <sys/time.h>
 #else 
 #	error "architecture not supported"
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index afb175c3984e6f9bd82d8f3fb591cdccdc29caa8..9346aa7a45ca98a38ea73e3d3feb5f2d858f4f34 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -38,15 +38,15 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL;
 void init()
 {
 	gMasterThreadRecorder = new MasterThreadRecorder();
-	Time::sCurTimerData = new Time::CurTimerData();
+	BlockTimer::sCurTimerData = new CurTimerData();
 }
 
 void cleanup()
 {
 	delete gMasterThreadRecorder;
 	gMasterThreadRecorder = NULL;
-	delete Time::sCurTimerData.get();
-	Time::sCurTimerData = NULL;
+	delete BlockTimer::sCurTimerData.get();
+	BlockTimer::sCurTimerData = NULL;
 }
 
 MasterThreadRecorder& getMasterThreadRecorder()
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index fb9dca5e84141d9a87e7a13e421871b4bba3fc58..61fed6e7b814f15a59c4007e3a98edc9276e4ded 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -235,8 +235,8 @@ namespace LLTrace
 
 		MeasurementAccumulator()
 		:	mSum(0),
-			mMin(std::numeric_limits<T>::max()),
-			mMax(std::numeric_limits<T>::min()),
+			mMin((std::numeric_limits<T>::max)()),
+			mMax((std::numeric_limits<T>::min)()),
 			mMean(0),
 			mVarianceSum(0),
 			mNumSamples(0),
@@ -380,6 +380,24 @@ namespace LLTrace
 		U32	mNumSamples;
 	};
 
+	class TimerAccumulator
+	{
+	public:
+		void addSamples(const TimerAccumulator& other);
+		void reset(const TimerAccumulator* other);
+
+		//
+		// members
+		//
+		U64 						mSelfTimeCounter,
+									mTotalTimeCounter;
+		U32 						mCalls;
+		class BlockTimer*			mLastCaller;	// used to bootstrap tree construction
+		U16							mActiveCount;	// number of timers with this ID active on stack
+		bool						mMoveUpTree;	// needs to be moved up the tree of timers at the end of frame
+	};
+
+
 	template <typename T = F64>
 	class Measurement
 	:	public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index 4dcadfdf296bf29efc67500fb43238d994847f71..efc54d240fbdbec262ced2d722d3c266eb5c45b3 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -273,7 +273,7 @@ namespace LLTrace
 		template <typename T>
 		typename T getPeriodMin(const TraceType<CountAccumulator<T> >& stat) const
 		{
-			T min_val = std::numeric_limits<T>::max();
+			T min_val = (std::numeric_limits<T>::max)();
 			for (S32 i = 0; i < mNumPeriods; i++)
 			{
 				min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat));
@@ -284,7 +284,7 @@ namespace LLTrace
 		template <typename T>
 		F64 getPeriodMinPerSec(const TraceType<CountAccumulator<T> >& stat) const
 		{
-			F64 min_val = std::numeric_limits<F64>::max();
+			F64 min_val = (std::numeric_limits<F64>::max)();
 			for (S32 i = 0; i < mNumPeriods; i++)
 			{
 				min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat));
@@ -295,7 +295,7 @@ namespace LLTrace
 		template <typename T>
 		T getPeriodMax(const TraceType<CountAccumulator<T> >& stat) const
 		{
-			T max_val = std::numeric_limits<T>::min();
+			T max_val = (std::numeric_limits<T>::min)();
 			for (S32 i = 0; i < mNumPeriods; i++)
 			{
 				max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat));
@@ -306,7 +306,7 @@ namespace LLTrace
 		template <typename T>
 		F64 getPeriodMaxPerSec(const TraceType<CountAccumulator<T> >& stat) const
 		{
-			F64 max_val = std::numeric_limits<F64>::min();
+			F64 max_val = (std::numeric_limits<F64>::min)();
 			for (S32 i = 0; i < mNumPeriods; i++)
 			{
 				max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat));
diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp
index 5a6ff14f9736b6b77262036fdb1b36aef10402ac..0f111aab59da2bba9cd352321ba5cc4ddfcc77fd 100644
--- a/indra/llcommon/lltracethreadrecorder.cpp
+++ b/indra/llcommon/lltracethreadrecorder.cpp
@@ -26,6 +26,7 @@
 #include "linden_common.h"
 
 #include "lltracethreadrecorder.h"
+#include "llfasttimer.h"
 
 namespace LLTrace
 {
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index 4ac2197c11d4e279978fd8174b7c92ebe99e7491..1fe492fdce43c10432b6d3345d9cf3a1734f0fcb 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -33,18 +33,12 @@
 namespace LLUnits
 {
 
-template<typename T, typename IS_UNIT = void>
+template<typename T>
 struct HighestPrecisionType
 {
 	typedef T type_t;
 };
 
-template<typename T>
-struct HighestPrecisionType<T, typename T::is_unit_tag_t>
-{
-	typedef typename HighestPrecisionType<typename T::storage_t>::type_t type_t;
-};
-
 template<> struct HighestPrecisionType<F32> { typedef F64 type_t; };
 template<> struct HighestPrecisionType<S32> { typedef S64 type_t; };
 template<> struct HighestPrecisionType<U32> { typedef S64 type_t; };
@@ -78,7 +72,6 @@ struct LLUnit
 {
 	typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t;
 	typedef typename STORAGE_TYPE storage_t;
-	typedef void is_unit_tag_t;
 
 	LLUnit(storage_t value = storage_t())
 	:	mValue(value)
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index db8c9c85ab52f742c5bb9131589ca42045c85e3b..83ed987d305e908d3affd6f3556d3fd1255b2a14 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -27,9 +27,7 @@
 
 // We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
 #if LL_WINDOWS
-#undef WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
+#include "llwin32headers.h"
 // ugh, this is ugly.  We need to straighten out our linking for this library
 #pragma comment(lib, "IPHLPAPI.lib")
 #include <iphlpapi.h>
diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h
new file mode 100644
index 0000000000000000000000000000000000000000..80fd2e1768e793b2cca7fda88af5f7701f7e4be6
--- /dev/null
+++ b/indra/llcommon/llwin32headers.h
@@ -0,0 +1,38 @@
+/** 
+ * @file llwindows.h
+ * @brief sanitized include of windows header files
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLWINDOWS_H
+#define LL_LLWINDOWS_H
+
+#ifdef LL_WINDOWS
+#define NOMINMAX
+#undef WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+#include <windows.h>
+#undef NOMINMAX
+#endif
+
+#endif
diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab6e9c09e26d3b6d1d401fdbc1dceff1bb56f776
--- /dev/null
+++ b/indra/llcommon/llwin32headerslean.h
@@ -0,0 +1,37 @@
+/** 
+ * @file llwindows.h
+ * @brief sanitized include of windows header files
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLWINDOWS_H
+#define LL_LLWINDOWS_H
+
+#ifdef LL_WINDOWS
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#endif
diff --git a/indra/llinventory/lleconomy.h b/indra/llinventory/lleconomy.h
index eb2ecf71ba41b70aaa905cbe7e99138688dbf869..47fcf688a26d66e9b61b70f119288d1ceb5c5303 100644
--- a/indra/llinventory/lleconomy.h
+++ b/indra/llinventory/lleconomy.h
@@ -27,6 +27,7 @@
 #define LL_LLECONOMY_H
 
 #include "llsingleton.h"
+#include <list>
 
 class LLMessageSystem;
 class LLVector3;
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index fbf23bc3f09a760eee88c85f29cf41df9a1a5352..43aa2ab799ead08dfbfb788426b54bf279a72339 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -28,6 +28,7 @@
 #include "llinventory.h"
 
 #include "lldbstrings.h"
+#include "llfasttimer.h"
 #include "llinventorydefines.h"
 #include "llxorcipher.h"
 #include "llsd.h"
diff --git a/indra/llmessage/llfiltersd2xmlrpc.cpp b/indra/llmessage/llfiltersd2xmlrpc.cpp
index e0ca056a5f698afb11ad860f0be48c2e291cc0a4..dbb8c4e28dfecef359f1a084707fe5cb397240ed 100644
--- a/indra/llmessage/llfiltersd2xmlrpc.cpp
+++ b/indra/llmessage/llfiltersd2xmlrpc.cpp
@@ -80,6 +80,7 @@
 
 #include "llbuffer.h"
 #include "llbufferstream.h"
+#include "llfasttimer.h"
 #include "llmemorystream.h"
 #include "llsd.h"
 #include "llsdserialize.h"
diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp
index 1236fc8b71c917c30a37bfdd7d9f3274241172d7..f9d37b2e3974fdfffcf54af882492763b3125ea1 100644
--- a/indra/llmessage/lliohttpserver.cpp
+++ b/indra/llmessage/lliohttpserver.cpp
@@ -33,6 +33,7 @@
 #include "llapr.h"
 #include "llbuffer.h"
 #include "llbufferstream.h"
+#include "llfasttimer.h"
 #include "llhttpnode.h"
 #include "lliopipe.h"
 #include "lliosocket.h"
diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp
index 0287026659a1b4406356a4cecfd5592a0e2e31b9..1383d37f4185ac264a0b1a94c2d890dfb7543077 100644
--- a/indra/llmessage/lliosocket.cpp
+++ b/indra/llmessage/lliosocket.cpp
@@ -32,6 +32,7 @@
 #include "llapr.h"
 
 #include "llbuffer.h"
+#include "llfasttimer.h"
 #include "llhost.h"
 #include "llpumpio.h"
 
diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h
index be0f7dfcc655e1e47ac2ccdf8f967037ac4458a8..4e07963af85151f5b4a56853624e292272adcc16 100644
--- a/indra/llmessage/lliosocket.h
+++ b/indra/llmessage/lliosocket.h
@@ -39,6 +39,7 @@
 
 #include "lliopipe.h"
 #include "apr_pools.h"
+#include "llwin32headerslean.h"
 #include "apr_network_io.h"
 #include "llchainio.h"
 
diff --git a/indra/llmessage/llioutil.cpp b/indra/llmessage/llioutil.cpp
index 8c50fd50693a1e62ab70d57c8649465d2ebecd21..9fd49d23d486d4dd8de78cfc9d59b301f07b837e 100644
--- a/indra/llmessage/llioutil.cpp
+++ b/indra/llmessage/llioutil.cpp
@@ -28,6 +28,7 @@
 
 #include "linden_common.h"
 #include "llioutil.h"
+#include "llfasttimer.h"
 
 /**
  * LLIOFlush
diff --git a/indra/llmessage/llmail.cpp b/indra/llmessage/llmail.cpp
index 08b31e9c7a29b45cdc61fde26fd5a79a25fba74d..dc27f2ca4acb6247c709ae199de192ba463880e2 100644
--- a/indra/llmessage/llmail.cpp
+++ b/indra/llmessage/llmail.cpp
@@ -29,12 +29,7 @@
 #include "llmail.h"
 
 // APR on Windows needs full windows headers
-#ifdef LL_WINDOWS
-#	undef WIN32_LEAN_AND_MEAN
-#	include <winsock2.h>
-#	include <windows.h>
-#endif
-
+#include "llwin32headers.h"
 #include <string>
 #include <sstream>
 
diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp
index 0623e99f0aad069598e0c0e1439df0f81981e8ab..e3f09f34eedd25e8465d042fb48e4214bae7f960 100644
--- a/indra/llmessage/llpumpio.cpp
+++ b/indra/llmessage/llpumpio.cpp
@@ -34,6 +34,7 @@
 #include "apr_poll.h"
 
 #include "llapr.h"
+#include "llfasttimer.h"
 #include "llstl.h"
 
 // These should not be enabled in production, but they can be
diff --git a/indra/llmessage/llsdrpcclient.cpp b/indra/llmessage/llsdrpcclient.cpp
index fcda0e81a3d59de6eddc8e509cbe5296fff51516..05b27f582c19a4b7edb0b51d66bdfa79da1f86e9 100644
--- a/indra/llmessage/llsdrpcclient.cpp
+++ b/indra/llmessage/llsdrpcclient.cpp
@@ -30,6 +30,7 @@
 #include "llsdrpcclient.h"
 
 #include "llbufferstream.h"
+#include "llfasttimer.h"
 #include "llfiltersd2xmlrpc.h"
 #include "llpumpio.h"
 #include "llsd.h"
diff --git a/indra/llmessage/llsdrpcserver.cpp b/indra/llmessage/llsdrpcserver.cpp
index f26ee52f7187112a5c5eaa72951e11eb554ea82d..2c233c1c0d0640274e844951997a13b7f6c3e371 100644
--- a/indra/llmessage/llsdrpcserver.cpp
+++ b/indra/llmessage/llsdrpcserver.cpp
@@ -31,6 +31,7 @@
 
 #include "llbuffer.h"
 #include "llbufferstream.h"
+#include "llfasttimer.h"
 #include "llpumpio.h"
 #include "llsdserialize.h"
 #include "llstl.h"
diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp
index 5831c3c1c1ff25872e24ae7e4de4bb106fe86d7d..982f4804f0f28aecf8b504928fa7672b28f2c652 100644
--- a/indra/llmessage/llurlrequest.cpp
+++ b/indra/llmessage/llurlrequest.cpp
@@ -33,6 +33,7 @@
 #include <openssl/x509_vfy.h>
 #include <openssl/ssl.h>
 #include "llcurl.h"
+#include "llfasttimer.h"
 #include "llioutil.h"
 #include "llproxy.h"
 #include "llpumpio.h"
diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp
index 85aef5da003c2bfb3e40c4f567b73a3c2665fbf7..6f8508ee8c4520c3826abe9d62c81ad439b14e13 100644
--- a/indra/llmessage/net.cpp
+++ b/indra/llmessage/net.cpp
@@ -32,9 +32,7 @@
 #include <stdexcept>
 
 #if LL_WINDOWS
-	#define WIN32_LEAN_AND_MEAN
-	#include <winsock2.h>
-	#include <windows.h>
+#include "llwin32headerslean.h"
 #else
 	#include <sys/types.h>
 	#include <sys/socket.h>
diff --git a/indra/llplugin/llpluginprocesschild.h b/indra/llplugin/llpluginprocesschild.h
index a9d6794e4037393701250a04cb36185d3d3ca46a..531422e792f7f840d24f718f57c5a04b08c56b01 100644
--- a/indra/llplugin/llpluginprocesschild.h
+++ b/indra/llplugin/llpluginprocesschild.h
@@ -29,6 +29,7 @@
 #ifndef LL_LLPLUGINPROCESSCHILD_H
 #define LL_LLPLUGINPROCESSCHILD_H
 
+#include <queue>
 #include "llpluginmessage.h"
 #include "llpluginmessagepipe.h"
 #include "llplugininstance.h"
diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h
index 990fc5cbae3226503ca1f9278dbc291716511315..24be7eb148d4de936030eb3e4cc5413de58d1b77 100644
--- a/indra/llplugin/llpluginprocessparent.h
+++ b/indra/llplugin/llpluginprocessparent.h
@@ -29,6 +29,8 @@
 #ifndef LL_LLPLUGINPROCESSPARENT_H
 #define LL_LLPLUGINPROCESSPARENT_H
 
+#include <queue>
+
 #include "llapr.h"
 #include "llprocess.h"
 #include "llpluginmessage.h"
diff --git a/indra/llplugin/tests/llplugincookiestore_test.cpp b/indra/llplugin/tests/llplugincookiestore_test.cpp
index aefa1ca1444b8b10985b17deaaa051cbf9c0d22c..c2cb236cbabebcf0845f35def9a4b5e13caa80fb 100644
--- a/indra/llplugin/tests/llplugincookiestore_test.cpp
+++ b/indra/llplugin/tests/llplugincookiestore_test.cpp
@@ -27,6 +27,7 @@
  */
 
 #include "linden_common.h"
+#include <list>
 #include "../test/lltut.h"
 
 #include "../llplugincookiestore.h"
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 4dc2fcd7146d9e3f60474dcf803f2402de93acc7..d2d929fbf90b8705dd97a697c60d04cf1cd3b913 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -29,6 +29,7 @@
 #include "llfontgl.h"
 
 // Linden library includes
+#include "llfasttimer.h"
 #include "llfontfreetype.h"
 #include "llfontbitmapcache.h"
 #include "llfontregistry.h"
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h
index 605b424b354db0c079454c028e8355e2235690ce..c9ce0d55883bb3a27209bc690722dcd6c8ca9663 100644
--- a/indra/llrender/llglheaders.h
+++ b/indra/llrender/llglheaders.h
@@ -540,11 +540,7 @@ extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
 // LL_WINDOWS
 
 // windows gl headers depend on things like APIENTRY, so include windows.
-#define WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
-#undef min
-#undef max
+#include "llwin32headerslean.h"
 
 //----------------------------------------------------------------------------
 #include <GL/gl.h>
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 5361d8e7bebd118a16cd5cd917c58d8c44373c54..751309af2007c9222c17d9c116b6b46e08df36a6 100755
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -32,6 +32,7 @@
 #include "llimagegl.h"
 
 #include "llerror.h"
+#include "llfasttimer.h"
 #include "llimage.h"
 
 #include "llmath.h"
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 11b2681e52d36a2d06b82c32984210a287c33a45..45baf641fb364935da5a21e6fa5e7dd43f341615 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -26,7 +26,7 @@
 
 #include "linden_common.h"
 
-#include <boost/static_assert.hpp>
+#include "llfasttimer.h"
 #include "llsys.h"
 #include "llvertexbuffer.h"
 // #include "llrender.h"
diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h
index a1e1f8a98835ffa6bd8fd257a8a5799268b5e6ce..e3b17dcb4fc7507e8846984b61027732275bb0f4 100644
--- a/indra/llui/llfloaterreg.h
+++ b/indra/llui/llfloaterreg.h
@@ -30,6 +30,7 @@
 #include "llrect.h"
 #include "llsd.h"
 
+#include <list>
 #include <boost/function.hpp>
 
 //*******************************************************
diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h
index 17c9c09cb26bf044b25009a0979e4d0be6a250bf..c366fd65db9ca6af1bee94895f4049d896239587 100644
--- a/indra/llui/llstatbar.h
+++ b/indra/llui/llstatbar.h
@@ -100,10 +100,10 @@ class LLStatBar : public LLView
 	BOOL mDisplayHistory;
 	BOOL mDisplayMean;			// If true, display mean, if false, display current value
 
-	LLTrace::TraceType<CountAccumulator<F64> >* mCountFloatp;
-	LLTrace::TraceType<CountAccumulator<S64> >* mCountIntp;
-	LLTrace::TraceType<MeasurementAccumulator<F64> >* mMeasurementFloatp;
-	LLTrace::TraceType<MeasurementAccumulator<S64> >* mMeasurementIntp;
+	LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* mCountFloatp;
+	LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* mCountIntp;
+	LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* mMeasurementFloatp;
+	LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* mMeasurementIntp;
 
 	LLFrameTimer mUpdateTimer;
 	LLUIString mLabel;
diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h
index 09b34c235826a7ec8a273edb22d78e0a9e588812..57856ff6f2a57cd72138b5d9f4fb6d6af6dc908c 100644
--- a/indra/llui/llstatgraph.h
+++ b/indra/llui/llstatgraph.h
@@ -57,10 +57,10 @@ class LLStatGraph : public LLView
 
 	struct StatParams : public LLInitParam::ChoiceBlock<StatParams>
 	{
-		Alternative<LLTrace::TraceType<CountAccumulator<F64> >* >		count_stat_float;
-		Alternative<LLTrace::TraceType<CountAccumulator<S64> >* >		count_stat_int;
-		Alternative<LLTrace::TraceType<MeasurementAccumulator<F64> >* >	measurement_stat_float;
-		Alternative<LLTrace::TraceType<MeasurementAccumulator<S64> >* >	measurement_stat_int;
+		Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* >		count_stat_float;
+		Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* >		count_stat_int;
+		Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* >	measurement_stat_float;
+		Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* >	measurement_stat_int;
 	};
 
 	struct Params : public LLInitParam::Block<Params, LLView::Params>
@@ -105,8 +105,8 @@ class LLStatGraph : public LLView
 	/*virtual*/ void setValue(const LLSD& value);
 	
 private:
-	LLTrace::count_common_float_t*	mNewStatFloatp;
-	LLTrace::count_common_int_t*	mNewStatIntp;
+	LLTrace::TraceType<LLTrace::CountAccumulator<F64> >*	mNewStatFloatp;
+	LLTrace::TraceType<LLTrace::CountAccumulator<S64> >*	mNewStatIntp;
 
 	BOOL mPerSec;
 
diff --git a/indra/llui/lluistring.cpp b/indra/llui/lluistring.cpp
index c4e073ccdb9cb9892a7fe502a4d56daaca8f8b1b..23fc53ea885ff5833e1793e7e6c176eaea4dcc59 100644
--- a/indra/llui/lluistring.cpp
+++ b/indra/llui/lluistring.cpp
@@ -26,6 +26,8 @@
 
 #include "linden_common.h"
 #include "lluistring.h"
+
+#include "llfasttimer.h"
 #include "llsd.h"
 #include "lltrans.h"
 
diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp
index 0c91390bc15c2c33bea775e28a17ed987b89d329..903f10ce108dcd8c1f07243d4a965ca267168e19 100644
--- a/indra/llui/llxuiparser.cpp
+++ b/indra/llui/llxuiparser.cpp
@@ -29,7 +29,7 @@
 #include "llxuiparser.h"
 
 #include "llxmlnode.h"
-
+#include "llfasttimer.h"
 #ifdef LL_STANDALONE
 #include <expat.h>
 #else
diff --git a/indra/llvfs/llpidlock.cpp b/indra/llvfs/llpidlock.cpp
index 0424f2379e04888139456af47fbb30e1620677fd..3b83d1b9e3e9edab5f97e4d312e8fd5dbc1e49a1 100644
--- a/indra/llvfs/llpidlock.cpp
+++ b/indra/llvfs/llpidlock.cpp
@@ -36,7 +36,7 @@
 
 #if LL_WINDOWS   //For windows platform.
 
-#include <windows.h>
+#include "llwin32headerslean.h"
 
 namespace {
 	inline DWORD getpid() {
diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp
index 7f631ef0bbb91fc41cd5c4f51d1c5f220f81f86b..d3f5673485e2b36d8a33048e2825a6902814bfed 100644
--- a/indra/llvfs/llvfile.cpp
+++ b/indra/llvfs/llvfile.cpp
@@ -32,6 +32,7 @@
 #include "llthread.h"
 #include "llvfs.h"
 #include "lltimer.h"
+#include "llfasttimer.h"
 
 const S32 LLVFile::READ			= 0x00000001;
 const S32 LLVFile::WRITE		= 0x00000002;
diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h
index c155c1b3626092c2b3a738ab08dd4a6afa9dea2c..276074d4cadd8a7aa4e3db4019b738d0d13337de 100644
--- a/indra/llwindow/llkeyboard.h
+++ b/indra/llwindow/llkeyboard.h
@@ -28,6 +28,7 @@
 #define LL_LLKEYBOARD_H
 
 #include <map>
+#include <boost/function.hpp>
 
 #include "string_table.h"
 #include "lltimer.h"
diff --git a/indra/llwindow/llkeyboardwin32.cpp b/indra/llwindow/llkeyboardwin32.cpp
index be3fe5deb056426b8ce852cba1443cf9c77e42bd..b76d526c5a2ab46cc60d40ea11530d9170bd1028 100644
--- a/indra/llwindow/llkeyboardwin32.cpp
+++ b/indra/llwindow/llkeyboardwin32.cpp
@@ -28,10 +28,7 @@
 
 #include "linden_common.h"
 
-#define WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
-
+#include "llwin32headerslean.h"
 #include "llkeyboardwin32.h"
 
 #include "llwindowcallbacks.h"
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index 4da87f4e068d64d90f5d039b8e9f3ca0fe890db5..f378203a88e9a7077d5de8c9f2789b4d68135810 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -31,6 +31,7 @@
 #include "llcoord.h"
 #include "llstring.h"
 #include "llcursortypes.h"
+#include "llinstancetracker.h"
 #include "llsd.h"
 
 class LLSplashScreen;
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 43c0090993ee7774b352350c65df3abd6ff10a6f..6d887926fae97985aaef9c7ba17ab96fe535cecd 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -38,6 +38,7 @@
 
 // Linden library includes
 #include "llerror.h"
+#include "llfasttimer.h"
 #include "llgl.h"
 #include "llstring.h"
 #include "lldir.h"
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index 54c9ac4d4d182fd52349e67caeaf56fa92999b5c..169d264808d18677a807a5520e82783eeab7e750 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -28,9 +28,7 @@
 #define LL_LLWINDOWWIN32_H
 
 // Limit Windows API to small and manageable set.
-#define WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-#include <windows.h>
+#include "llwin32headerslean.h"
 
 #include "llwindow.h"
 #include "llwindowcallbacks.h"
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ac659c409b87204653c21bd788c2783c4e0f113b..c6ed8d5071cfd034f214eeabdbd9b02081045a0a 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -679,7 +679,7 @@ bool LLAppViewer::init()
 	// into the log files during normal startup until AFTER
 	// we run the "program crashed last time" error handler below.
 	//
-	LLFastTimer::reset();
+	LLTrace::BlockTimer::reset();
 
 	// initialize SSE options
 	LLVector4a::initClass();
@@ -1222,7 +1222,7 @@ bool LLAppViewer::mainLoop()
 	while (!LLApp::isExiting())
 	{
 		LLFastTimer _(FTM_FRAME);
-		LLFastTimer::nextFrame(); 
+		LLTrace::BlockTimer::nextFrame(); 
 		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
 
 		//clear call stack records
@@ -1552,9 +1552,9 @@ bool LLAppViewer::cleanup()
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
 		llinfos << "Analyzing performance" << llendl;
-		std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
-		std::string current_name  = LLFastTimer::sLogName + ".slp"; 
-		std::string report_name   = LLFastTimer::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -1900,9 +1900,9 @@ bool LLAppViewer::cleanup()
 	{
 		llinfos << "Analyzing performance" << llendl;
 		
-		std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
-		std::string current_name  = LLFastTimer::sLogName + ".slp"; 
-		std::string report_name   = LLFastTimer::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -2031,10 +2031,10 @@ bool LLAppViewer::initThreads()
 													enable_threads && true,
 													app_metrics_qa_mode);	
 
-	if (LLFastTimer::sLog || LLFastTimer::sMetricLog)
+	if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog)
 	{
-		LLFastTimer::sLogLock = new LLMutex(NULL);
-		mFastTimerLogThread = new LLFastTimerLogThread(LLFastTimer::sLogName);
+		LLTrace::BlockTimer::sLogLock = new LLMutex(NULL);
+		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName);
 		mFastTimerLogThread->start();
 	}
 
@@ -2445,13 +2445,13 @@ bool LLAppViewer::initConfiguration()
 
 	if (clp.hasOption("logperformance"))
 	{
-		LLFastTimer::sLog = TRUE;
-		LLFastTimer::sLogName = std::string("performance");		
+		LLTrace::BlockTimer::sLog = true;
+		LLTrace::BlockTimer::sLogName = std::string("performance");		
 	}
 	
 	if (clp.hasOption("logmetrics"))
  	{
- 		LLFastTimer::sMetricLog = TRUE ;
+ 		LLTrace::BlockTimer::sMetricLog = true ;
 		// '--logmetrics' can be specified with a named test metric argument so the data gathering is done only on that test
 		// In the absence of argument, every metric is gathered (makes for a rather slow run and hard to decipher report...)
 		std::string test_name = clp.getOption("logmetrics")[0];
@@ -2459,11 +2459,11 @@ bool LLAppViewer::initConfiguration()
 		if (test_name == "")
 		{
 			llwarns << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << llendl;
-			LLFastTimer::sLogName = DEFAULT_METRIC_NAME;
+			LLTrace::BlockTimer::sLogName = DEFAULT_METRIC_NAME;
 		}
 		else
 		{
-			LLFastTimer::sLogName = test_name;
+			LLTrace::BlockTimer::sLogName = test_name;
 		}
  	}
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 0934028a8c9e2ae8626fa36515531c1667a28ee0..d0bb75225c3a7f9429a4092269a58dfc859335c9 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240;
 static S32 FTV_NUM_TIMERS;
 const S32 FTV_MAX_DEPTH = 8;
 
-std::vector<LLFastTimer::DeclareTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
+std::vector<LLTrace::BlockTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
-typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_iterator_t;
+typedef LLTreeDFSIter<LLTrace::BlockTimer, LLTrace::BlockTimer::child_const_iter> timer_tree_iterator_t;
 
 BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
 
-static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) 
+static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id) 
 { 
 	return timer_tree_iterator_t(&id, 
-							boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), 
-							boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1));
+							boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1), 
+							boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1));
 }
 
 static timer_tree_iterator_t end_timer_tree() 
@@ -92,18 +92,18 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mScrollIndex = 0;
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
-	FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount();
+	FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount();
 	mPrintStats = -1;	
 }
 
 void LLFastTimerView::onPause()
 {
-	LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory;
+	LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory;
 	// reset scroll to bottom when unpausing
-	if (!LLFastTimer::sPauseHistory)
+	if (!LLTrace::BlockTimer::sPauseHistory)
 	{
 		mScrollIndex = 0;
-		LLFastTimer::sResetHistory = true;
+		LLTrace::BlockTimer::sResetHistory = true;
 		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
 	}
 	else
@@ -139,13 +139,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	{
 		S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
 		bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
-		mPrintStats = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx;
+		mPrintStats = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx;
 		return TRUE;
 	}
 	return LLFloater::handleRightMouseDown(x, y, mask);
 }
 
-LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y)
+LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y)
 {
 	S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5;
 
@@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (x < mBarRect.mLeft) 
 	{
-		LLFastTimer::DeclareTimer* idp = getLegendID(y);
+		LLTrace::BlockTimer* idp = getLegendID(y);
 		if (idp)
 		{
 			idp->setCollapsed(!idp->getCollapsed());
@@ -208,16 +208,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 		gFocusMgr.setMouseCapture(this);
 		return TRUE;
 	}
-	//else
-	//{
-	//	// pause/unpause
-	//	LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory;
-	//	// reset scroll to bottom when unpausing
-	//	if (!LLFastTimer::sPauseHistory)
-	//	{
-	//		mScrollIndex = 0;
-	//	}
-	//}
+
 	return LLFloater::handleMouseDown(x, y, mask);
 }
 
@@ -235,14 +226,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
-		mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
-		mScrollIndex = llclamp(	mScrollIndex, 0, LLFastTimer::getLastFrameIndex());
+		mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+		mScrollIndex = llclamp(	mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex());
 		return TRUE;
 	}
 	mHoverTimer = NULL;
 	mHoverID = NULL;
 
-	if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, 
 								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
@@ -288,7 +279,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	}
 	else if (x < mBarRect.mLeft) 
 	{
-		LLFastTimer::DeclareTimer* timer_id = getLegendID(y);
+		LLTrace::BlockTimer* timer_id = getLegendID(y);
 		if (timer_id)
 		{
 			mHoverID = timer_id;
@@ -299,7 +290,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 }
 
 
-static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1)
+static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1)
 {
 	F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond();
 
@@ -318,7 +309,7 @@ static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_ind
 
 BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 {
-	if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		// tooltips for timer bars
 		if (mHoverTimer)
@@ -326,7 +317,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLRect screen_rect;
 			localRectToScreen(mToolTipRect, &screen_rect);
 
-			std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
+			std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
 
 			LLToolTipMgr::instance().show(LLToolTip::Params()
 				.message(tooltip)
@@ -341,7 +332,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 		// tooltips for timer legend
 		if (x < mBarRect.mLeft) 
 		{
-			LLFastTimer::DeclareTimer* idp = getLegendID(y);
+			LLTrace::BlockTimer* idp = getLegendID(y);
 			if (idp)
 			{
 				LLToolTipMgr::instance().show(get_tooltip(*idp));
@@ -356,16 +347,16 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	LLFastTimer::sPauseHistory = TRUE;
+	LLTrace::BlockTimer::sPauseHistory = TRUE;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+							llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true);
+static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true);
 
-static std::map<LLFastTimer::DeclareTimer*, LLColor4> sTimerColors;
+static std::map<LLTrace::BlockTimer*, LLColor4> sTimerColors;
 
 void LLFastTimerView::draw()
 {
@@ -429,7 +420,7 @@ void LLFastTimerView::draw()
 		y -= (texth + 2);
 	}
 
-	S32 histmax = llmin(LLFastTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY);
+	S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY);
 		
 	// Draw the legend
 	xleft = margin;
@@ -445,7 +436,7 @@ void LLFastTimerView::draw()
 		it != timer_tree_iterator_t();
 		++it)
 	{
-		LLFastTimer::DeclareTimer* idp = (*it);
+		LLTrace::BlockTimer* idp = (*it);
 
 		const F32 HUE_INCREMENT = 0.23f;
 		hue = fmodf(hue + HUE_INCREMENT, 1.f);
@@ -465,12 +456,12 @@ void LLFastTimerView::draw()
 		LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
 		S32 cur_line = 0;
 		ft_display_idx.clear();
-		std::map<LLFastTimer::DeclareTimer*, S32> display_line;
+		std::map<LLTrace::BlockTimer*, S32> display_line;
 		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			LLFastTimer::DeclareTimer* idp = (*it);
+			LLTrace::BlockTimer* idp = (*it);
 			display_line[idp] = cur_line;
 			ft_display_idx.push_back(idp);
 			cur_line++;
@@ -490,7 +481,7 @@ void LLFastTimerView::draw()
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
-				S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
+				S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
 				U64 ticks = idp->getHistoricalCount(hidx);
 				ms = (F32)((F64)ticks * iclock_freq);
 				calls = (S32)idp->getHistoricalCalls(hidx);
@@ -528,7 +519,7 @@ void LLFastTimerView::draw()
 
 			x += dx;
 			BOOL is_child_of_hover_item = (idp == mHoverID);
-			LLFastTimer::DeclareTimer* next_parent = idp->getParent();
+			LLTrace::BlockTimer* next_parent = idp->getParent();
 			while(!is_child_of_hover_item && next_parent)
 			{
 				is_child_of_hover_item = (mHoverID == next_parent);
@@ -570,18 +561,18 @@ void LLFastTimerView::draw()
 	barw = width - xleft - margin;
 
 	// Draw the history bars
-	if (LLFastTimer::getLastFrameIndex() >= 0)
+	if (LLTrace::BlockTimer::getLastFrameIndex() >= 0)
 	{	
 		LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin));
 
 		U64 totalticks;
-		if (!LLFastTimer::sPauseHistory)
+		if (!LLTrace::BlockTimer::sPauseHistory)
 		{
 			U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex);
 
-			if (LLFastTimer::getCurFrameIndex() >= 10)
+			if (LLTrace::BlockTimer::getCurFrameIndex() >= 10)
 			{
-				U64 framec = LLFastTimer::getCurFrameIndex();
+				U64 framec = LLTrace::BlockTimer::getCurFrameIndex();
 				U64 avg = (U64)mAvgCountTotal;
 				mAvgCountTotal = (avg*framec + ticks) / (framec + 1);
 				if (ticks > mMaxCountTotal)
@@ -592,14 +583,14 @@ void LLFastTimerView::draw()
 
 			if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100)
 			{
-				LLFastTimer::sResetHistory = true;
+				LLTrace::BlockTimer::sResetHistory = true;
 			}
 
-			if (LLFastTimer::getCurFrameIndex() < 10 || LLFastTimer::sResetHistory)
+			if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory)
 			{
 				mAvgCountTotal = ticks;
 				mMaxCountTotal = ticks;
-				LLFastTimer::sResetHistory = false;
+				LLTrace::BlockTimer::sResetHistory = false;
 			}
 		}
 
@@ -706,7 +697,7 @@ void LLFastTimerView::draw()
 			S32 tidx;
 			if (j >= 0)
 			{
-				tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex;
+				tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex;
 			}
 			else
 			{
@@ -720,14 +711,14 @@ void LLFastTimerView::draw()
 			std::vector<S32> deltax;
 			xpos.push_back(xleft);
 			
-			LLFastTimer::DeclareTimer* prev_id = NULL;
+			LLTrace::BlockTimer* prev_id = NULL;
 
 			S32 i = 0;
 			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 				it != end_timer_tree();
 				++it, ++i)
 			{
-				LLFastTimer::DeclareTimer* idp = (*it);
+				LLTrace::BlockTimer* idp = (*it);
 				F32 frac = tidx == -1
 					? (F32)idp->getCountAverage() / (F32)totalticks 
 					: (F32)idp->getHistoricalCount(tidx) / (F32)totalticks;
@@ -754,7 +745,7 @@ void LLFastTimerView::draw()
 				{
 					U64 sublevelticks = 0;
 
-					for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren();
+					for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren();
 						it != prev_id->endChildren();
 						++it)
 					{
@@ -796,7 +787,7 @@ void LLFastTimerView::draw()
 					S32 scale_offset = 0;
 
 					BOOL is_child_of_hover_item = (idp == mHoverID);
-					LLFastTimer::DeclareTimer* next_parent = idp->getParent();
+					LLTrace::BlockTimer* next_parent = idp->getParent();
 					while(!is_child_of_hover_item && next_parent)
 					{
 						is_child_of_hover_item = (mHoverID == next_parent);
@@ -861,10 +852,10 @@ void LLFastTimerView::draw()
 
 			//highlight visible range
 			{
-				S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex;
+				S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex;
 				S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 				
-				F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1);
+				F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1);
 				
 				F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
 				F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
@@ -891,7 +882,7 @@ void LLFastTimerView::draw()
 				it != end_timer_tree();
 				++it)
 			{
-				LLFastTimer::DeclareTimer* idp = (*it);
+				LLTrace::BlockTimer* idp = (*it);
 				
 				//fatten highlighted timer
 				if (mHoverID == idp)
@@ -915,8 +906,8 @@ void LLFastTimerView::draw()
 
 				gGL.color4f(col[0], col[1], col[2], alpha);				
 				gGL.begin(LLRender::TRIANGLE_STRIP);
-				for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex());
-					j < LLFastTimer::DeclareTimer::HISTORY_NUM;
+				for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex());
+					j < LLTrace::BlockTimer::HISTORY_NUM;
 					j++)
 				{
 					U64 ticks = idp->getHistoricalCount(j);
@@ -937,7 +928,7 @@ void LLFastTimerView::draw()
 						//normalize to highlighted timer
 						cur_max = llmax(cur_max, ticks);
 					}
-					F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j;
+					F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j;
 					F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks;
 					gGL.vertex2f(x,y);
 					gGL.vertex2f(x,mGraphRect.mBottom);
@@ -992,7 +983,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLFastTimer::DeclareTimer* idp = (*it);
+			LLTrace::BlockTimer* idp = (*it);
 
 			if (!first)
 			{
@@ -1014,7 +1005,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLFastTimer::DeclareTimer* idp = (*it);
+			LLTrace::BlockTimer* idp = (*it);
 
 			if (!first)
 			{
@@ -1551,13 +1542,13 @@ void LLFastTimerView::outputAllMetrics()
 //static
 void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
 {
-	if(LLFastTimer::sLog)
+	if(LLTrace::BlockTimer::sLog)
 	{
 		doAnalysisDefault(baseline, target, output) ;
 		return ;
 	}
 
-	if(LLFastTimer::sMetricLog)
+	if(LLTrace::BlockTimer::sMetricLog)
 	{
 		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
 		return ;
@@ -1568,7 +1559,7 @@ void	LLFastTimerView::onClickCloseBtn()
 	setVisible(false);
 }
 
-LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer()
+LLTrace::BlockTimer& LLFastTimerView::getFrameTimer()
 {
 	return FTM_FRAME;
 }
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 01a3501e4b7838fdcfd6097a726f5555a635ff95..d7f7f27cd4fd9e8956bc28b3c04cb66a297edefc 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -46,7 +46,7 @@ class LLFastTimerView : public LLFloater
 	static LLSD analyzePerformanceLogDefault(std::istream& is) ;
 	static void exportCharts(const std::string& base, const std::string& target);
 	void onPause();
-	LLFastTimer::DeclareTimer& getFrameTimer();
+	LLTrace::BlockTimer& getFrameTimer();
 
 public:
 
@@ -59,7 +59,7 @@ class LLFastTimerView : public LLFloater
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
 
-	LLFastTimer::DeclareTimer* getLegendID(S32 y);
+	LLTrace::BlockTimer* getLegendID(S32 y);
 	F64 getTime(const std::string& name);
 
 protected:
@@ -85,8 +85,8 @@ class LLFastTimerView : public LLFloater
 	U64 mMaxCountTotal;
 	LLRect mBarRect;
 	S32	mScrollIndex;
-	LLFastTimer::DeclareTimer* mHoverID;
-	LLFastTimer::DeclareTimer* mHoverTimer;
+	LLTrace::BlockTimer* mHoverID;
+	LLTrace::BlockTimer* mHoverTimer;
 	LLRect					mToolTipRect;
 	S32 mHoverBarIndex;
 	LLFrameTimer mHighlightTimer;
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 3136358b83653e8c1d4d3b6d36482895f73f2729..6bba375f50c2d8b64869fdd12f06eb20332c4802 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -31,6 +31,7 @@
 #include "llassetstorage.h"
 #include "llinventorytype.h"
 #include "llfilepicker.h"
+#include <queue>
 
 class LLTransactionID;