diff --git a/ScratchFs.cabal b/ScratchFs.cabal
--- a/ScratchFs.cabal
+++ b/ScratchFs.cabal
@@ -1,5 +1,5 @@
 name:                ScratchFs
-version:             0.1.0.1
+version:             0.1.0.2
 synopsis:            Size limited temp filesystem based on fuse
 
 description:         ScratchFS is a FUSE-based filesystem which provides a size-limited directory tree. 
diff --git a/src/HistoryDb.hs b/src/HistoryDb.hs
--- a/src/HistoryDb.hs
+++ b/src/HistoryDb.hs
@@ -24,7 +24,6 @@
                   Connection,
                   HistoryField) where
 
-import System.Process
 import System.FilePath.Posix
 import System.Posix
 import System.Directory
@@ -45,11 +44,6 @@
 dbFileName:: String
 dbFileName = "scratchfs.db"
 
-createDbArgs:: [String]
-createDbArgs = [dbFileName, 
-                "CREATE TABLE IF NOT EXISTS scratchfs \
-                \(id INTEGER PRIMARY KEY, \
-                \time INTEGER, size INTEGER, path TEXT);"]
 
 {-|
   Create the history database in the root-path of the filesystem if it does not exist already.
@@ -60,10 +54,13 @@
 -}
 historyDb:: FilePath        -- ^ Path to the base directory of the filesystem.
          -> IO Connection   -- ^ The open database connection
-historyDb path =
-    runProcess "sqlite3" createDbArgs (Just path) Nothing Nothing Nothing Nothing >>= 
-    waitForProcess >>
-    open (path </> dbFileName)
+historyDb path = do
+    conn <- open (path </> dbFileName)
+    execute_  conn "CREATE TABLE IF NOT EXISTS scratchfs \
+                   \(id INTEGER PRIMARY KEY, \
+                   \time INTEGER, size INTEGER, path TEXT);"
+    return conn
+
 
 {-|
   Insert a file to the database, the size and time gets added automatically to the database.
diff --git a/src/ScratchFs.hs b/src/ScratchFs.hs
--- a/src/ScratchFs.hs
+++ b/src/ScratchFs.hs
@@ -176,29 +176,14 @@
 
 scratchRead :: FilePath -> FilePath -> Fd -> ByteCount -> FileOffset -> IO (Either Errno B.ByteString)
 scratchRead _ _ fd count off = do
-    -- Some stupid Fd -> Handle conversion is done here because the fd-based IO operations
-    -- perform some encoding-magic on the data which we don't need here. We need plain binary
-    -- date writes
-    hd <- fdToHandle fd
-    hSetBinaryMode hd True
-    hSeek hd AbsoluteSeek $ fromIntegral off
-    bs <- B.hGet hd $ fromIntegral count
-    _ <- handleToFd hd   -- Vital to free the handle after the operation
+    bs <- withBinaryHandle B.hGet fd (fromIntegral count) off
     return.Right $ bs
 
 scratchWrite :: FilePath -> FilePath -> Fd -> B.ByteString -> FileOffset -> IO (Either Errno ByteCount)
 scratchWrite _ _ fd buf off = do
-    -- Some stupid Fd -> Handle conversion is done here because the fd-based IO operations
-    -- perform some encoding-magic on the data which we don't need here. We need plain binary
-    -- date writes
-    hd <- fdToHandle fd
-    hSetBinaryMode hd True
-    hSeek hd AbsoluteSeek $ fromIntegral off
-    B.hPut hd buf
-    _ <- handleToFd hd   -- Vital to free the handle after the operation
+    withBinaryHandle B.hPut fd buf off
     return.Right $ fromIntegral $ B.length buf
 
-
 scratchGetFileSystemStats :: String -> IO (Either Errno FileSystemStats)
 scratchGetFileSystemStats _ = return $ Left eOK
 
@@ -215,7 +200,7 @@
     maybeCleanUp newSz
     closeFd fd
     stop <- getCPUTime
-    let diff = (fromIntegral (stop - start)) / (10^(12::Integer))
+    let diff = fromIntegral (stop - start) / (10^(12::Integer))
     traceIO $ printf "Time: %0.3f sec" (diff :: Double)
     signalQSem qsem
     where
@@ -232,3 +217,14 @@
 
 scratchSynchronizeFile :: FilePath -> SyncType -> IO Errno
 scratchSynchronizeFile _ _ = getErrno
+
+-- Some stupid Fd -> Handle conversion is done here because the fd-based IO operations
+-- perform some encoding-magic on the data which we don't need here. We need plain binary
+-- date writes
+withBinaryHandle:: (Handle -> a -> IO b) -> Fd -> a -> FileOffset -> IO b
+withBinaryHandle f fd a fo = do
+    hd <- fdToHandle fd
+    hSeek hd AbsoluteSeek $ fromIntegral fo
+    res <- f hd a
+    _ <- handleToFd hd
+    return res
