             self.presentViewController(alert, animated: true, completion: nil)
         }
         
-        println("  - Setting auto theme = false")
-        self.config.setBool(false, forKey: "useAutoTheme")
+        dispatch_async(dispatch_get_main_queue(), {
+            println("  - Setting auto theme = false")
+            self.config.setBool(false, forKey: "useAutoTheme")
+            self.themeAutoSwitch.on = false
+        })
         
     }
     

        config.setBool(sender.on, forKey: "useAutoTheme")
        
        if sender.on == true {
            self.requestCameraAccess()
        }
    }
    
    
    func requestCameraAccess() {
        AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { (access: Bool) -> Void in
            println("Camera access status: \(access)")
            var alert = UIAlertController(
                title: "Theme Switching Disabled",
                message: "This app does not have access to the camera. " +
                    "Because of this theme switching has been disabled.\n\n" +
                    "To be able to switch themes automatically the camera is needed to " +
                    "measure light levels.\n\n" +
                    "If you wish to use this feature, please go to the iOS " +
                    "Settings for Garage Opener to enable access to the camera.",
                preferredStyle: UIAlertControllerStyle.Alert
            )
            alert.addAction(UIAlertAction(
                title: "OK",
                style: UIAlertActionStyle.Default,
                handler: nil
            ))
            
            if access == false {
                self.presentViewController(alert, animated: true, completion: { () -> Void in
                    self.config.setBool(false, forKey: "useAutoTheme")
                    self.themeAutoSwitch.setOn(false, animated: false)
                })
            }
        })
    }
    
    @IBAction func handleShowPasswordChange(sender: UISwitch) {
        passwordField.secureTextEntry = !sender.on
        config.setBool(sender.on, forKey: "showPassword")

    var config = NSUserDefaults.standardUserDefaults()
    var nc     = NSNotificationCenter.defaultCenter()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
