 
   // MARK: private methods
 
-  private func setState(newState: DeferredState) -> Bool
+  private func beginExecution()
   {
-    switch newState
-    {
-    case .Waiting:
-      return currentState == DeferredState.Waiting.rawValue
+    OSAtomicCompareAndSwap32Barrier(DeferredState.Waiting.rawValue, DeferredState.Executing.rawValue, &currentState)
+  }
 
-    case .Executing:
-      return OSAtomicCompareAndSwap32Barrier(DeferredState.Waiting.rawValue, DeferredState.Executing.rawValue, &currentState)
-
-    case .Assigning:
-      return OSAtomicCompareAndSwap32Barrier(DeferredState.Executing.rawValue, DeferredState.Assigning.rawValue, &currentState)
-
-    case .Determined:
-      if OSAtomicCompareAndSwap32Barrier(DeferredState.Assigning.rawValue, DeferredState.Determined.rawValue, &currentState)
+  private func setValue(value: T) throws
+  {
+    // A turnstile to ensure only one thread can succeed
+    repeat
+    { // Allow multiple tries in case another thread concurrently switches state from .Waiting to .Executing
+      let initialState = currentState
+      if initialState < DeferredState.Determined.rawValue
       {
-        dispatch_group_leave(group)
-        return true
+        OSAtomicCompareAndSwap32Barrier(initialState, transientState, &currentState)
       }
-      return currentState == DeferredState.Determined.rawValue
-    }
-  }
-  
-  private func setValue(value: T) throws
-  { // A very simple turnstile to ensure only one thread can succeed
-    guard setState(.Assigning) else
-    {
-      if currentState == DeferredState.Determined.rawValue
+      else
       {
-        throw DeferredError.AlreadyDetermined("Failed attempt to determine Deferred twice with \(__FUNCTION__)")
+        assert(currentState >= DeferredState.Determined.rawValue)
+        throw DeferredError.AlreadyDetermined("Attempted to determine Deferred twice with \(__FUNCTION__)")
       }
-      throw DeferredError.CannotDetermine("Deferred in wrong state at start of \(__FUNCTION__)")
-    }
+    } while currentState != transientState
 
     v = value
 
-    guard setState(.Determined) else
-    { // We cannot know where to go from here. Happily getting here seems impossible.
-      fatalError("Could not complete assignment of value in \(__FUNCTION__)")
+    guard OSAtomicCompareAndSwap32Barrier(transientState, DeferredState.Determined.rawValue, &currentState) else
+    { // Getting here seems impossible, but try to handle it gracefully.
+      throw DeferredError.CannotDetermine("Failed to determine Deferred")
     }
 
+    dispatch_group_leave(group)
     // The result is now available for the world
   }
 
   // MARK: public interface
 
-  public var state: DeferredState { return DeferredState(rawValue: currentState)! }
+  public var state: DeferredState { return DeferredState(rawValue: currentState) ?? .Executing }
 
   public var isDetermined: Bool { return currentState == DeferredState.Determined.rawValue }
 


  public func determine(value: T) throws
  {
    super.setState(.Executing)
    try super.setValue(value)
  }

  public func beginExecution()
  {
    super.setState(.Executing)
  }
}

  {
    self.init()

    currentState = DeferredState.Executing.rawValue
    dispatch_async(queue) {
      try! self.setValue(task())
    }
