diff --git a/doc/contributions.txt b/doc/contributions.txt
index 16615ab22059062cd664fd9a2ea47edad30424e8..f3584dbf177b49130d6a58025a6e5cf12cc69aaf 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -90,6 +90,7 @@ Aleric Inglewood
 	VWR-24320
     VWR-24321
  	VWR-24354
+	VWR-24366
 	VWR-24519
 	STORM-163
 	STORM-864
diff --git a/indra/cmake/GoogleMock.cmake b/indra/cmake/GoogleMock.cmake
index ca5a8034ba442082c5881ec4c046ebe4b7a777e9..06d6d847a05b82bb96b6ef3a0bf859d9b89fa0cb 100644
--- a/indra/cmake/GoogleMock.cmake
+++ b/indra/cmake/GoogleMock.cmake
@@ -8,9 +8,10 @@ set(GOOGLEMOCK_INCLUDE_DIRS
     ${LIBS_PREBUILT_DIR}/include)
 
 if (LINUX)
+	# VWR-24366: gmock is underlinked, it needs gtest.
     set(GOOGLEMOCK_LIBRARIES 
-        gmock  
-        gtest)
+        gmock -Wl,--no-as-needed
+        gtest -Wl,--as-needed)
 elseif(WINDOWS)
     set(GOOGLEMOCK_LIBRARIES 
         gmock)
diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake
index 05f0492234f059146f38ef586295707ef3456cff..cd0eada2d0dbddc0fa804cfe04731cd2bdff1b45 100644
--- a/indra/cmake/LLAddBuildTest.cmake
+++ b/indra/cmake/LLAddBuildTest.cmake
@@ -57,11 +57,6 @@ INCLUDE(GoogleMock)
     ${CMAKE_SOURCE_DIR}/test/test.h
     )
 
-  # Use the default flags
-  if (LINUX)
-    SET(CMAKE_EXE_LINKER_FLAGS "")
-  endif (LINUX)
-
   # start the source test executable definitions
   SET(${project}_TEST_OUTPUT "")
   FOREACH (source ${sources})
diff --git a/indra/cmake/run_build_test.py b/indra/cmake/run_build_test.py
index 37aa75e364663c675a33f2fa109102c964d7f3d2..320a9be8abb9aaeaadaaa6a4491913211aafcad5 100644
--- a/indra/cmake/run_build_test.py
+++ b/indra/cmake/run_build_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file   run_build_test.py
 @author Nat Goodspeed
diff --git a/indra/copy_win_scripts/start-client.py b/indra/copy_win_scripts/start-client.py
index 5f7ff2f293fa4618a832b498a0b6dae73c9720aa..5699f5273f4b88b337d15139262a753bd3c3a151 100644
--- a/indra/copy_win_scripts/start-client.py
+++ b/indra/copy_win_scripts/start-client.py
@@ -1,4 +1,28 @@
 #!/usr/bin/env python
+"""\
+@file   start-client.py
+
+$LicenseInfo:firstyear=2010&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2010-2011, 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$
+"""
 import sys, getopt
 import os
 import llstart
diff --git a/indra/develop.py b/indra/develop.py
index 36c947327aefd933e120baa76cc843a9d403e5bd..d9a66352f339f6b03e450da20fcf1af4048c6998 100755
--- a/indra/develop.py
+++ b/indra/develop.py
@@ -1,29 +1,30 @@
 #!/usr/bin/env python
-#
-# @file develop.py
-# @authors Bryan O'Sullivan, Mark Palange, Aaron Brashears
-# @brief Fire and forget script to appropriately configure cmake for SL.
-#
-# $LicenseInfo:firstyear=2007&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$
+"""\
+@file develop.py
+@authors Bryan O'Sullivan, Mark Palange, Aaron Brashears
+@brief Fire and forget script to appropriately configure cmake for SL.
+
+$LicenseInfo:firstyear=2007&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2007-2011, 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$
+"""
 
 
 import errno
diff --git a/indra/lib/python/indra/util/llperformance.py b/indra/lib/python/indra/util/llperformance.py
index 7c52730b5e049f40596cbdc21e6a2fc5acab9158..57dd64de3fa04706eb69793361180cf52dee0fe3 100755
--- a/indra/lib/python/indra/util/llperformance.py
+++ b/indra/lib/python/indra/util/llperformance.py
@@ -1,4 +1,28 @@
-#!/usr/bin/python
+#!/usr/bin/env python
+"""\
+@file   llperformance.py
+
+$LicenseInfo:firstyear=2010&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2010-2011, 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$
+"""
 
 # ------------------------------------------------
 # Sim metrics utility functions.
diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py
index 2718a85f414cb958db30e8035bf21742583a084b..ba6f567b607f43792231d18a19857068d587f408 100644
--- a/indra/lib/python/indra/util/llversion.py
+++ b/indra/lib/python/indra/util/llversion.py
@@ -1,7 +1,9 @@
-"""@file llversion.py
-@brief Utility for parsing llcommon/llversion${server}.h
-       for the version string and channel string
-       Utility that parses hg or svn info for branch and revision
+#!/usr/bin/env python
+"""\
+@file  llversion.py
+@brief Parses llcommon/llversionserver.h and llcommon/llversionviewer.h
+       for the version string and channel string.
+       Parses hg info for branch and revision.
 
 $LicenseInfo:firstyear=2006&license=mit$
 
@@ -27,7 +29,7 @@
 $/LicenseInfo$
 """
 
-import re, sys, os, commands
+import re, sys, os, subprocess
 
 # Methods for gathering version information from
 # llversionviewer.h and llversionserver.h
@@ -73,29 +75,13 @@ def get_viewer_channel():
 def get_server_channel():
     return get_channel('server')
 
-# Methods for gathering subversion information
-def get_svn_status_matching(regular_expression):
-    # Get the subversion info from the working source tree
-    status, output = commands.getstatusoutput('svn info %s' % get_src_root())
-    m = regular_expression.search(output)
-    if not m:
-        print >> sys.stderr, "Failed to parse svn info output, result follows:"
-        print >> sys.stderr, output
-        raise Exception, "No matching svn status in "+src_root
-    return m.group(1)
-
-def get_svn_branch():
-    branch_re = re.compile('URL: (\S+)')
-    return get_svn_status_matching(branch_re)
-
-def get_svn_revision():
-    last_rev_re = re.compile('Last Changed Rev: (\d+)')
-    return get_svn_status_matching(last_rev_re)
-
+# Methods for gathering hg information
 def get_hg_repo():
-    status, output = commands.getstatusoutput('hg showconfig paths.default')
+    child = subprocess.Popen(["hg","showconfig","paths.default"], stdout=subprocess.PIPE)
+    output, error = child.communicate()
+    status = child.returncode
     if status:
-        print >> sys.stderr, output
+        print >> sys.stderr, error
         sys.exit(1)
     if not output:
         print >> sys.stderr, 'ERROR: cannot find repo we cloned from'
@@ -103,24 +89,19 @@ def get_hg_repo():
     return output
 
 def get_hg_changeset():
-    # The right thing to do:
-    # status, output = commands.getstatusoutput('hg id -i')
-    # if status:
-    #     print >> sys.stderr, output
-    #    sys.exit(1)
-
-    # The temporary hack:
-    status, output = commands.getstatusoutput('hg parents --template "{rev}"')
+    # The right thing to do would be to use the *global* revision id:
+    #     "hg id -i"
+    # For the moment though, we use the parent revision:
+    child = subprocess.Popen(["hg","parents","--template","{rev}"], stdout=subprocess.PIPE)
+    output, error = child.communicate()
+    status = child.returncode
     if status:
-        print >> sys.stderr, output
+        print >> sys.stderr, error
         sys.exit(1)
     lines = output.splitlines()
     if len(lines) > 1:
         print >> sys.stderr, 'ERROR: working directory has %d parents' % len(lines)
     return lines[0]
 
-def using_svn():
-    return os.path.isdir(os.path.join(get_src_root(), '.svn'))
-
 def using_hg():
     return os.path.isdir(os.path.join(get_src_root(), '.hg'))
diff --git a/indra/lib/python/indra/util/simperf_proc_interface.py b/indra/lib/python/indra/util/simperf_proc_interface.py
index da6304a2742435dc30bb8da49452053d9f38b734..de061f68ccfda36277b0bb2f558d464c03b3bcc7 100755
--- a/indra/lib/python/indra/util/simperf_proc_interface.py
+++ b/indra/lib/python/indra/util/simperf_proc_interface.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file simperf_proc_interface.py
 @brief Utility to extract log messages from *.<pid>.llsd files containing performance statistics.
diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py
index da8ee6c545741a56a43d849f0f68420b4f3d2df9..0532cb006537df4af76d63a521bcd223f8d31b2c 100644
--- a/indra/lib/python/indra/util/test_win32_manifest.py
+++ b/indra/lib/python/indra/util/test_win32_manifest.py
@@ -1,28 +1,29 @@
 #!/usr/bin/env python
-# @file test_win32_manifest.py
-# @brief Test an assembly binding version and uniqueness in a windows dll or exe.  
-#
-# $LicenseInfo:firstyear=2009&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$
-
+"""\
+@file test_win32_manifest.py
+@brief Test an assembly binding version and uniqueness in a windows dll or exe.  
+
+$LicenseInfo:firstyear=2009&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2009-2011, 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$
+"""
 import sys, os
 import tempfile
 from xml.dom.minidom import parse
diff --git a/indra/llmessage/tests/test_llsdmessage_peer.py b/indra/llmessage/tests/test_llsdmessage_peer.py
index 7eb198bb34f47ac729e320bec64801f7d4444969..580ee7f8b44cb7ece17ee60077238883dce8bd78 100644
--- a/indra/llmessage/tests/test_llsdmessage_peer.py
+++ b/indra/llmessage/tests/test_llsdmessage_peer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file   test_llsdmessage_peer.py
 @author Nat Goodspeed
diff --git a/indra/llmessage/tests/testrunner.py b/indra/llmessage/tests/testrunner.py
index 4d58ef71301b9db5aea8d991053d1004361aa1ff..b70ce91ee7beecc1e68471c6e51e380a4a352b3f 100644
--- a/indra/llmessage/tests/testrunner.py
+++ b/indra/llmessage/tests/testrunner.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file   testrunner.py
 @author Nat Goodspeed
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 03befe6818c06c3fe867f17da62a3df22ea901d2..2417f88050bdb689622d8514f8372fa6ccba212d 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -214,11 +214,6 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
 {
 	llassert(mRequestedNumVerts >= 0);
 
-	if(mDirty)
-	{
-		postUpdate() ;
-	}
-
 	if (start >= (U32) mRequestedNumVerts ||
 	    end >= (U32) mRequestedNumVerts)
 	{
@@ -259,11 +254,6 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
 {
 	llassert(mRequestedNumIndices >= 0);
 
-	if(mDirty)
-	{
-		postUpdate() ;
-	}
-
 	if (indices_offset >= (U32) mRequestedNumIndices ||
 	    indices_offset + count > (U32) mRequestedNumIndices)
 	{
@@ -296,11 +286,6 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
 {
 	llassert(mRequestedNumVerts >= 0);
 
-	if(mDirty)
-	{
-		postUpdate() ;
-	}
-
 	if (first >= (U32) mRequestedNumVerts ||
 	    first + count > (U32) mRequestedNumVerts)
 	{
@@ -327,7 +312,7 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
 void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping)
 {
 	sEnableVBOs = use_vbo;
-	sDisableVBOMapping = no_vbo_mapping ;
+	sDisableVBOMapping = sEnableVBOs && no_vbo_mapping ;
 	LLGLNamePool::registerPool(&sDynamicVBOPool);
 	LLGLNamePool::registerPool(&sDynamicIBOPool);
 	LLGLNamePool::registerPool(&sStreamVBOPool);
@@ -384,13 +369,14 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
 	mGLBuffer(0),
 	mGLIndices(0), 
 	mMappedData(NULL),
-	mMappedIndexData(NULL), mLocked(FALSE),
+	mMappedIndexData(NULL), 
+	mVertexLocked(FALSE),
+	mIndexLocked(FALSE),
 	mFinal(FALSE),
 	mFilthy(FALSE),
 	mEmpty(TRUE),
 	mResized(FALSE),
-	mDynamicSize(FALSE),
-	mDirty(FALSE)
+	mDynamicSize(FALSE)
 {
 	LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR);
 	if (!sEnableVBOs)
@@ -443,6 +429,8 @@ LLVertexBuffer::~LLVertexBuffer()
 	destroyGLBuffer();
 	destroyGLIndices();
 	sCount--;
+
+	llassert_always(!mMappedData && !mMappedIndexData) ;
 };
 
 //----------------------------------------------------------------------------
@@ -859,85 +847,58 @@ void LLVertexBuffer::freeClientBuffer()
 	}
 }
 
-void LLVertexBuffer::preUpdate()
+void LLVertexBuffer::allocateClientVertexBuffer()
 {
-	if(!useVBOs() || !sDisableVBOMapping)
-	{
-		return ;
-	}
-
 	if(!mMappedData)
 	{
 		U32 size = getSize() ;
 		mMappedData = new U8[size];
 		memset(mMappedData, 0, size);
 	}
+}
 
+void LLVertexBuffer::allocateClientIndexBuffer()
+{
 	if(!mMappedIndexData)
 	{
 		U32 size = getIndicesSize();
 		mMappedIndexData = new U8[size];
 		memset(mMappedIndexData, 0, size);
 	}
-
-	mDirty = TRUE ;
-}
-
-void LLVertexBuffer::postUpdate() const
-{
-	if(!useVBOs() || !sDisableVBOMapping)
-	{
-		return ;
-	}
-
-	llassert_always(mMappedData && mMappedIndexData) ;
-
-	//release the existing buffers
-	glBufferDataARB(GL_ARRAY_BUFFER_ARB, 0, NULL, mUsage);
-	glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, NULL, mUsage);
-
-	//update to the new buffers
-	glBufferDataARB(GL_ARRAY_BUFFER_ARB, getSize(), mMappedData, mUsage);
-	glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, getIndicesSize(), mMappedIndexData, mUsage);
-
-	mDirty = FALSE ;
 }
 
 // Map for data access
-U8* LLVertexBuffer::mapBuffer(S32 access)
+U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 access)
 {
 	LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER);
 	if (mFinal)
 	{
-		llerrs << "LLVertexBuffer::mapBuffer() called on a finalized buffer." << llendl;
+		llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl;
 	}
 	if (!useVBOs() && !mMappedData && !mMappedIndexData)
 	{
-		llerrs << "LLVertexBuffer::mapBuffer() called on unallocated buffer." << llendl;
+		llerrs << "LLVertexBuffer::mapVertexBuffer() called on unallocated buffer." << llendl;
 	}
 		
-	if(useVBOs() && sDisableVBOMapping)
-	{
-		preUpdate() ;
-		return mMappedData ;
-	}
-
-	if (!mLocked && useVBOs())
+	if (!mVertexLocked && useVBOs())
 	{
 		{
 			LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES);
-			setBuffer(0);
-			mLocked = TRUE;
+			setBuffer(0, type);
+			mVertexLocked = TRUE;
 			stop_glerror();	
-			mMappedData = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
-			stop_glerror();
-		}
-		{
-			LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES);
-			mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+
+			if(sDisableVBOMapping)
+			{
+				allocateClientVertexBuffer() ;
+			}
+			else
+			{
+				mMappedData = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+			}
 			stop_glerror();
 		}
-
+		
 		if (!mMappedData)
 		{
 			log_glerror();
@@ -945,23 +906,67 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
 			//check the availability of memory
 			LLMemory::logMemoryInfo(TRUE) ; 
 			
-			//--------------------
-			//print out more debug info before crash
-			llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl ;
-			GLint size ;
-			glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size) ;
-			llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl ;
-			//--------------------
+			if(!sDisableVBOMapping)
+			{
+				//--------------------
+				//print out more debug info before crash
+				llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl ;
+				GLint size ;
+				glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size) ;
+				llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl ;
+				//--------------------
 
-			GLint buff;
-			glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff);
-			if ((GLuint)buff != mGLBuffer)
+				GLint buff;
+				glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff);
+				if ((GLuint)buff != mGLBuffer)
+				{
+					llerrs << "Invalid GL vertex buffer bound: " << buff << llendl;
+				}
+
+				
+				llerrs << "glMapBuffer returned NULL (no vertex data)" << llendl;
+			}
+			else
 			{
-				llerrs << "Invalid GL vertex buffer bound: " << buff << llendl;
+				llerrs << "memory allocation for vertex data failed." << llendl ;
 			}
+		}
+		sMappedCount++;
+	}
+	
+	return mMappedData;
+}
 
-			
-			llerrs << "glMapBuffer returned NULL (no vertex data)" << llendl;
+U8* LLVertexBuffer::mapIndexBuffer(S32 access)
+{
+	LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER);
+	if (mFinal)
+	{
+		llerrs << "LLVertexBuffer::mapIndexBuffer() called on a finalized buffer." << llendl;
+	}
+	if (!useVBOs() && !mMappedData && !mMappedIndexData)
+	{
+		llerrs << "LLVertexBuffer::mapIndexBuffer() called on unallocated buffer." << llendl;
+	}
+
+	if (!mIndexLocked && useVBOs())
+	{
+		{
+			LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES);
+
+			setBuffer(0, TYPE_INDEX);
+			mIndexLocked = TRUE;
+			stop_glerror();	
+
+			if(sDisableVBOMapping)
+			{
+				allocateClientIndexBuffer() ;
+			}
+			else
+			{
+				mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+			}
+			stop_glerror();
 		}
 
 		if (!mMappedIndexData)
@@ -969,61 +974,99 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
 			log_glerror();
 			LLMemory::logMemoryInfo(TRUE) ;
 
-			GLint buff;
-			glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
-			if ((GLuint)buff != mGLIndices)
+			if(!sDisableVBOMapping)
 			{
-				llerrs << "Invalid GL index buffer bound: " << buff << llendl;
-			}
+				GLint buff;
+				glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
+				if ((GLuint)buff != mGLIndices)
+				{
+					llerrs << "Invalid GL index buffer bound: " << buff << llendl;
+				}
 
-			llerrs << "glMapBuffer returned NULL (no index data)" << llendl;
+				llerrs << "glMapBuffer returned NULL (no index data)" << llendl;
+			}
+			else
+			{
+				llerrs << "memory allocation for Index data failed. " << llendl ;
+			}
 		}
 
 		sMappedCount++;
 	}
-	
-	return mMappedData;
+
+	return mMappedIndexData ;
 }
 
-void LLVertexBuffer::unmapBuffer()
+void LLVertexBuffer::unmapBuffer(S32 type)
 {
 	LLMemType mt2(LLMemType::MTYPE_VERTEX_UNMAP_BUFFER);
-	if (mMappedData || mMappedIndexData)
+	if (!useVBOs())
+	{
+		return ; //nothing to unmap
+	}
+
+	bool updated_all = false ;
+	if (mMappedData && mVertexLocked && type != TYPE_INDEX)
 	{
-		if(sDisableVBOMapping && useVBOs())
+		updated_all = (mIndexLocked && type < 0) ; //both vertex and index buffers done updating
+
+		if(sDisableVBOMapping)
 		{
-			return ;
+			stop_glerror();
+			glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, getSize(), mMappedData);
+			stop_glerror();
 		}
-		else if (useVBOs() && mLocked)
+		else
 		{
 			stop_glerror();
 			glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
 			stop_glerror();
+
+			mMappedData = NULL;
+		}
+
+		mVertexLocked = FALSE ;
+		sMappedCount--;
+	}
+
+	if(mMappedIndexData && mIndexLocked && (type < 0 || type == TYPE_INDEX))
+	{
+		if(sDisableVBOMapping)
+		{
+			stop_glerror();
+			glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, getIndicesSize(), mMappedIndexData);
+			stop_glerror();
+		}
+		else
+		{
+			stop_glerror();
 			glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
 			stop_glerror();
 
-			/*if (!sMapped)
-			{
-				llerrs << "Redundantly unmapped VBO!" << llendl;
-			}
-			sMapped = FALSE;*/
-			sMappedCount--;
-
-			if (mUsage == GL_STATIC_DRAW_ARB)
-			{ //static draw buffers can only be mapped a single time
-				//throw out client data (we won't be using it again)
-				mEmpty = TRUE;
-				mFinal = TRUE;
-			}
-			else
+			mMappedIndexData = NULL ;
+		}
+
+		mIndexLocked = FALSE ;
+		sMappedCount--;
+	}
+
+	if(updated_all)
+	{
+		if(mUsage == GL_STATIC_DRAW_ARB)
+		{
+			//static draw buffers can only be mapped a single time
+			//throw out client data (we won't be using it again)
+			mEmpty = TRUE;
+			mFinal = TRUE;
+
+			if(sDisableVBOMapping)
 			{
-				mEmpty = FALSE;
+				freeClientBuffer() ;
 			}
-
-			mMappedIndexData = NULL;
-			mMappedData = NULL;
-			
-			mLocked = FALSE;
+		}
+		else
+		{
+			mEmpty = FALSE;
 		}
 	}
 }
@@ -1037,15 +1080,16 @@ template <class T,S32 type> struct VertexBufferStrider
 					strider_t& strider, 
 					S32 index)
 	{
-		if (vbo.mapBuffer() == NULL)
-		{
-			llwarns << "mapBuffer failed!" << llendl;
-			return FALSE;
-		}
-
 		if (type == LLVertexBuffer::TYPE_INDEX)
 		{
 			S32 stride = sizeof(T);
+
+			if (vbo.mapIndexBuffer() == NULL)
+			{
+				llwarns << "mapIndexBuffer failed!" << llendl;
+				return FALSE;
+			}
+
 			strider = (T*)(vbo.getMappedIndices() + index*stride);
 			strider.setStride(0);
 			return TRUE;
@@ -1053,6 +1097,13 @@ template <class T,S32 type> struct VertexBufferStrider
 		else if (vbo.hasDataType(type))
 		{
 			S32 stride = vbo.getStride();
+
+			if (vbo.mapVertexBuffer(type) == NULL)
+			{
+				llwarns << "mapVertexBuffer failed!" << llendl;
+				return FALSE;
+			}
+
 			strider = (T*)(vbo.getMappedData() + vbo.getOffset(type) + index*stride);
 			strider.setStride(stride);
 			return TRUE;
@@ -1133,7 +1184,7 @@ void LLVertexBuffer::setStride(S32 type, S32 new_stride)
 //----------------------------------------------------------------------------
 
 // Set for rendering
-void LLVertexBuffer::setBuffer(U32 data_mask)
+void LLVertexBuffer::setBuffer(U32 data_mask, S32 type)
 {
 	LLMemType mt2(LLMemType::MTYPE_VERTEX_SET_BUFFER);
 	//set up pointers if the data mask is different ...
@@ -1240,13 +1291,13 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 				}
 			}
 
-			if (mGLBuffer && !sDisableVBOMapping)
+			if (mGLBuffer)
 			{
 				stop_glerror();
 				glBufferDataARB(GL_ARRAY_BUFFER_ARB, getSize(), NULL, mUsage);
 				stop_glerror();
 			}
-			if (mGLIndices && !sDisableVBOMapping)
+			if (mGLIndices)
 			{
 				stop_glerror();
 				glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, getIndicesSize(), NULL, mUsage);
@@ -1274,7 +1325,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 		{
 			ll_fail("LLVertexBuffer::mapBuffer failed");
 		}
-		unmapBuffer();
+		unmapBuffer(type);
 	}
 	else
 	{		
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index 18d50c87bb32ff56c2e31717c20b80e2710e0a55..c51ce7ac4e1119bd8b4d14c583f94ea2c032a37c 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -139,24 +139,24 @@ class LLVertexBuffer : public LLRefCount
 	void	updateNumVerts(S32 nverts);
 	void	updateNumIndices(S32 nindices); 
 	virtual BOOL	useVBOs() const;
-	void	unmapBuffer();
-		
+	void	unmapBuffer(S32 type);
+	void freeClientBuffer() ;
+	void allocateClientVertexBuffer() ;
+	void allocateClientIndexBuffer() ;
+
 public:
 	LLVertexBuffer(U32 typemask, S32 usage);
 	
 	// map for data access
-	U8*		mapBuffer(S32 access = -1);
+	U8*		mapVertexBuffer(S32 type = -1, S32 access = -1);
+	U8*		mapIndexBuffer(S32 access = -1);
+
 	// set for rendering
-	virtual void	setBuffer(U32 data_mask); 	// calls  setupVertexBuffer() if data_mask is not 0
+	virtual void	setBuffer(U32 data_mask, S32 type = -1); 	// calls  setupVertexBuffer() if data_mask is not 0
 	// allocate buffer
 	void	allocateBuffer(S32 nverts, S32 nindices, bool create);
 	virtual void resizeBuffer(S32 newnverts, S32 newnindices);
-		
-	void preUpdate() ;
-	void postUpdate() const ;
-	void freeClientBuffer() ;
-	void dirty() {mDirty = TRUE;}
-
+			
 	// Only call each getVertexPointer, etc, once before calling unmapBuffer()
 	// call unmapBuffer() after calls to getXXXStrider() before any cals to setBuffer()
 	// example:
@@ -175,7 +175,7 @@ class LLVertexBuffer : public LLRefCount
 	bool getClothWeightStrider(LLStrider<LLVector4>& strider, S32 index=0);
 	
 	BOOL isEmpty() const					{ return mEmpty; }
-	BOOL isLocked() const					{ return mLocked; }
+	BOOL isLocked() const					{ return mVertexLocked || mIndexLocked; }
 	S32 getNumVerts() const					{ return mNumVerts; }
 	S32 getNumIndices() const				{ return mNumIndices; }
 	S32 getRequestedVerts() const			{ return mRequestedNumVerts; }
@@ -214,14 +214,14 @@ class LLVertexBuffer : public LLRefCount
 	U32		mGLIndices;		// GL IBO handle
 	U8*		mMappedData;	// pointer to currently mapped data (NULL if unmapped)
 	U8*		mMappedIndexData;	// pointer to currently mapped indices (NULL if unmapped)
-	BOOL	mLocked;			// if TRUE, buffer is being or has been written to in client memory
+	BOOL	mVertexLocked;			// if TRUE, vertex buffer is being or has been written to in client memory
+	BOOL	mIndexLocked;			// if TRUE, index buffer is being or has been written to in client memory
 	BOOL	mFinal;			// if TRUE, buffer can not be mapped again
 	BOOL	mFilthy;		// if TRUE, entire buffer must be copied (used to prevent redundant dirty flags)
-	BOOL	mEmpty;			// if TRUE, client buffer is empty (or NULL). Old values have been discarded.
-	S32		mOffsets[TYPE_MAX];
+	BOOL	mEmpty;			// if TRUE, client buffer is empty (or NULL). Old values have been discarded.	
 	BOOL	mResized;		// if TRUE, client buffer has been resized and GL buffer has not
 	BOOL	mDynamicSize;	// if TRUE, buffer has been resized at least once (and should be padded)
-	mutable BOOL    mDirty ;
+	S32		mOffsets[TYPE_MAX];
 
 	class DirtyRegion
 	{
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index fac4cfbef958bd450cef7287ef497d1db2770404..b7262212811d0e546214d44cf3c04fa0f7089fdc 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -8493,7 +8493,7 @@
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-      <integer>0</integer>
+      <integer>1</integer>
     </map>
   <key>RenderUseStreamVBO</key>
   <map>
diff --git a/indra/newview/generate_breakpad_symbols.py b/indra/newview/generate_breakpad_symbols.py
index 4fd04d780eb0a8b926797d7623d26b1b04ab611e..5ebec1563e915b5914be63fc2d1dc4f1ecb6bcae 100644
--- a/indra/newview/generate_breakpad_symbols.py
+++ b/indra/newview/generate_breakpad_symbols.py
@@ -1,29 +1,31 @@
 #!/usr/bin/env python
-# @file generate_breakpad_symbols.py
-# @author Brad Kittenbrink <brad@lindenlab.com>
-# @brief Simple tool for generating google_breakpad symbol information
-#        for the crash reporter.
-#
-# $LicenseInfo:firstyear=2010&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$
+"""\
+@file generate_breakpad_symbols.py
+@author Brad Kittenbrink <brad@lindenlab.com>
+@brief Simple tool for generating google_breakpad symbol information
+       for the crash reporter.
+
+$LicenseInfo:firstyear=2010&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2010-2011, 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$
+"""
 
 
 import collections
diff --git a/indra/newview/skins/default/xui/en/floater_region_debug_console.xml b/indra/newview/skins/default/xui/en/floater_region_debug_console.xml
index cf95257b0a508d9d5a1e937f4c6ff4a7894cc68e..7c7ee2df4cba54d28e78a7e4bd927cdb58f0d25c 100644
--- a/indra/newview/skins/default/xui/en/floater_region_debug_console.xml
+++ b/indra/newview/skins/default/xui/en/floater_region_debug_console.xml
@@ -2,6 +2,7 @@
 <floater
   name="region_debug_console"
   title="Region Debug"
+  can_resize="true"
   layout="topleft"
   min_height="300"
   min_width="300"
@@ -12,7 +13,7 @@
   left="10"
    type="string"
    length="1"
-   follows="left|top|right|bottom"
+   follows="left|right|bottom"
    font="Monospace"
    height="366"
    width="576"
diff --git a/indra/newview/tests/test_llxmlrpc_peer.py b/indra/newview/tests/test_llxmlrpc_peer.py
index aeebb0cfd18b758c6e449c77f986de9a7684a184..1c7204a6b639cad20ee9761709be0095f632f1fe 100644
--- a/indra/newview/tests/test_llxmlrpc_peer.py
+++ b/indra/newview/tests/test_llxmlrpc_peer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file   test_llxmlrpc_peer.py
 @author Nat Goodspeed
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 338c62b9fb3a7193971a511872c108a16fd69be4..1722c84d342831e2d03384f056581484a267b377 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -1,29 +1,31 @@
-#!/usr/bin/python
-# @file viewer_manifest.py
-# @author Ryan Williams
-# @brief Description of all installer viewer files, and methods for packaging
-#        them into installers for all supported platforms.
-#
-# $LicenseInfo:firstyear=2006&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$
+#!/usr/bin/env python
+"""\
+@file viewer_manifest.py
+@author Ryan Williams
+@brief Description of all installer viewer files, and methods for packaging
+       them into installers for all supported platforms.
+
+$LicenseInfo:firstyear=2006&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2006-2011, 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$
+"""
 import sys
 import os.path
 import re
diff --git a/indra/test/test_llmanifest.py b/indra/test/test_llmanifest.py
index 89c36f95ddaf40cdf1c1db5f85aa1680f6073664..a97abbc6eed3292fad3af64d5ac746ec2cfb20fd 100644
--- a/indra/test/test_llmanifest.py
+++ b/indra/test/test_llmanifest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """
 @file test_llmanifest.py
 @author Ryan Williams
