     super.viewDidLoad()
     
     if let mtkView = self.view as? MTKView {
-        mtkView.device = MTLCreateSystemDefaultDevice()
+        mtkView.device = VideoSessionController.device
         renderer = VSRenderer(view: mtkView)
         renderer?.mtkView(mtkView, drawableSizeWillChange: mtkView.drawableSize)
         mtkView.delegate = renderer

    startVideoCaptureSession()
  }
  
  override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    metalLayer.frame = view.layer.frame
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.

    CVMetalTextureCacheCreate(nil, nil, VideoSessionController.device, nil, &cache)
    return cache!
  }()
  
  // Debug only for Metal
  let vertexData:[Float] = [ -1.0, -1.0,  0.0, 1.0,
