     if node == nil
     {
       node = UnsafeMutablePointer<Node<T>>.alloc(1)
-      node.memory.elem = UnsafeMutablePointer<T>.alloc(1)
+      node.memory = Node(UnsafeMutablePointer<T>.alloc(1))
     }
     node.memory.next = nil
     node.memory.elem.initialize(newElement)
 
     OSSpinLockLock(&tlock)
+    // hopefully tail.memory.next is stored atomically
+    // this is the one possible collision between dequeue() and enqueue()
     tail.memory.next = node
     tail = node
     OSSpinLockUnlock(&tlock)


private struct Node<T>
{
  var nptr: COpaquePointer = nil
  var elem: UnsafeMutablePointer<T>

  init(_ p: UnsafeMutablePointer<T>)
  {

  }

  var next: UnsafeMutablePointer<Node<T>> {
    get { return UnsafeMutablePointer(nptr) }
    set { nptr = UnsafeMutablePointer(newValue) }
  }
}
