     }
     
     mutating func nestedContainer<NestedKey>(keyedBy keyType: NestedKey.Type) -> KeyedEncodingContainer<NestedKey> where NestedKey : CodingKey {
-        <#code#>
+        return KeyedEncodingContainer(BSONKeyedEncodingContainer<NestedKey>(encoder: self.wrapper.subEncoder))
     }
     
     mutating func nestedUnkeyedContainer() -> UnkeyedEncodingContainer {
-        var encoder = _BSONEncoder()
-        encoder.wrapper = self.wrapper
-        
-        return BSONUnkeyedEncodingContainer(encoder: encoder)
+        return BSONUnkeyedEncodingContainer(encoder: self.wrapper.subEncoder)
     }
     
     mutating func superEncoder() -> Encoder {

    }
    
    mutating func encode(_ value: Int8) throws {
        try wrapper.encode(value)
    }
    
    mutating func encode(_ value: Int16) throws {
        try wrapper.encode(value)
    }
    
    mutating func encode(_ value: Int32) throws {

    }
    
    mutating func encode(_ value: Int64) throws {
        wrapper.encode(value)
    }
    
    mutating func encode(_ value: UInt) throws {
        wrapper.encode(value)
    }
    
    mutating func encode(_ value: UInt8) throws {
        wrapper.encode(value)
    }
    
    mutating func encode(_ value: UInt16) throws {
        wrapper.encode(value)
    }
    
    mutating func encode(_ value: UInt32) throws {
        wrapper.encode(value)
    }
    
    mutating func encode(_ value: UInt64) throws {
        wrapper.encode(value)
    }
    
    mutating func encode(_ value: Float) throws {
