     }
 }
 
-private enum State {
-    case Pending
-    case Fulfilled
-    case Rejected
+private class PendingInfo<T> {
+    let parent: (() -> Any)?
+    var deferred: Promise<T>? = nil
+    var onFulfilled: Array<T -> ()> = []
+    var onRejected: Array<Error -> ()> = []
+    
+    private init() {
+        self.parent = nil
+    }
+
+    private init(parent: () -> Any) {
+        self.parent = parent
+    }
+}
+
+private enum State<T> {
+    case Pending(PendingInfo<T>)
+    case Fulfilled(Value<T>)
+    case Rejected(Error)
 }
 
 public enum Result<T> {


public class Promise<T> : Synchronizable {
    public let synchronizationQueue: DispatchQueue
    private var state: State = .Pending
    private var result: Result<T>? = nil
    private var parent: (() -> Any)? = nil
    private var onFulfilled: Array<(T) -> ()>! = []
    private var onRejected: Array<(Error) -> ()>! = []
    
    public init(_ resolver: (fulfill: T -> (), reject: Error -> (), isCancelled: () -> Bool) -> ()) {
        self.parent = nil
        self.synchronizationQueue = GCDQueue.serial("net.franticapparatus.Promise")
        
        let weakFulfill: T -> () = { [weak self] value in

    }
    
    private init(parent: () -> Any, synchronizationQueue: DispatchQueue, resolver: (Result<T> -> ()) -> ()) {
        self.state = .Pending(PendingInfo(parent: parent))
        self.synchronizationQueue = synchronizationQueue
        
        let weakResolve: Result<T> -> () = { [weak self] result in
