 (defn- value-file [port]
   (str "/sys/class/gpio/gpio" port "/value"))
 
-(defn random-access [filename]
-  (RandomAccessFile. filename "rw"))
-
-(defrecord BasicGpioPort [port filename file formatter]
+(defrecord BasicGpioPort [port filename formatter]
   GpioPort
 
-  (set-direction! [_ direction]
-    (do-set-direction! port direction))
-
-  (set-active-low! [_ active-low?]
-    (do-set-active-low! port active-low?))
+  (set-direction! [this direction]
+    (do-set-direction! port direction)
+    this)
+
+  (set-active-low! [this active-low?]
+    (do-set-active-low! port active-low?)
+    this)
 
   (read-value
     [_]
-    (.seek file 0)
-    (formatter (char (.read file))))
+    (formatter (slurp filename)))
 
   (write-value!
-    [_ value]
-    (.seek file 0)
-    (.writeByte file (high-low-value value)))
-
-  clojure.lang.IDeref
-  (deref [this] (read-value this))
+    [this value]
+    (spit filename (high-low-value value))
+    this)
 
   Closeable
   (close! [_]
-    (.close file)
     (unexport! port)))
 
 (defn open-port


(defmethod format-raw-digital :char
  [_ raw-value]
  raw-value)

(defmethod format-raw-digital :default
  [_ raw-value]
  raw-value)

(defprotocol Closeable
  (close! [self] "Closes this object"))


(defmethod format-raw-digital :boolean
  [_ raw-value]
  (= \1 (first raw-value)))

(defmethod format-raw-digital :symbol
  [_ raw-value]