diff --git a/scripts/build_version.py b/scripts/build_version.py
index 4bef290b7dd0c932a6b709ef05587d563436850b..203d76fe9ee904d0f8ffe73f04da66d251bda019 100755
--- a/scripts/build_version.py
+++ b/scripts/build_version.py
@@ -1,16 +1,39 @@
 #!/usr/bin/env python
-#
-# Print the build information embedded in a header file.
-#
-# Expects to be invoked from the command line with a file name and a
-# list of directories to search.  The file name will be one of the
-# following:
-#
-#   llversionserver.h
-#   llversionviewer.h
-#
-# The directory list that follows will include indra/llcommon, where
-# these files live.
+"""\
+@file   build_version.py
+@brief Print the build information embedded in a header file.
+
+  Expects to be invoked from the command line with a file name and a
+  list of directories to search.  The file name will be one of the
+  following:
+
+    llversionserver.h
+    llversionviewer.h
+
+  The directory list that follows will include indra/llcommon, where
+  these files live.
+
+$LicenseInfo:firstyear=2010&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2010-2011, 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$
+"""
 
 import errno, os, re
 
diff --git a/scripts/md5check.py b/scripts/md5check.py
index 951fe0105ca8a7106c0ac9649b6f4d050b016402..1a54a2844c395e037a321a789f7015e642a0faa6 100755
--- a/scripts/md5check.py
+++ b/scripts/md5check.py
@@ -1,32 +1,27 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file md5check.py
 @brief Replacement for message template compatibility verifier.
 
