         )
     }
     
-
+    /// Called to start scanning for devices.
+    /// Also sets a timer to stop scanning after a given time.
     func startScanning() {
         if let central = self.centralManager {
             if central.state == CBCentralManagerState.PoweredOff {

        
        println("Stopping scan!")
        central.stopScan()
    }
    
    
    func centralManager(central: CBCentralManager!, didDisconnectPeripheral peripheral: CBPeripheral!, error: NSError!) {
        println("Called did Disconnect Peripheral: \(peripheral)")
        

    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() {
