diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index daff69c73a7cf4ab4c600fec1c38c5b1a79124d2..1eee736b4853c00eef9f0727f8fd4770497b4064 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -1453,6 +1453,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo
 		if (joint)
 		{
             S32 joint_num = joint->getJointNum();
+			joint_name = joint->getName(); // canonical name in case this is an alias.
 //			LL_INFOS() << "  joint: " << joint_name << LL_ENDL;
             if ((joint_num >= (S32)LL_CHARACTER_MAX_ANIMATED_JOINTS) || (joint_num < 0))
             {
@@ -2109,8 +2110,9 @@ U32	LLKeyframeMotion::getFileSize()
 //-----------------------------------------------------------------------------
 // dumpToFile()
 //-----------------------------------------------------------------------------
-void LLKeyframeMotion::dumpToFile(const std::string& name)
+bool LLKeyframeMotion::dumpToFile(const std::string& name)
 {
+	bool succ = false;
     if (isLoaded())
     {
         std::string outfile_base;
@@ -2127,10 +2129,24 @@ void LLKeyframeMotion::dumpToFile(const std::string& name)
             const LLUUID& id = getID();
             outfile_base = id.asString();
         }
-        std::string outfilename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,outfile_base + ".anim");
+
+		if (gDirUtilp->getExtension(outfile_base).empty())
+		{
+			outfile_base += ".anim";
+		}
+		std::string outfilename;
+		if (gDirUtilp->getDirName(outfile_base).empty())
+		{
+			outfilename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,outfile_base);
+		}
+		else
+		{
+			outfilename = outfile_base;
+		}
         if (LLFile::isfile(outfilename))
         {
-            return;
+			LL_WARNS() << outfilename << " already exists, write failed" << LL_ENDL;
+            return false;
         }
 
         S32 file_size = getFileSize();
@@ -2144,11 +2160,13 @@ void LLKeyframeMotion::dumpToFile(const std::string& name)
             outfile.open(outfilename, LL_APR_WPB);
             if (outfile.getFileHandle())
             {
-                outfile.write(buffer, file_size);
+                S32 wrote_bytes = outfile.write(buffer, file_size);
+				succ = (wrote_bytes == file_size);
             }
         }
         delete [] buffer;
     }
+	return succ;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h
index ff29a900107da8de3272c16f29e612db641d987d..96746f57c923fe55254ddc1f151f19d1b37d7eb1 100644
--- a/indra/llcharacter/llkeyframemotion.h
+++ b/indra/llcharacter/llkeyframemotion.h
@@ -158,7 +158,7 @@ class LLKeyframeMotion :
 	BOOL	serialize(LLDataPacker& dp) const;
 	BOOL	deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints = true);
 	BOOL	isLoaded() { return mJointMotionList != NULL; }
-    void	dumpToFile(const std::string& name);
+    bool	dumpToFile(const std::string& name);
 
 
 	// setters for modifying a keyframe animation
@@ -432,6 +432,9 @@ class LLKeyframeMotion :
 	F32								mLastUpdateTime;
 	F32								mLastLoopedTime;
 	AssetStatus						mAssetStatus;
+
+public:
+	void setCharacter(LLCharacter* character) { mCharacter = character; }
 };
 
 class LLKeyframeDataCache
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index 7c6721cad93f6df84ea82b09b6b466c777042d66..14fae8d03553495b0555c6d88a1028ba8f21dbdd 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -50,6 +50,10 @@
 #include "llpreviewnotecard.h"
 #include "llpreviewgesture.h"
 #include "llcoproceduremanager.h"
+#include "llthread.h"
+#include "llkeyframemotion.h"
+#include "lldatapacker.h"
+#include "llvoavatarself.h"
 
 void dialog_refresh_all();
 
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index b1f04601fdca66d98f2c5be746e7f980f84d619b..8c8025e35207a8cfc054c5398224ca772318e9f0 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -6145,7 +6145,11 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name )
 	LLJoint* jointp = NULL;
 
 	if (iter == mJointMap.end() || iter->second == NULL)
-	{
+	{   //search for joint and cache found joint in lookup table
+		if (mJointAliasMap.empty())
+		{
+			getJointAliases();
+		}
 		joint_alias_map_t::const_iterator alias_iter = mJointAliasMap.find(name);
 		std::string canonical_name;
 		if (alias_iter != mJointAliasMap.end())
diff --git a/scripts/content_tools/anim_tool.py b/scripts/content_tools/anim_tool.py
index e7b86a88fa07f76f17a532c0e80b11dea0f50b52..205fc2b6e1970c07aa944c51591982b8c967b2d7 100644
--- a/scripts/content_tools/anim_tool.py
+++ b/scripts/content_tools/anim_tool.py
@@ -637,6 +637,7 @@ def main(*argv):
     parser.add_argument("--no_hud", help="omit hud joints from list of attachments", action="store_true")
     parser.add_argument("--base_priority", help="set base priority", type=int)
     parser.add_argument("--joint_priority", help="set joint priority for all joints", type=int)
+    parser.add_argument("--force_joints", help="don't check validity of joint names", action="store_true")
     parser.add_argument("infilename", help="name of a .anim file to input")
     parser.add_argument("outfilename", nargs="?", help="name of a .anim file to output")
     args = parser.parse_args(argv)
@@ -661,7 +662,12 @@ def main(*argv):
         if lad_tree is None:
             raise Error("failed to parse " + args.lad)
     if args.joints:
-        joints = resolve_joints(args.joints, skel_tree, lad_tree, args.no_hud)
+        if args.force_joints:
+            joints = args.joints
+        else:
+            joints = resolve_joints(args.joints, skel_tree, lad_tree, args.no_hud)
+        if args.use_aliases:
+            joints = map(lambda name: "avatar_" + name, joints)
         if args.verbose:
             print("joints resolved to",joints)
         for name in joints: