diff --git a/System/Log/FastLogger.hs b/System/Log/FastLogger.hs
--- a/System/Log/FastLogger.hs
+++ b/System/Log/FastLogger.hs
@@ -1,5 +1,5 @@
 {-# LANGUAGE NoImplicitPrelude, RecordWildCards #-}
-{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleInstances, BangPatterns #-}
 
 -- | Fast logging system to copy log data directly to Handle buffer.
 
@@ -8,6 +8,7 @@
     Logger
   , mkLogger
   , renewLogger
+  , rmLogger
   -- * Logging
   , loggerPutStr
   , loggerPutBuilder
@@ -22,14 +23,16 @@
   ) where
 
 import Blaze.ByteString.Builder
+import Blaze.ByteString.Builder.Char8 (fromString)
 import Control.Applicative
 import Control.Monad
 import qualified Data.ByteString as BS
 import Data.ByteString.Internal (ByteString(..), c2w)
 import Data.List
 import Data.Maybe
+import Data.Monoid
 import Data.Typeable
-import Foreign
+import Foreign hiding (void)
 import GHC.Base
 import GHC.IO.Buffer
 import qualified GHC.IO.BufferedIO as Buffered
@@ -84,6 +87,10 @@
     initHandle newhdl
     return $ logger { loggerHandle = newhdl }
 
+-- | Destroy a 'Logger' by closing internal 'Handle'.
+rmLogger :: Logger -> IO ()
+rmLogger (Logger _ hdl _) = hClose hdl
+
 -- | A date type to contain 'String' and 'ByteString'.
 -- This data is exported so that format can be defined.
 -- This would be replaced with 'Builder' someday when
@@ -119,13 +126,11 @@
         writeIORef haByteBuffer old_buf'
         if size > len then
             bufsWrite h_ bss
-         else allocaBytes size $ \ptr -> do
-            go ptr bss
+          else do
             let Just fd = cast haDevice :: Maybe FD
-            _ <- RawIO.writeNonBlocking fd ptr size
-            return ()
+            writeWithBuilder fd bss
   where
-    len = foldl' (\x y -> x + getLength y) 0 bss
+    len = foldl' (\ !x !y -> x + getLength y) 0 bss
     getLength (LB s) = BS.length s
     getLength (LS s) = length s
     go :: Ptr Word8 -> [LogStr] -> IO ()
@@ -137,11 +142,21 @@
       dst' <- copy' dst s
       go dst' ss
 
+writeWithBuilder :: FD -> [LogStr] -> IO ()
+writeWithBuilder fd bss = toByteStringIOWith 4096 write builder
+  where
+    write !(PS fp o l) = withForeignPtr fp $ \p -> do
+        void $ RawIO.writeNonBlocking fd (p `plusPtr` o) l
+    builder = foldr mappend mempty $ map toBuilder bss
+    toBuilder (LB s) = fromByteString s
+    toBuilder (LS s) = fromString s
+
 copy :: Ptr Word8 -> ByteString -> IO (Ptr Word8)
 copy dst (PS ptr off len) = withForeignPtr ptr $ \s -> do
-    let src = s `plusPtr` off
+    let !src = s `plusPtr` off
     _ <- memcpy dst src (fromIntegral len)
-    return (dst `plusPtr` len)
+    let !res = dst `plusPtr` len
+    return res
 
 copy' :: Ptr Word8 -> String -> IO (Ptr Word8)
 copy' dst [] = return dst
diff --git a/fast-logger.cabal b/fast-logger.cabal
--- a/fast-logger.cabal
+++ b/fast-logger.cabal
@@ -1,5 +1,5 @@
 Name:                   fast-logger
-Version:                0.2.1
+Version:                0.2.2
 Author:                 Kazu Yamamoto <kazu@iij.ad.jp>
 Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp>
 License:                BSD3
@@ -7,9 +7,10 @@
 Synopsis:               A fast logging system
 Description:            A fast logging system
 Category:               System
-Cabal-Version:          >= 1.6
+Cabal-Version:          >= 1.8
 Build-Type:             Simple
-library
+
+Library
   GHC-Options:          -Wall
   Exposed-Modules:      System.Log.FastLogger
                         System.Log.FastLogger.File
@@ -27,6 +28,20 @@
   else
     Build-Depends:      unix
                       , unix-time
+
+Test-Suite spec
+    Main-Is:         Spec.hs
+    Hs-Source-Dirs:  test
+    Type:            exitcode-stdio-1.0
+
+    Ghc-Options:     -Wall
+    Build-Depends:   base >= 4 && < 5
+                   , HUnit
+                   , QuickCheck
+                   , bytestring
+                   , fast-logger
+                   , hspec
+
 Source-Repository head
   Type:                 git
   Location:             git://github.com/kazu-yamamoto/logger.git
diff --git a/test/Spec.hs b/test/Spec.hs
new file mode 100644
--- /dev/null
+++ b/test/Spec.hs
@@ -0,0 +1,1 @@
+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
