     (do (stop-server)
         (reset! server-state {}))))
 
-(defn repl-env [root port]
-  (BrowserEvaluator. root port))
+(defn repl-env [& {:keys [port root] :as opts}]
+  (let [opts (merge {:port 9000 :root "" :main "main.js" :goog-base "out/goog/base.js"} opts)]
+    (BrowserEvaluator. opts)))
 
 (comment
   
   (require '[cljs.repl :as repl])
   (require '[cljs.repl.browser :as browser])
-  (def env (browser/repl-env "samples/repl2" 9000))
+  (def env (browser/repl-env :main "out/repl.js"))
   (repl/repl env)
   ;; simulate the browser with curl
   ;; curl -v -d "ready" http://127.0.0.1:9000

      (.close conn))))

(defn- server-loop
  [root server-socket]
  (let [conn (.accept server-socket)]
    (do (.setKeepAlive conn true)
        (future (handle-connection root conn))
        (recur root server-socket))))

(defn start-server
  "Start the server on the specified port."
  [root port]
  (do (println "Starting Server on Port:" port)
      (let [ss (ServerSocket. port)]
        (future (server-loop root ss))
        (swap! server-state (fn [old] {:socket ss :port port})))))

(defn stop-server
  []

      {:type :return
       :value ret})))

(defrecord BrowserEvaluator [opts]
  IEvaluator
  (-setup [this]
    (comp/with-core-cljs (start-server opts)))
  (-evaluate [this line js]
    (browser-eval js))
  (-put [this k v]
