     override func viewDidDisappear(animated: Bool){
         captureSession.stopRunning();
     }
-    override func viewDidAppear(animated: Bool){ captureSession.startRunning() }
-    
+    override func viewDidAppear(animated: Bool){
+        captureSession.startRunning()
+    }
+
     override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { return UIInterfaceOrientationMask.All }
-    
+
     override func didReceiveMemoryWarning() {
         super.didReceiveMemoryWarning()
         // Dispose of any resources that can be recreated.
     }
-    
+
     override func prefersStatusBarHidden() -> Bool {
         return true
     }
-    
+
     override func shouldAutorotate() -> Bool {
         return false
     }
-    
+
     override func willRotateToInterfaceOrientation(newOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
         (camPreview.layer as! AVCaptureVideoPreviewLayer).connection.videoOrientation = AVCaptureVideoOrientation(rawValue: newOrientation.rawValue)!
-        
+
         if(newOrientation == UIInterfaceOrientation.LandscapeLeft || newOrientation == UIInterfaceOrientation.LandscapeRight){
             (camPreview.layer as! AVCaptureVideoPreviewLayer).videoGravity = AVLayerVideoGravityResizeAspect
         }
         else{
             (camPreview.layer as! AVCaptureVideoPreviewLayer).videoGravity = AVLayerVideoGravityResizeAspectFill
         }
-        
+
         //TODO implement asset rotation something like this let PortraitImage  : UIImage = UIImage(CGImage: LandscapeImage.CGImage ,
          //scale: 1.0 ,
          //orientation: UIImageOrientation.Right)
     }
-    
+
     //MARK: AVFoundation Implementation
     func beginSession(){
         let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
+
         let orientation: AVCaptureVideoOrientation =  AVCaptureVideoOrientation(rawValue: self.interfaceOrientation.rawValue)!
         previewLayer.connection.videoOrientation = orientation;
         camPreview.layer.addSublayer(previewLayer)
-        previewLayer?.frame = self.view.bounds
+
+        previewLayer.frame = CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height)
+        previewLayer.bounds = CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height)
         previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
         captureSession.startRunning()
     }
-    
+
     //MARK: IB Outlets and Actions
     @IBOutlet weak var camPreview: UIView!
     @IBOutlet weak var flashUIButton: UIButton!

        }
        return captureDevice
    }
    
    func setFlashModeToAuto(device: AVCaptureDevice){
            do{
                try device.lockForConfiguration();
                if(backCameraDevice!.hasFlash){
                    if(backCameraDevice!.isFlashModeSupported(AVCaptureFlashMode.Auto)){
                        device.flashMode = AVCaptureFlashMode.Auto;
                        let image = UIImage(named: "camera_flash_auto.png") as UIImage!

    @IBOutlet weak var LRuii: UIImageView!
    @IBOutlet weak var badgeBg: UIImageView!
    @IBOutlet weak var badgeCount: UILabel!

    @IBAction func flashToggle(sender: UIButton) {
        toggleFlashMode(backCameraDevice!)
    }

    @IBAction func cancelSession(sender: AnyObject) {
        resetThumbImages()
        let pathJSON = jsonGen.getFinalJSON(dest: "cancel", save: false)
        setFlashModeToAuto(backCameraDevice!)
        delegate.cameraFinished(self, JSON: pathJSON)
    }

    @IBAction func cameraFinishToQueue(sender: UIButton) {
        resetThumbImages()
        let pathJSON = jsonGen.getFinalJSON(dest: "queue", save: true)
        setFlashModeToAuto(backCameraDevice!)
        delegate.cameraFinished(self, JSON: pathJSON)
    }

    func resetThumbImages(){
        ULuii.image = UIImage(named:"gray.png")
        URuii.image = UIImage(named:"gray.png")
        LLuii.image = UIImage(named:"gray.png")
        LRuii.image = UIImage(named:"gray.png")
    }

    @IBAction func captureImage(sender: UIButton){
        let connection = stillImageOutput?.connectionWithMediaType(AVMediaTypeVideo)
        stillImageOutput?.captureStillImageAsynchronouslyFromConnection(connection, completionHandler:
