     }
 
     open func removeObject(at idx: Int) {
+        _validateSubscript(idx)
         _storage.remove(_orderedStorage[idx])
         _orderedStorage.remove(at: idx)
     }
 
     open func replaceObject(at idx: Int, with obj: Any) {
-        guard idx < count && idx >= 0 else {
-            fatalError("\(self): Index out of bounds")
-        }
-        
         let value = __SwiftValue.store(obj)
         let objectToReplace = __SwiftValue.store(object(at: idx))
         _orderedStorage[idx] = value

        guard aCoder.allowsKeyedCoding else {
            preconditionFailure("Unkeyed coding is unsupported.")
        }
        for idx in 0..<self.count {
            aCoder.encode(__SwiftValue.store(self.object(at: idx)), forKey:"NS.object.\(idx)")
        }
    }

    }
    
    open func exchangeObject(at idx1: Int, withObjectAt idx2: Int) {
        let object1 = self.object(at: idx1)
        let object2 = self.object(at: idx2)
        _orderedStorage[idx1] = __SwiftValue.store(object2)
