     func resetConnection() {
         self.activeService = nil
         self.activePeripheral = nil
-        
+        self.resetScanTimeout()
+    }
+    
+    /// This function invalidates the timer which cancels the scanning after
+    /// a given interval.
+    func resetScanTimeout() {
         if let scan = self.scanTimeout {
             if scan.valid == true {
                 scan.invalidate()
             }
         }
     }
-    
     
     /// handler for NSTimer to stop the scanner after a set interval.
     func handleCheckAndStopScan() {

    }
    
    
    func centralManager(
        central: CBCentralManager!,
        didDiscoverPeripheral peripheral: CBPeripheral!,
        advertisementData: [NSObject : AnyObject]!,
        RSSI: NSNumber!) {
        
        let uuid = peripheral.identifier.UUIDString;
        

        
        println("Stopping scan!")
        central.stopScan()
        self.resetScanTimeout()
        
    }
    
    
    /// called when thing disconnects.
    func centralManager(central: CBCentralManager!, didDisconnectPeripheral peripheral: CBPeripheral!, error: NSError!) {
        println("Called did Disconnect Peripheral: \(peripheral)")
        
