         else if newCount > common {
             openGapAt(range.startIndex + common, length: newCount - common)
             let p = elements
-            var q = p.advancedBy(bufferIndexForDequeIndex(range.startIndex + common))
-            let limit = p.advancedBy(capacity)
-            var i = newElements.startIndex.advancedBy(numericCast(common))
+            var q = p.advanced(by: bufferIndexForDequeIndex(range.startIndex + common))
+            let limit = p.advanced(by: capacity)
+            var i = newElements.startIndex.advanced(by: numericCast(common))
             while i != newElements.endIndex {
-                q.initialize(newElements[i])
+                q.initialize(with: newElements[i])
                 i = i.successor()
                 q = q.successor()
                 if q == limit { q = p }

        }
        return capacity - start + i
    }

    internal var isFull: Bool { return count == capacity }

    internal subscript(index: Int) -> Element {
        get {
            assert(index >= 0 && index < count)
            let i = bufferIndexForDequeIndex(index)
            return elements.advancedBy(i).memory
        }
        set {
            assert(index >= 0 && index < count)
            let i = bufferIndexForDequeIndex(index)
            elements.advancedBy(i).memory = newValue
        }
    }

    internal func prepend(element: Element) {
        precondition(count < capacity)
        let i = start == 0 ? capacity - 1 : start - 1
        elements.advancedBy(i).initialize(element)
        self.start = i
        self.count += 1
    }

    internal func popFirst() -> Element? {
        guard count > 0 else { return nil }
        let first = elements.advancedBy(start).move()
        self.start = bufferIndexForDequeIndex(1)
        self.count -= 1
        return first
    }

    internal func append(element: Element) {
        precondition(count < capacity)
        let endIndex = bufferIndexForDequeIndex(count)
        elements.advancedBy(endIndex).initialize(element)
        self.count += 1
    }

    internal func popLast() -> Element? {
        guard count > 0 else { return nil }
        let lastIndex = bufferIndexForDequeIndex(count - 1)
        let last = elements.advancedBy(lastIndex).move()
        self.count -= 1
        return last
    }

    /// Create a gap of `length` uninitialized slots starting at `index`.
    /// Existing elements are moved out of the way.
    /// You are expected to fill the gap by initializing all slots in it after calling this method.

        makeUniqueWithCapacity(grow(count + 1))
        buffer.append(newElement)
    }
    
    /// Append `newElements` to the end of this queue.
    public mutating func appendContentsOf<S: Sequence where S.Iterator.Element == Element>(newElements: S) {
        makeUniqueWithCapacity(self.count + newElements.underestimatedCount)
        var capacity = buffer.capacity
        var count = buffer.count
        var generator = newElements.makeIterator()
        var next = generator.next()
        while next != nil {
            if capacity == count {
