Trim key/value pairs correctly.