             }, completion: { cancelled in
                 self.dismissViewControllerAnimated(true, completion: nil)
         })
-
+        
         presentViewController(controller, animated: true, completion: nil)
     }
-
+    
     func capturePhotoTapped(sender: UIButton) {
         sender.enabled = false
         UIView.animateWithDuration(0.1, animations: { self.previewView.alpha = 0.0 }, completion: { finished in
             UIView.animateWithDuration(0.1, animations: {self.previewView.alpha = 1.0})
         })
-
+        
         captureManager.captureImage { (data, metadata) in
             sender.enabled = true
-
+            
             self.createAssetFromImageData(data, completion: self.didAddAsset)
         }
     }
-
+    
     private func didAddAsset(asset: Asset) {
         collectionView.performBatchUpdates({
             self.delegate?.photoCaptureViewController(self, didAddAsset: asset)

        }
        return CGRect.zeroRect
    }

    func createAssetFromImageData(data: NSData, completion: Asset -> Void) {
        storage.createAssetFromImageData(data, completion: completion)
    }

    func createAssetFromImage(image: UIImage, completion: Asset -> Void) {
        storage.createAssetFromImage(image, completion: completion)
    }

    func createAssetFromImageURL(imageURL: NSURL, dimensions: CGSize, completion: Asset -> Void) {
        storage.createAssetFromImageURL(imageURL, dimensions: dimensions, completion: completion)
    }

    /// Deletes item at the given index. Perform any deletions from datamodel in the handler
    func deleteAssetAtIndex(idx: Int, handler: () -> Void) {
        let indexPath = NSIndexPath(forItem: idx, inSection: 0)

    private var containerView: UIView!
    private var focusIndicatorView: UIView!
    private var flashButton: UIButton!
    
    deinit {
        captureManager.stop(nil)
    }
    
    override public func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = UIColor.blackColor()
        
        // TODO: Move all the boring view setup to a storyboard/xib
        
        previewView = UIView(frame: view.bounds)
        previewView.autoresizingMask = .FlexibleWidth | .FlexibleHeight
        view.addSubview(previewView)
        let previewLayer = captureManager.previewLayer
        // We are using AVCaptureSessionPresetPhoto which has a 4:3 aspect ratio
        var viewFinderWidth = view.bounds.size.width
        var viewFinderHeight = (viewFinderWidth/3) * 4
        if captureManager.viewfinderMode == .FullScreen {
            viewFinderHeight = view.bounds.size.height
        }
        previewLayer.frame = CGRectMake(0, 0, viewFinderWidth, viewFinderHeight)
        previewView.layer.addSublayer(previewLayer)
        
        focusIndicatorView = UIView(frame: CGRect(x: 0, y: 0, width: 64, height: 64))
        focusIndicatorView.backgroundColor = UIColor.clearColor()
        focusIndicatorView.layer.borderColor = UIColor.orangeColor().CGColor
        focusIndicatorView.layer.borderWidth = 1.0
        focusIndicatorView.alpha = 0.0
        previewView.addSubview(focusIndicatorView)
        
        flashButton = UIButton(frame: CGRect(x: 12, y: 12, width: 70, height: 38))
        flashButton.setImage(UIImage(named: "LightningIcon"), forState: .Normal)
        flashButton.setTitle(NSLocalizedString("Off", comment:"flash off"), forState: .Normal)
