          */
         public function setObject(instance:Object):void
         {
-            _inUse.pop();
+            if (!instance) return;
             
-            if (!instance) return;
-
-            if (_bounded && _available.length >= _maxSize)
+            if (instance in _inUse)
+            {
+                delete _inUse[instance];
+                _inUseCount--;
+            }
+
+            if (_bounded && _availableCount >= _maxSize)
             {
                 if (destroyFunction != null) destroyFunction(instance);
                 


        public var maxSizeException:Boolean = true;

        protected var _available:Vector.<Object> = new Vector.<Object>;
        protected var _inUse:Vector.<Object> = new Vector.<Object>;
        protected var _callbacks:Vector.<Function> = new Vector.<Function>;

        protected var _minSize:uint;


        public function getObject():Object
        {
            if (_bounded && _inUseCount >= _maxSize)
            {
                if (maxSizeException)
                {
                    throw new IllegalOperationError("ObjectPool size exceeded maxSize");
                }
                return _instantiateFunction();
            }

            var instance:Object;
            for (instance in _available)
            {
                break;
            }
            
            if (instance)
            {
                delete _available[instance];
                _availableCount--;
            }
            else
            {
                instance = _instantiateFunction();
            }
            
            _inUse[instance] = null;
            _inUseCount++;
            return instance;
        }