-$LicenseInfo:firstyear=20i10&license=viewergpl$
-Copyright (c) 2010, Linden Research, Inc.
-
+$LicenseInfo:firstyear=2010&license=viewerlgpl$
 Second Life Viewer Source Code
-The source code in this file ("Source Code") is provided by Linden Lab
-to you under the terms of the GNU General Public License, version 2.0
-("GPL"), unless you have obtained a separate licensing agreement
-("Other License"), formally executed by you and Linden Lab.  Terms of
-the GPL can be found in doc/GPL-license.txt in this distribution, or
-online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
-
-There are special exceptions to the terms and conditions of the GPL as
-it is applied to this Source Code. View the full text of the exception
-in the file doc/FLOSS-exception.txt in this software distribution, or
-online at
-http://secondlifegrid.net/programs/open_source/licensing/flossexception
-
-By copying, modifying or distributing this software, you acknowledge
-that you have read and understood your obligations described above,
-and agree to abide by those obligations.
-
-ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
-WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
-COMPLETENESS OR PERFORMANCE.
+Copyright (C) 2010-2011, 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$
 """
 
diff --git a/scripts/setup-path.py b/scripts/setup-path.py
index 55e0f1a85f91665048ee46c475fbf5a496ed4d41..ce83d815bf8d0ac3c743d8848e715da48d2b29bb 100644
--- a/scripts/setup-path.py
+++ b/scripts/setup-path.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file setup-path.py
 @brief Get the python library directory in the path, so we don't have
diff --git a/scripts/template_verifier.py b/scripts/template_verifier.py
index ddb050fbbbb604626d3f3a89d6831b54e990a901..7f3fed88a92bc1ce2cb72e8f9159ad3f4288ec28 100644
--- a/scripts/template_verifier.py
+++ b/scripts/template_verifier.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """\
 @file template_verifier.py
 @brief Message template compatibility verifier.
