 package weave.core
 {
 	import weave.api.WeaveAPI;
+	import weave.api.core.ICallbackCollection;
 	import weave.api.core.IDisposableObject;
 	import weave.api.core.ILinkableObject;
-	import weave.api.juggleGroupedCallback;
-	import weave.api.juggleImmediateCallback;
-	import weave.utils.WeakReference;
 	
 	/**
 	 * This is used to juggle a single callback between linkable object targets.
+	 * The callback will be triggered automatically when the target changes, even when the target becomes null.
 	 * @see weave.api.#juggleImmediateCallback()
 	 * @see weave.api.#juggleGroupedCallback()
 	 * @author adufilie

		 */
		public function set target(newTarget:ILinkableObject):void
		{
			var oldTarget:ILinkableObject = targetRef.value as ILinkableObject;
			
			var change:Boolean;
			if (useGroupedCallback)
				change = juggleGroupedCallback(oldTarget, newTarget, this, callback);
			else
				change = juggleImmediateCallback(oldTarget, newTarget, this, callback);
			
			if (change)
			{
				targetRef.value = newTarget;
				callback(); // call immediately after target change whether or not we are using a grouped callback
			}
		}
		
		public function dispose():void
		{
			callback = null;
			targetRef.value = null;
		}
	}
}

		/**
		 * @param relevantContext The owner of this CallbackJuggler.
		 * @param callback The callback function.
		 * @param useGroupedCallback If this is set to true, a grouped callback will be used instead of an immediate callback.
		 * @see weave.api.core.ICallbackCollection#addImmediateCallback() 
		 * @see weave.api.core.ICallbackCollection#addGroupedCallback() 
		 */
		public function CallbackJuggler(relevantContext:Object, callback:Function, useGroupedCallback:Boolean)
		{
			WeaveAPI.SessionManager.registerDisposableChild(relevantContext, this);
			if (useGroupedCallback)
				_callbacks.addGroupedCallback(null, callback);
			else
				_callbacks.addImmediateCallback(null, callback);
		}
		
		private var _callbacks:ICallbackCollection = new CallbackCollection();
		private var _target:ILinkableObject;
		
		/**
		 * This is the linkable object to which the callback has been added.
		 */		
		public function get target():ILinkableObject
		{
			return _target;
		}
		
		/**
