   "Decode the Set-Cookie string into a cookie seq."
   [set-cookie-str]
   (if-not (blank? set-cookie-str)
-    (let [domain (lower-case (str (gensym))) ; I just want to parse a cookie without providing origin. How?
+    ;; I just want to parse a cookie without providing origin. How?
+    (let [domain (lower-case (str (gensym)))
           origin (CookieOrigin. domain 80 "/" false)
-          [cookie-name cookie-content] (to-cookie (first (.parse (cookie-spec) (BasicHeader. "set-cookie" set-cookie-str) origin)))]
+          [cookie-name cookie-content] (-> (cookie-spec)
+                                           (.parse (BasicHeader.
+                                                    "set-cookie"
+                                                    set-cookie-str)
+                                                   origin)
+                                           first
+                                           to-cookie)]
       [cookie-name
        (if (= domain (:domain cookie-content))
          (dissoc cookie-content :domain) cookie-content)])))

(ns clj-http.cookies
  (:import (org.apache.http.client.params ClientPNames CookiePolicy)
           (org.apache.http.cookie CookieOrigin)
           (org.apache.http.params BasicHttpParams)
           (org.apache.http.impl.cookie BasicClientCookie2)
           (org.apache.http.impl.cookie BrowserCompatSpecFactory)
           (org.apache.http.message BasicHeader))
  (:use [clojure.contrib.string :only (as-str blank? join lower-case)]
        clj-http.util))

(defn- cookie-spec []
  (.newInstance
   (BrowserCompatSpecFactory.)
   (doto (BasicHttpParams.)
     (.setParameter ClientPNames/COOKIE_POLICY CookiePolicy/BROWSER_COMPATIBILITY))))

(defn- compact-map
  "Removes all map entries where value is nil."
  [m] (reduce #(if (get m %2) (assoc %1 %2 (get m %2)) %1) (sorted-map) (sort (keys m))))

(defn- to-cookie
  "Converts a ClientCookie object into a tuple where the first item is

(defn encode-cookie
  "Encode the cookie into a string used by the Cookie header."
  [cookie]
  (when-let [header (-> (cookie-spec)
                        (.formatCookies [(to-basic-client-cookie cookie)])
                        first)]
    (.getValue header)))

(defn encode-cookies
