diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp
old mode 100644
new mode 100755
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index e15c1a5104ced5c9e3832e399527792a8a512ee0..6c082a7e9cd1b365331417d99aa3adfeaefceaaf 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -4292,10 +4292,6 @@ void LLAgent::requestLeaveGodMode()
 	sendReliableMessage();
 }
 
-extern void dump_visual_param(apr_file_t* file, LLVisualParam* viewer_param, F32 value);
-extern std::string get_sequential_numbered_file_name(const std::string& prefix,
-													 const std::string& suffix);
-
 // For debugging, trace agent state at times appearance message are sent out.
 void LLAgent::dumpSentAppearance(const std::string& dump_prefix)
 {
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 10523ca9987e82d442289b456301e0c3a5b59926..d0f28b8c101b1ddcb34fc05c97b9e5b52204d278 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -50,6 +50,7 @@
 #include "llviewerregion.h"
 #include "llwearablelist.h"
 #include "llsdutil.h"
+#include "llsdserialize.h"
 
 std::string self_av_string()
 {
@@ -3049,6 +3050,10 @@ class RequestAgentUpdateAppearanceResponder: public LLHTTPClient::Responder
 		if (content["success"].asBoolean())
 		{
 			LL_DEBUGS("Avatar") << "OK" << LL_ENDL;
+			if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"))
+			{
+				dumpContents("appearance_request_ok", content);
+			}
 		}
 		else
 		{
@@ -3056,11 +3061,23 @@ class RequestAgentUpdateAppearanceResponder: public LLHTTPClient::Responder
 		}
 	}
 
+	void dumpContents(const std::string outprefix, const LLSD& content)
+	{
+		std::string outfilename = get_sequential_numbered_file_name(outprefix,".xml");
+		std::string fullpath = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,outfilename);
+		std::ofstream ofs(fullpath);
+		ofs << LLSDOStreamer<LLSDXMLFormatter>(content, LLSDFormatter::OPTIONS_PRETTY);
+		LL_DEBUGS("Avatar") << "results saved to: " << fullpath << LL_ENDL;
+	}
+	
 	// Error
 	/*virtual*/ void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "appearance update request failed, status: " << status << " reason: " << reason << llendl;
-		LL_DEBUGS("Avatar") << "content: " << ll_pretty_print_sd(content) << LL_ENDL;
+		llwarns << "appearance update request failed, status: " << status << " reason: " << reason << " code: " << content["code"].asInteger() << " error: \"" << content["error"].asString() << "\"" << llendl;
+		if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"))
+		{
+			dumpContents("appearance_request_error", content);
+		}
 		onFailure(status);
 	}	
 
