     override init() {
         super.init()
         
-        nc.addObserver(self, selector: Selector("appWillResignActive"), name: UIApplicationWillResignActiveNotification, object: nil)
-        
-        nc.addObserver(self, selector: Selector("appDidBecomeActive"), name: UIApplicationDidBecomeActiveNotification, object: nil)
+        nc.addObserver(
+            self,
+            selector: Selector("appDidEnterBackground"),
+            name: UIApplicationDidEnterBackgroundNotification,
+            object: nil)
+        
+        nc.addObserver(
+            self,
+            selector: Selector("appWillEnterForeground"),
+            name: UIApplicationWillEnterForegroundNotification,
+            object: nil
+        )
         
         let queue = dispatch_queue_create("no.malt", DISPATCH_QUEUE_SERIAL)
         centralManager = CBCentralManager(delegate: self, queue: queue)
         
-        NSTimer.scheduledTimerWithTimeInterval(2.0, target: self, selector: Selector("doReadRSSI"), userInfo: nil, repeats: true)
+        rssiTimer = NSTimer.scheduledTimerWithTimeInterval(
+            2.0,
+            target: self,
+            selector: Selector("doReadRSSI"),
+            userInfo: nil,
+            repeats: true
+        )
     }
     
     func sayHello() -> String {

    }
    
    
    func appDidBecomeActive() {
        println("Discovery Manager: did become active")
        
        if self.centralManager?.state == CBCentralManagerState.PoweredOn {
            self.startScanning()

    }
    
    
    func appDidEnterBackground() {
        println("Discovery Manager: did enter background")
        
        if (self.activePeripheral == nil) {
            println("  Got nil activePeripheral. Not connected.")
