         yield(manager)
         manager.startUpdatingLocation()
         manager.promise.always {
-            manager.delegate = nil
-            manager.stopUpdatingLocation()
+            CLLocationManager.promiseDoneForLocationManager(manager)
         }
         return manager.promise
     }

#if os(iOS)
    @objc func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        fulfill(locations)
    }
#else
    @objc func locationManager(manager: CLLocationManager, didUpdateLocations ll: [AnyObject]) {
        let locations = ll as! [CLLocation]
        fulfill(locations)
    }
#endif

    @objc func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
        reject(error)
    }
}


        case Always
        case WhenInUse
    }

    private class func promiseDoneForLocationManager(manager: CLLocationManager) -> Void {
        manager.delegate = nil
        manager.stopUpdatingLocation()
    }
  
    /**
      @return A new promise that fulfills with the most recent CLLocation.
