         print("Setting offscreen texure resolution to \(textureWidth)x\(textureHeight)\n")
         
         let descriptor = MTLTextureDescriptor.texture2DDescriptorWithPixelFormat(.BGRA8Unorm, width: textureWidth, height: textureHeight, mipmapped: false)
-        _intermediateTextures.removeAll(keepCapacity: true)
-        _intermediateRenderPassDescriptor.removeAll(keepCapacity: true)
-        for i in (0...1) {
-            let texture = _device.newTextureWithDescriptor(descriptor)
+        
+        _intermediateTextures = [descriptor,descriptor].map { self._device.newTextureWithDescriptor($0) }
+        _intermediateRenderPassDescriptor = _intermediateTextures.map {
             let renderDescriptor = MTLRenderPassDescriptor()
-            renderDescriptor.colorAttachments[0].texture = texture
+            renderDescriptor.colorAttachments[0].texture = $0
             renderDescriptor.colorAttachments[0].loadAction = .DontCare
             renderDescriptor.colorAttachments[0].storeAction = .DontCare
-            
-            _intermediateTextures.append(texture)
-            _intermediateRenderPassDescriptor.append(renderDescriptor)
-        }
-
+            return renderDescriptor
+        }
+        
         _rgbTexture = _device.newTextureWithDescriptor(descriptor)
         _rgbDescriptor = MTLRenderPassDescriptor()
         _rgbDescriptor.colorAttachments[0].texture = _rgbTexture

                    renderEncoder.setViewport(view)
                }
                renderEncoder.setRenderPipelineState(pipeline)
                for i in 0..<vertexBuffers.count {
                    renderEncoder.setVertexBuffer(vertexBuffers[i].0, offset: vertexBuffers[i].1, atIndex: i)
                }
                for i in 0..<fragmentBuffers.count {
                    renderEncoder.setFragmentBuffer(fragmentBuffers[i].0, offset: fragmentBuffers[i].1, atIndex: i)
                }
                for i in 0..<sourceTextures.count {
                    renderEncoder.setFragmentTexture(sourceTextures[i], atIndex: i)
                }
                for i in 0..<_samplerStates.count {
                    renderEncoder.setFragmentSamplerState(_samplerStates[i], atIndex: i)
                }
                renderEncoder.drawPrimitives(.Triangle, vertexStart: 0, vertexCount: 6, instanceCount: 1)
                renderEncoder.popDebugGroup()
                renderEncoder.endEncoding()

        if _device.supportsFeatureSet(._iOS_GPUFamily2_v1) {
            println("Using high quality blur...")
            highQuality = true
            _blurPipelineStates = ["BlurX_HQ", "BlurY_HQ"].map {self.cachedPipelineStateFor($0)!}
            let fragmentArgs = (_shaderArguments["BlurX_HQ"]!.fragmentArguments as! [MTLArgument]).filter({$0.name == "blurParameters"})
            if fragmentArgs.count == 1 {
                _blurArgs = MetalBufferArray<BlurBuffer>(arguments: fragmentArgs[0], count: _numberShaderBuffers)
            }
        } else {
            highQuality = false
            _blurPipelineStates = ["BlurX", "BlurY"].map {self.cachedPipelineStateFor($0)!}
            let fragmentArgs = (_shaderArguments["BlurX"]!.fragmentArguments as! [MTLArgument]).filter({$0.name == "blurParameters"})
            if fragmentArgs.count == 1 {
                _blurArgs = MetalBufferArray<BlurBuffer>(arguments: fragmentArgs[0], count: _numberShaderBuffers)
