     
     /// Whether the data has been written
     private var didWrite = false
-    
-    let keyPath: String
     
     // MARK: - Initialization
     
     init(referencing encoder: PredicateEncoder.Encoder) {
         self.encoder = encoder
         self.codingPath = encoder.codingPath
-        self.keyPath = encoder.codingPath.path
     }
     
     // MARK: - Methods
     
-    func encodeNil() throws {
-        // do nothing
-    }
-    
-    func encode(_ value: Bool) throws { write(encoder.box(value)) }
-    
-    func encode(_ value: String) throws { write(encoder.box(value)) }
-    
-    func encode(_ value: Double) throws { write(encoder.boxDouble(value)) }
-    
-    func encode(_ value: Float) throws { write(encoder.boxFloat(value)) }
-    
-    func encode(_ value: Int) throws { write(encoder.boxNumeric(Int32(value))) }
-    
-    func encode(_ value: Int8) throws { write(encoder.box(value)) }
-    
-    func encode(_ value: Int16) throws { write(encoder.boxNumeric(value)) }
-    
-    func encode(_ value: Int32) throws { write(encoder.boxNumeric(value)) }
-    
-    func encode(_ value: Int64) throws { write(encoder.boxNumeric(value)) }
-    
-    func encode(_ value: UInt) throws { write(encoder.boxNumeric(UInt32(value))) }
-    
-    func encode(_ value: UInt8) throws { write(encoder.box(value)) }
-    
-    func encode(_ value: UInt16) throws { write(encoder.boxNumeric(value)) }
-    
-    func encode(_ value: UInt32) throws { write(encoder.boxNumeric(value)) }
-    
-    func encode(_ value: UInt64) throws { write(encoder.boxNumeric(value)) }
+    func encodeNil() throws { write(.null) }
+    
+    func encode(_ value: Bool) throws { write(value) }
+    
+    func encode(_ value: String) throws { write(value) }
+    
+    func encode(_ value: Double) throws { write(value) }
+    
+    func encode(_ value: Float) throws { write(value) }
+    
+    func encode(_ value: Int) throws { write(Int64(value)) }
+    
+    func encode(_ value: Int8) throws { write(value) }
+    
+    func encode(_ value: Int16) throws { write(value) }
+    
+    func encode(_ value: Int32) throws { write(value) }
+    
+    func encode(_ value: Int64) throws { write(value) }
+    
+    func encode(_ value: UInt) throws { write(UInt64(value)) }
+    
+    func encode(_ value: UInt8) throws { write(value) }
+    
+    func encode(_ value: UInt16) throws { write(value) }
+    
+    func encode(_ value: UInt32) throws { write(value) }
+    
+    func encode(_ value: UInt64) throws { write(value) }
     
     func encode <T: Encodable> (_ value: T) throws {
         precondition(didWrite == false, "Data already written")
-        encoder.writeEncodable(<#T##value: Encodable##Encodable#>, for: <#T##String#>)
+        try encoder.writeEncodable(value)
         didWrite = true
     }
     
     // MARK: - Private Methods
     
-    private func encode<T: PredicateValue>(_ value: T) {
-        encode(value.predicateValue)
-    }
-    
-    private func encode(_ value: Value) {
+    private func write<T: PredicateValue>(_ value: T) {
+        write(value.predicateValue)
+    }
+    
+    private func write(_ value: Value) {
         precondition(didWrite == false, "Data already written")
-        encoder.write(value, for: keyPath)
+        encoder.write(value)
         didWrite = true
     }
 }


internal extension PredicateEncoder.Encoder {
    
    func write(_ value: Value, for keyPath: String) {
        values[keyPath] = value
        log?("Did encode \(value.type) value for keyPath \"\(keyPath)\"")
    }
    
    func writeEncodable <T: Encodable> (_ value: T, for keyPath: String) throws {
        
        if let data = value as? Data {
            write(.data(data), for: keyPath)
        } else if let uuid = value as? UUID {
            write(.uuid(uuid), for: keyPath)
        } else if let date = value as? Date {
            write(.date(date), for: keyPath)
        } else {
            // encode using Encodable, container should write directly.
            try value.encode(to: self)

    }
    
    func nestedUnkeyedContainer(forKey key: K) -> UnkeyedEncodingContainer {
        fatalError()
    }
    
    func superEncoder() -> Encoder {
        fatalError()
    }
    
    func superEncoder(forKey key: K) -> Encoder {
        fatalError()
    }
    
