                 }
                 self.cameraDevice.unlockForConfiguration()
             }
-
+            
             self.session.startRunning()
-
+            
             dispatch_async(dispatch_get_main_queue()) {
                 completion(error)
             }
         }
     }
-
+    
     private func cameraDeviceWithPosition(position: AVCaptureDevicePosition) -> AVCaptureDevice? {
         let availableCameraDevices = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo)
         for device in availableCameraDevices as! [AVCaptureDevice] {

            }
        }
    }

    func changeFlashMode(newMode: AVCaptureFlashMode, completion: () -> Void) {
        lockCurrentCameraDeviceForConfiguration { device in
            device.flashMode = newMode
            dispatch_async(dispatch_get_main_queue(), completion)
        }
    }

    // Next available flash mode, or nil if flash is unsupported
    func nextAvailableFlashMode() -> AVCaptureFlashMode? {
        if !hasFlash {
            return nil
        }

        // Find the next available mode, or wrap around
        var nextIndex = 0
        if let idx = find(supportedFlashModes, flashMode) {

        }
        let startIndex = min(nextIndex, supportedFlashModes.count)
        let next = supportedFlashModes[startIndex..<supportedFlashModes.count].first ?? supportedFlashModes.first
        
        return next
    }
    
    // Orientation change function required because we've locked the interface in portrait
    // and DeviceOrientation does not map 1:1 with AVCaptureVideoOrientation
    func changedOrientationNotification(notification: NSNotification?) {
        let currentDeviceOrientation = UIDevice.currentDevice().orientation
        switch currentDeviceOrientation {
        case .FaceDown, .FaceUp, .Unknown:
            break
        case .LandscapeLeft, .LandscapeRight, .Portrait, .PortraitUpsideDown:
            orientation = AVCaptureVideoOrientation(rawValue: currentDeviceOrientation.rawValue)!
        }
    }
    
    // MARK: - Private methods
    
    private func accessDeniedError(code: Int = FinjinonCameraAccessErrorDeniedCode) -> NSError {
        let info = [NSLocalizedDescriptionKey: NSLocalizedString("Camera access denied, please enable it in the Settings app to continue", comment: "")]
        return NSError(domain: FinjinonCameraAccessErrorDomain, code: code, userInfo: info)
    }
    
    private func lockCurrentCameraDeviceForConfiguration(configurator: AVCaptureDevice -> Void) {
        dispatch_async(captureQueue) {
            var error: NSError?
            if !self.cameraDevice.lockForConfiguration(&error) {
                NSLog("Failed to lock camera device for configuration: \(error)")
            }
            
            configurator(self.cameraDevice)
            
            self.cameraDevice.unlockForConfiguration()
        }
    }
    
    private func configure(completion: NSError? -> Void) {
        dispatch_async(captureQueue) {
            self.cameraDevice = self.cameraDeviceWithPosition(.Back)
            
            var error: NSError?
            if let input = AVCaptureDeviceInput.deviceInputWithDevice(self.cameraDevice, error: &error) as? AVCaptureDeviceInput {
                if self.session.canAddInput(input) {
