         }
         
         self.callbacks.removeAll()
-    }
-    
-    private func executionContextForCurrentContext() -> ExecutionContext {
-        return toContext(NSThread.isMainThread() ? Queue.main : Queue.global)
     }
 }
 

        return p.future
    }

    public func andThen(callback: Result<T> -> ()) -> Future<T> {
        return self.andThen(context: executionContextForCurrentContext(), callback: callback)
    }

    public func andThen(context c: ExecutionContext, callback: Result<T> -> ()) -> Future<T> {
        let p = Promise<T>()
        
        self.onComplete(context: c) { result in

 */
public extension Future {

    public func flatMap<U>(context c: ExecutionContext = executionContextForCurrentContext(), f: T -> Future<U>) -> Future<U> {
        let p: Promise<U> = Promise()
        self.onComplete(context: c) { res in
            switch (res) {
