 			if (e._typePrev) e._typePrev._typeNext = e._typeNext;
 			e._typeNext = e._typePrev = null;
 			_typeCount[e._type] --;
-		}
-		
-		/** @private Removes all nulls from the array. */
-		private static function removeNulls(a:Array):void
-		{
-			var i:int = 0,
-				j:int = a.length;
-			if (j == 1 && a[0] == null)
-			{
-				a.length = 0;
-				return;
-			}
-			while (i < j)
-			{
-				while (a[i] != null) i ++;
-				while (a[j] == null) j --;
-				a[i] = a[j];
-				a[j] = null;
-			}
-			a[j] = a[i];
-			a[i] = null;
-			a.length -= a.length - a.indexOf(null);
-		}
-		
-		/** @private Quicksorts the values in the array. */
-		private static function sort(a:Array, left:int, right:int):void
-		{
-			var i:int = left,
-				j:int = right,
-				p:int = a[Math.round((left + right) * .5)],
-				t:int;
-			while (i <= j)
-			{
-				while (a[i] < p) i ++;
-				while (a[j] > p) j --;
-				if (i <= j)
-				{
-					t = a[i];
-					a[i ++] = a[j];
-					a[j --] = t;
-				}
-			}
-			if (left < j) sort(a, left, j);
-			if (i < right) sort(a, i, right);
-			return;
 		}
 		
 		/** @private Calculates the squared distance between two rectangles. */

			return into;
		}
		
		/** @private Updates the add/remove lists at the end of the frame. */
		internal function updateLists():void
		{
			var e:Entity;
			

			if (e._renderPrev) e._renderPrev._renderNext = e._renderNext;
			else
			{
				// Remove this entity from the layer.
				_renderFirst[e._layer] = e._renderNext
				if (!e._renderNext)
				{
					// Remove the layer from the layer list if this was the last entity.
					if (_layerList.length > 1)
					{
						_layerList[_layerList.indexOf(e._layer)] = _layerList[_layerList.length - 1];
						_layerSort = true;
					}
					_layerList.length --;
				}
			}
			_layerCount[e._layer] --;
