// Returns true if it found the script loaded and decremented the refcount.
        private bool PerformUnloadRequest(LoadUnloadRequest unloadReq)
        {
            bool rc = false;

            // Find based on the item ID
            VM.Interpreter loadedScript = _exeScheduler.FindScript(unloadReq.ItemId);

            if (loadedScript != null)
            {
                LoadedScript reffedScript;

                //tell the scheduler the script needs to be pulled
                _exeScheduler.DoUnload(unloadReq.ItemId, unloadReq);

                //tell the async command manager that it needs to remove this script
                AsyncCommandManager.RemoveScript(_engineInterface, unloadReq.LocalId, unloadReq.ItemId);

                //tell the state manager to remove this script
                _stateManager.ScriptUnloaded(unloadReq.ItemId);

                //decref and unload if refcount is 0 based on the Asset ID
                if (_loadedScripts.TryGetValue(loadedScript.Script.AssetId, out reffedScript))
                {
                    if (--reffedScript.RefCount == 0)
                    {
                        _loadedScripts.Remove(loadedScript.Script.AssetId);
                        _unloadedScriptCache.Add(loadedScript.Script.AssetId, loadedScript.Script);
                    }

                    rc = true;
                }
            }

            // Callback here because if the Item ID was not found, the callback would be meaningless
            if (unloadReq.PostUnloadCallback != null)
            {
                // Now call the completion callback (e.g. now that it is safe for the script to be removed in the delete case).
                unloadReq.PostUnloadCallback(unloadReq.Prim, unloadReq.ItemId, unloadReq.CallbackParams.AllowedDrop, unloadReq.CallbackParams.FireEvents, unloadReq.CallbackParams.ReplaceArgs);
            }

            return(rc);
        }