void saveChanges()
    {
        //GameObject go = GameObject.Find ("AnimatorData");
        //if(!go) return;
        //AnimatorData aData = (AnimatorData) go.GetComponent<AnimatorData>();
        //if(!aData) return;

        AnimatorData aData = AMTimeline.GetAnimatorData();

        if (!aData)
        {
            return;
        }

        List <GameObject> keepReferences    = new List <GameObject>();
        List <GameObject> replaceReferences = new List <GameObject>();

        for (int i = 0; i < newReference.Count; i++)
        {
            if (actions[i] == 0)
            {
                continue;
            }
            if (newReference[i] == oldReference[i])
            {
                continue;
            }
            if (!newReference[i] || !oldReference[i])
            {
                continue;                                                       // skip null values
            }
            else if (actions[i] == 1)
            {
                keepReferences.Add(newReference[i]);
                replaceReferences.Add(oldReference[i]);
            }
            else if (actions[i] == 2)
            {
                keepReferences.Add(oldReference[i]);
                replaceReferences.Add(newReference[i]);
            }
        }

        if (keepReferences.Count <= 0)
        {
            this.Close();
            return;             // return if no changes made
        }
        //AMTimeline.registerUndo("Resolve Duplicates");
        // update references
        List <GameObject> lsFlagToKeep = aData.updateDependencies(keepReferences, replaceReferences);

        // reset event track method info
        AMTimeline.resetIndexMethodInfo();
        AMTimeline.shouldCheckDependencies = false;
        //aData.shouldCheckDependencies = false;
        // delete replaced references
        int count = 0;

        for (int i = 0; i < replaceReferences.Count; i++)
        {
            if (lsFlagToKeep.Contains(replaceReferences[i]))
            {
                continue;
            }
            DestroyImmediate(replaceReferences[i]);
            replaceReferences.RemoveAt(i);
            count++;
            i--;
        }
        replaceReferences = new List <GameObject>();

        Debug.Log("Animator: Resolved Duplicate" + (count > 1 ? "s" : "") + ". Deleted " + count + " GameObject" + (count > 1 ? "s" : "") + ".");
        this.Close();
    }