         
         self.computeCommandEncoder?.endEncoding();
         
-        self.commandBuffer?.addCompletedHandler({ (commandBuffer : MTLCommandBuffer) -> Void in
-            let data = NSData(bytesNoCopy: outputBuffer.contents(), length: self.pointCloud.count * sizeof(OSPoint), freeWhenDone: false);
+        self.commandBuffer?.addCompletedHandler({[unowned self] (commandBuffer : MTLCommandBuffer) -> Void in
+            let data = NSData(bytesNoCopy: outputBuffer.contents(), length: (self.pointCloud?.count)! * sizeof(OSPoint), freeWhenDone: false);
             data.getBytes(&self.pointCloud, length: outputByteLength);
             
             let elapsedTime : CFTimeInterval = CACurrentMediaTime() - startTime;
             print("Total process \(elapsedTime) seconds");
+            
+            completionHandler?();
         });
         
         self.commandBuffer?.commit();
     }
     
-    func unitTest(multiplier : Float)
-    {
-        for (var x : Int = 0; x < self.notCalibratedDepth.count; x++)
-        {
-            self.notCalibratedDepth[x] = Float(x) * multiplier;
-        }
-        
-        self.prepareMetalForSurgery();
-    }
-    
-    init()
-    {
-        OSBaseFrame.loadContent(nil);
-    }
+// MARK: OSContentLoadingProtocol
 
     static func loadContent(completionHandler : (() -> Void)!)
     {

        self.computeCommandEncoder?.setBuffer(outputBuffer, offset: 0, atIndex: 1);
        self.computeCommandEncoder?.setBuffer(OSBaseFrame.calibrationMatrixBuffer, offset: 0, atIndex: 2);
        
        let threadGroupCountX = dataSize / 512;
        let threadGroupCount = MTLSize(width: threadGroupCountX, height: 1, depth: 1)
        let threadGroups = MTLSize(width:(dataSize + threadGroupCountX - 1) / threadGroupCountX, height:1, depth:1);

        self.computeCommandEncoder?.setComputePipelineState(OSBaseFrame.metalComputePipelineState!);
        
        //pass the data to GPU
        let dataSize : Int = self.notCalibratedDepth!.count//self.height * self.width;

        let inputByteLength = dataSize * sizeof(Float);
        let inVectorBuffer = OSBaseFrame.device.newBufferWithBytes(&self.notCalibratedDepth, length: inputByteLength, options:[]);