diff --git a/scripts/update_version_files.py b/scripts/update_version_files.py
index da60fd105a93e35059e62a63107481f20bdcfec1..87036dc1c05e2a0f632c768e827fc27894a16418 100755
--- a/scripts/update_version_files.py
+++ b/scripts/update_version_files.py
@@ -1,8 +1,30 @@
-#!/usr/bin/python
-#
-# Update all of the various files in the repository to a new version number,
-# instead of having to figure it out by hand
-#
+#!/usr/bin/env python
+"""\
+@file   update_version_files.py
+@brief  Update all of the various files in the repository to a new version number,
+instead of having to figure it out by hand
+
+$LicenseInfo:firstyear=2010&license=viewerlgpl$
+Second Life Viewer Source Code
+Copyright (C) 2010-2011, 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$
+"""
 
 import sys
 import os.path
@@ -37,9 +59,6 @@ def add_indra_lib_path():
 import getopt, os, re, commands
 from indra.util import llversion
 
-svn = os.path.expandvars("${SVN}")
-if not svn or svn == "${SVN}": svn = "svn"
-
 def usage():
     print "Usage:"
     print sys.argv[0] + """ [options]
@@ -68,7 +87,7 @@ def usage():
    Print this message and exit.
 
 Common Uses:
-   # Update server and viewer build numbers to the current SVN revision:
+   # Update server and viewer build numbers to the current hg revision:
    update_version_files.py
 
    # Update build numbers unless we are on a release branch:
@@ -80,7 +99,7 @@ def usage():
    # Update just the viewer version number explicitly:
    update_version_files.py --viewer --version=1.18.1.6     
 
-   # Update just the server build number to the current SVN revision:
+   # Update just the server build number to the current hg revision:
    update_version_files.py --server
                                
    # Update the viewer channel
@@ -152,9 +171,7 @@ def _getstatusoutput(cmd):
       'CFBundleGetInfoString = "Second Life version %(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s'))
 
 
-version_re      = re.compile('(\d+).(\d+).(\d+).(\d+)')
-svn_branch_re   = re.compile('^URL:\s+\S+/([^/\s]+)$', re.MULTILINE)
-svn_revision_re = re.compile('^Last Changed Rev: (\d+)$', re.MULTILINE)
+version_re = re.compile('(\d+).(\d+).(\d+).(\d+)')
 
 def main():
     script_path = os.path.dirname(__file__)
@@ -249,13 +266,7 @@ def main():
             server_version = new_version
     else:
 
-        if llversion.using_svn():
-            if new_revision:
-                revision = new_revision
-            else:
-                revision = llversion.get_svn_revision()
-            branch = llversion.get_svn_branch()
-        elif llversion.using_hg():
+        if llversion.using_hg():
             if new_revision:
                 revision = new_revision
             else:
@@ -327,5 +338,6 @@ def main():
             print "File %(filename)s not present, skipping..." % locals()
     return 0
 
-main()
+if __name__ == '__main__':
+    sys.exit(main())