 
   // MARK: State Handling
 
-  var rawState: Int32 { return currentState }
-  var state: ChannelSemaphoreState { return ChannelSemaphoreState(rawValue: currentState)! }
-
-  func setState(newState: ChannelSemaphoreState) -> Bool
+  enum State: Int32
+  {
+    case Ready
+
+    // Unbuffered channel data
+    case Pointer
+
+    // Select() case
+    case WaitSelect
+    case Select
+    case DoubleSelect
+    case Invalidated
+    
+    // End state
+    case Done
+  }
+  
+  private var currentState = State.Ready.rawValue
+
+  var state: State { return State(rawValue: currentState)! }
+
+  func setState(newState: State) -> Bool
   {
     switch newState
     {
     case .Pointer, .WaitSelect:
-      return OSAtomicCompareAndSwap32Barrier(ChannelSemaphoreState.Ready.rawValue, newState.rawValue, &currentState)
+      return OSAtomicCompareAndSwap32Barrier(State.Ready.rawValue, newState.rawValue, &currentState)
 
     case .Select, .Invalidated, .DoubleSelect:
-      return OSAtomicCompareAndSwap32Barrier(ChannelSemaphoreState.WaitSelect.rawValue, newState.rawValue, &currentState)
+      return OSAtomicCompareAndSwap32Barrier(State.WaitSelect.rawValue, newState.rawValue, &currentState)
 
     case .Done:
-      // Ideally it would be: __sync_swap(&currentState, ChannelSemaphoreState.Done.rawValue)
-      // Or maybe: __c11_atomic_exchange(&currentState, ChannelSemaphoreState.Done.rawValue, __ATOMIC_SEQ_CST)
-      while OSAtomicCompareAndSwap32Barrier(currentState, ChannelSemaphoreState.Done.rawValue, &currentState) == false {}
+      // Ideally it would be: __sync_swap(&currentState, State.Done.rawValue)
+      // Or maybe: __c11_atomic_exchange(&currentState, State.Done.rawValue, __ATOMIC_SEQ_CST)
+      while OSAtomicCompareAndSwap32Barrier(currentState, State.Done.rawValue, &currentState) == false {}
       return true
 
     default:

          OSSpinLockUnlock(&lock)
          s.svalue = 0
          s.iptr = nil
          s.currentState = ChannelSemaphoreState.Ready.rawValue
          return s
        }
      }


  var pointer: UnsafeMutablePointer<Void> {
    get {
      if currentState == State.Pointer.rawValue ||
         currentState == State.DoubleSelect.rawValue
      { return iptr }
      else
      { return nil }
    }
    set {
      if currentState == State.Pointer.rawValue ||
         currentState == State.DoubleSelect.rawValue
      { iptr = newValue }
      else
      { iptr = nil }
    }
  }


  private var seln: Selection? = nil

  var selection: Selection! {
    get {
      if currentState == State.Select.rawValue ||
         currentState == State.DoubleSelect.rawValue
      { return seln }
      else
      { return nil }
    }
    set {
      if currentState == State.Select.rawValue ||
         currentState == State.DoubleSelect.rawValue
      { seln = newValue }
      else
      { seln = nil }
