     public init() {}
     
     public func encode<E: Encodable>(_ e: E) throws -> Document {
-        try e.encode(to: _BSONEncoder())
-    }
-    
-    public func encodePrimitive<E: Encodable>(_ e: E) throws -> Document {
-        try e.encode(to: _BSONEncoder())
+        let encoder = _BSONEncoder()
+        try e.encode(to: encoder)
+        
+        guard let doc = encoder.wrapper.primitive as? Document else {
+            throw BSONEncoderError()
+        }
+        
+        return doc
+    }
+    
+    public func encodePrimitive<E: Encodable>(_ e: E) throws -> Primitive {
+        let encoder = _BSONEncoder()
+        
+        try e.encode(to: encoder)
+        
+        return encoder.wrapper.primitive
     }
 }
 
-final class PrimitiveWrapper {
+fileprivate final class PrimitiveWrapper {
     var primitive: Primitive
     var doc: Document {
         get {

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

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