 
 public struct RangeSet<Bound : Comparable> {
     
-    public let lowerBounds: [Bound]
-    public let upperBounds: [Bound]
+    fileprivate let ranges: [Range<Bound>]
     
     public init() {
-        self.lowerBounds = []
-        self.upperBounds = []
+        self.ranges = []
     }
     public init(_ ranges: Range<Bound> ... ) {
         self.init(ranges)

        self = s.reduce(RangeSet()) { $0.union($1) }
    }
    
    fileprivate init(bounds: [Range<Bound>]) {
        let sorted = bounds.sorted { $0.lowerBound < $1.lowerBound }
        self.lowerBounds = sorted.map { $0.lowerBound }
        self.upperBounds = sorted.map { $0.upperBound }
    }
}

extension RangeSet : RandomAccessCollection {
    
    public var startIndex: Int {
        return lowerBounds.startIndex
    }
    public var endIndex: Int {
        return lowerBounds.endIndex
    }
    
    public subscript(position: Int) -> Range<Bound> {
        return Range(uncheckedBounds: (lowerBounds[position], upperBounds[position]))
    }
    
    public func index(before i: Int) -> Int {
        return lowerBounds.index(before: i)
    }
    public func index(after i: Int) -> Int {
        return lowerBounds.index(after: i)
    }
}


    public func union(_ range: Range<Bound>) -> RangeSet {
        var collect: [Range<Bound>] = []
        var overlap = range
        for r in ranges {
            if overlap.overlaps(r) || overlap.lowerBound == r.upperBound || overlap.upperBound == r.lowerBound {
                overlap = Range(uncheckedBounds: (Swift.min(overlap.lowerBound, r.lowerBound), Swift.max(overlap.upperBound, r.upperBound)))
            } else {