@@ -3095,6 +3112,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond
 	if (!gAgent.getRegion())
 	{
 		llwarns << "Region not set, cannot request server appearance update" << llendl;
+		return;
 	}
 	if (gAgent.getRegion()->getCentralBakeVersion()==0)
 	{
@@ -3110,7 +3128,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond
 	LLSD body;
 	S32 cof_version = getCOFVersion();
 	body["cof_version"] = cof_version;
-	LL_DEBUGS("Avatar") << "my_cof_version " << cof_version << llendl;
+	LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << llendl;
 	
 	//LLCurl::ResponderPtr responder_ptr;
 	if (!responder_ptr.get())
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index ac1f40b4862ee39d78a871b9a0db47ab82268b1f..171a2cd043a6f9e45761df8d392decbae9735594 100755
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -1922,7 +1922,18 @@ bool LLInventoryModel::loadSkeleton(
 			for(cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
 			{
 				LLViewerInventoryCategory *llvic = (*it);
+#if 1
 				llvic->setVersion(NO_VERSION);
+#else
+				if (llvic->getPreferredType()==LLFolderType::FT_CURRENT_OUTFIT && llvic->getVersion()==1)
+				{
+					llinfos << "preserving empty COF for first-time login" << llendl;
+				}
+				else
+				{
+					llvic->setVersion(NO_VERSION);
+				}
+#endif
 				addCategory(*it);
 			}
 		}
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
old mode 100644
new mode 100755
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index d6f0874a58ac4535771778a5186c63484e167f2c..59efcfa7fac6ef917629119658b04e30887adb0c 100755
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -592,7 +592,7 @@ void LLViewerInventoryCategory::copyViewerCategory(const LLViewerInventoryCatego
 {
 	copyCategory(other);
 	mOwnerID = other->mOwnerID;
-	mVersion = other->mVersion;
+	setVersion(other->getVersion());
 	mDescendentCount = other->mDescendentCount;
 	mDescendentsRequested = other->mDescendentsRequested;
 }
@@ -660,9 +660,19 @@ void LLViewerInventoryCategory::removeFromServer( void )
 	gAgent.sendReliableMessage();
 }
 
+S32 LLViewerInventoryCategory::getVersion() const
+{
+	return mVersion;
+}
+
+void LLViewerInventoryCategory::setVersion(S32 version)
+{
+	mVersion = version;
+}
+
 bool LLViewerInventoryCategory::fetch()
 {
-	if((VERSION_UNKNOWN == mVersion)
+	if((VERSION_UNKNOWN == getVersion())
 	   && mDescendentsRequested.hasExpired())	//Expired check prevents multiple downloads.
 	{
 		LL_DEBUGS("InventoryFetch") << "Fetching category children: " << mName << ", UUID: " << mUUID << LL_ENDL;
@@ -1127,6 +1137,11 @@ void link_inventory_item(
 		}
 	}
 
+#if 1 // debugging stuff
+	LLViewerInventoryCategory* cat = gInventory.getCategory(parent_id);
+	lldebugs << "cat: " << cat << llendl;
+	
+#endif
 	LLMessageSystem* msg = gMessageSystem;
 	msg->newMessageFast(_PREHASH_LinkInventoryItem);
 	msg->nextBlock(_PREHASH_AgentData);
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index 13e95c57cbfe088eee685ba82570e0c3480fb55e..812b3b273979a15eacc231bbe0552ccae2c32fc8 100755
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -205,8 +205,8 @@ class LLViewerInventoryCategory  : public LLInventoryCategory
 
 	// Version handling
 	enum { VERSION_UNKNOWN = -1, VERSION_INITIAL = 1 };
-	S32 getVersion() const { return mVersion; }
-	void setVersion(S32 version) { mVersion = version; }
+	S32 getVersion() const;
+	void setVersion(S32 version);
 
 	// Returns true if a fetch was issued.
 	bool fetch();
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 266b9fecd5f72c1b7ec4d1746dc6a46466d9e572..04458da5293d5e5f191e500132702beb1ebf59bc 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -190,11 +190,6 @@ enum ERenderName
 	RENDER_NAME_FADE
 };
 
-
-// Utility func - FIXME move out of avatar.
-std::string get_sequential_numbered_file_name(const std::string& prefix,
-											  const std::string& suffix);
-
 //-----------------------------------------------------------------------------
 // Callback data
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index c989673cdfa9a205f5c4ad5d1c7fb07fc5f810ea..3382a1ef17b40921dbd3650363e7ec94f06c9d64 100755
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -980,5 +980,9 @@ class LLVOAvatar :
 extern const F32 SELF_ADDITIONAL_PRI;
 extern const S32 MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL;
 
+std::string get_sequential_numbered_file_name(const std::string& prefix,
+											  const std::string& suffix);
+void dump_visual_param(apr_file_t* file, LLVisualParam* viewer_param, F32 value);
+
 #endif // LL_VOAVATAR_H
 
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 0e8e48099e1e98d1aef5ca22c0b90e31dcd1574d..c069488a37e2f81e0a77ca99357a2aa1411521e9 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -3049,8 +3049,6 @@ void LLVOAvatarSelf::dumpScratchTextureByteCount()
 	llinfos << "Scratch Texture GL: " << (sScratchTexBytes/1024) << "KB" << llendl;
 }
 
-void dump_visual_param(apr_file_t* file, LLVisualParam* viewer_param, F32 value);
-
 void LLVOAvatarSelf::dumpWearableInfo(LLAPRFile& outfile)
 {
 	apr_file_t* file = outfile.getFileHandle();