                 }
             }
         } else {
+            buffer = nil
+            _filterBufferData = nil
+            _filterBufferSize = 0
             return nil
         }
     }
     
     subscript (element:Int) -> T {
         get {
-            assert(element >= 0 && element < _count, "Index out of range")
+            assert(element >= 0 && element < _members.count , "Index out of range")
             return _members[element]
         }
     }
 
     func bufferAndOffsetForElement(element:Int) -> (MTLBuffer, Int){
-        assert(element >= 0 && element < _count, "Index out of range")
+        assert(element >= 0 && element < _members.count , "Index out of range")
         return (buffer!,_filterBufferSize * element)
     }
     
     func offsetForElement(element:Int) -> Int {
-        assert(element >= 0 && element < _count, "Index out of range")
+        assert(element >= 0 && element < _members.count , "Index out of range")
         return _filterBufferSize * element
     }
     
     var count:Int {
-        return _count
+        return _members.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
+    private let _base:UnsafeMutablePointer<UInt8>
     init(buffer:UnsafeMutablePointer<UInt8>) {
         _base = buffer
     }

}

class MetalBufferArray<T:MetalBuffer> {
    var buffer:MTLBuffer? = nil
    internal var _filterBufferData:UnsafePointer<Void> = nil
    internal var _filterBufferSize:Int = 0
    lazy internal var _members = [T]()
    internal var _count:Int = 0
    
    init!(arguments:MTLArgument, count:Int){
        let size = arguments.bufferDataSize



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