             _filterBufferSize = size
             setContents(arguments)
         } else {
+            buffer = nil
+            _filterBufferData = nil
+            _filterBufferSize = 0
             return nil
         }
     }
     
     required init!(base:UnsafePointer<Void>, size:Int) {
         if base != nil {
+            buffer = nil
             _filterBufferData = base
             _filterBufferSize = size
         } else {
+            buffer = nil
+            _filterBufferData = nil
+            _filterBufferSize = 0
             return nil
         }
     }

                }
            }
        } else {
            return nil
        }
    }
    
    subscript (element:Int) -> T {
        get {
            assert(element >= 0 && element < _count, "Index out of range")
            return _members[element]
        }
    }

    func bufferAndOffsetForElement(element:Int) -> (MTLBuffer, Int){
        assert(element >= 0 && element < _count, "Index out of range")
        return (buffer!,_filterBufferSize * element)
    }
    
    func offsetForElement(element:Int) -> Int {
        assert(element >= 0 && element < _count, "Index out of range")
        return _filterBufferSize * element
    }
    
    var count:Int {
        return _count
    }
}

// type takes in a UIColor or CGFloats and writes them out as an
// 8-bit per channel RGBA vector
struct Color {
    private var _base:UnsafeMutablePointer<UInt8> = nil
    init(buffer:UnsafeMutablePointer<UInt8>) {
        _base = buffer
    }



class MetalBuffer {
    let buffer:MTLBuffer?
    internal let _filterBufferData:UnsafePointer<Void>
    internal let _filterBufferSize:Int
    
    init!(arguments:MTLArgument) {
        let size = arguments.bufferDataSize
