diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2011, Nobuo Yamashita
+Copyright (c) 2011-2016, Nobuo Yamashita
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/oi.cabal b/oi.cabal
--- a/oi.cabal
+++ b/oi.cabal
@@ -1,5 +1,5 @@
 Name:			oi
-Version:		0.3.1
+Version:		0.4.0
 Category:		Data
 Synopsis:		Library for purely functional lazy interactions with the outer world.
 Description:		This package implements a data structure and operations on it for writing interactive program with no imperative flavor of IO monads.
@@ -15,23 +15,67 @@
 Cabal-Version:		>= 1.14
 
 Data-dir:		sample
-Data-files:		Makefile cats.hs cats2.hs echo.hs morec.hs recdircs.hs talk.hs
 
 Library
   Default-Language:         Haskell2010
   Hs-Source-Dirs:	    src/
-  Build-Depends:	    base >= 4.5 && < 5, parallel, comonad >= 3, filepath, directory, SafeSemaphore
-  GHC-Options:		    -Wall -O0
+  Build-Depends:	    base >= 4.5 && < 5, parallel, comonad >= 3, filepath, directory
+  GHC-Options:		    -O0 -fcase-merge -fcse -fdo-eta-reduction -fenable-rewrite-rules -ffloat-in -ffull-laziness -fspecialise -fstrictness 
   Exposed-modules:	    Data.OI
-                           ,Data.OI.Internal
-                           ,Data.OI.Combinator
-                           ,Data.OI.Force
-                           ,Data.OI.IFun
-                           ,Data.OI.IO
-                           ,Data.OI.Merge
-                           ,Data.OI.Resource
-                           ,Data.OI.System
+                          , Data.OI.Internal
+                          , Data.OI.Combinator
+                          , Data.OI.Force
+                          , Data.OI.IFun
+                          , Data.OI.IO
+                          , Data.OI.Merge
+                          , Data.OI.Resource
+                          , Data.OI.System
 
+Executable oi-cats
+  Hs-Source-Dirs:           sample/
+  Main-Is:                  cats.hs
+  Build-Depends:            base >= 4.5 && < 5
+                          , oi
+  Default-Language:         Haskell2010
+                          
+Executable oi-cats2
+  Hs-Source-Dirs:           sample/
+  Main-Is:                  cats2.hs
+  Build-Depends:            base >= 4.5 && < 5
+                          , oi
+  Default-Language:         Haskell2010
+                           
+Executable oi-echo
+  Hs-Source-Dirs:           sample/
+  Main-Is:                  echo.hs
+  Build-Depends:            base >= 4.5 && < 5
+                          , oi
+  Default-Language:         Haskell2010
+                           
+Executable oi-morec
+  Hs-Source-Dirs:           sample/
+  Main-Is:                  morec.hs
+  Build-Depends:            base >= 4.5 && < 5
+                          , oi
+  Default-Language:         Haskell2010
+                           
+Executable oi-recdircs
+  Hs-Source-Dirs:           sample/
+  Main-Is:                  recdircs.hs
+  Build-Depends:            base >= 4.5 && < 5
+                          , directory
+                          , filepath
+                          , oi
+  Default-Language:         Haskell2010
+                           
+Executable oi-talk
+  Hs-Source-Dirs:           sample/
+  Main-Is:                  talk.hs
+  Build-Depends:            base >= 4.5 && < 5
+                          , parallel
+                          , oi
+  Default-Language:         Haskell2010
+                           
 Source-Repository head
-  type:		  darcs
-  location:	  http://darcs.sampou.org/oi/
+  type:		  git
+  location:	  https://github.com/nobsun/oi
diff --git a/sample/Makefile b/sample/Makefile
deleted file mode 100644
--- a/sample/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-EXECS = echo recdircs talk cats cats2 morec
-
-all	: $(EXECS)
-
-echo	: echo.hs
-	ghc --make -O0 -threaded $< -o $@
-
-recdircs	: recdircs.hs
-	ghc --make -O0 -threaded $< -o $@
-
-talk	: talk.hs
-	ghc --make -O0 -threaded $< -o $@
-
-cats	: cats.hs
-	ghc --make -O0 -threaded $< -o $@
-
-cats2	: cats2.hs
-	ghc --make -O0 -threaded $< -o $@
-
-morec	: morec.hs
-	ghc --make -O0 -threaded $< -o $@
-
-clean	:
-	-rm $(EXECS) *.hi *.o *~ core
diff --git a/src/Data/OI.hs b/src/Data/OI.hs
--- a/src/Data/OI.hs
+++ b/src/Data/OI.hs
@@ -1,6 +1,6 @@
 -- |
 -- Module      : Data.OI
--- Copyright   : (c) Nobuo Yamashita 2011-2012
+-- Copyright   : (c) Nobuo Yamashita 2011-2016
 -- License     : BSD3
 -- Author      : Nobuo Yamashita
 -- Maintainer  : nobsun@sampou.org
diff --git a/src/Data/OI/Combinator.hs b/src/Data/OI/Combinator.hs
--- a/src/Data/OI/Combinator.hs
+++ b/src/Data/OI/Combinator.hs
@@ -1,6 +1,6 @@
 -- |
 -- Module      : Data.OI.Combinator
--- Copyright   : (c) Nobuo Yamashita 2011-2012
+-- Copyright   : (c) Nobuo Yamashita 2011-2016
 -- License     : BSD3
 -- Author      : Nobuo Yamashita
 -- Maintainer  : nobsun@sampou.org
diff --git a/src/Data/OI/Force.hs b/src/Data/OI/Force.hs
--- a/src/Data/OI/Force.hs
+++ b/src/Data/OI/Force.hs
@@ -1,6 +1,6 @@
 -- |
 -- Module      : Data.OI.Force
--- Copyright   : (c) Nobuo Yamashita 2012
+-- Copyright   : (c) Nobuo Yamashita 2012-2016
 -- License     : BSD3
 -- Author      : Nobuo Yamashita
 -- Maintainer  : nobsun@sampou.org
diff --git a/src/Data/OI/IFun.hs b/src/Data/OI/IFun.hs
--- a/src/Data/OI/IFun.hs
+++ b/src/Data/OI/IFun.hs
@@ -3,7 +3,7 @@
   #-}
 -- |
 -- Module      : Data.OI.IFun
--- Copyright   : (c) Nobuo Yamashita 2012
+-- Copyright   : (c) Nobuo Yamashita 2012-2016
 -- License     : BSD3
 -- Author      : Nobuo Yamashita
 -- Maintainer  : nobsun@sampou.org
diff --git a/src/Data/OI/IO.hs b/src/Data/OI/IO.hs
--- a/src/Data/OI/IO.hs
+++ b/src/Data/OI/IO.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE TypeOperators #-}
 -- |
 -- Module      : Data.OI.IO
--- Copyright   : (c) Nobuo Yamashita 2011-2012
+-- Copyright   : (c) Nobuo Yamashita 2011-2016
 -- License     : BSD3
 -- Author      : Nobuo Yamashita
 -- Maintainer  : nobsun@sampou.org
diff --git a/src/Data/OI/Internal.hs b/src/Data/OI/Internal.hs
--- a/src/Data/OI/Internal.hs
+++ b/src/Data/OI/Internal.hs
@@ -6,7 +6,7 @@
 {-# OPTIONS_GHC -fno-cse #-}
 -- |
 -- Module      : Data.OI.Base
--- Copyright   : (c) Nobuo Yamashita 2011-2012
+-- Copyright   : (c) Nobuo Yamashita 2011-2016
 -- License     : BSD3
 -- Author      : Nobuo Yamashita
 -- Maintainer  : nobsun@sampou.org
@@ -41,7 +41,7 @@
   ) 
   where
 
-import Control.Applicative
+-- import Control.Applicative
 -- import Control.Category
 import Control.Comonad
 import Control.Exception
@@ -69,6 +69,10 @@
 instance Functor OI where
   fmap f = (##) . f . (??)
 
+instance Applicative OI where
+  pure = (##)
+  f <*> g = ((f ??) (g ??) ##)
+
 instance Monad OI where
   return = (##)
   (>>=)  = flip ($) . (??)
@@ -254,12 +258,15 @@
 
 -- Unsafe primitive
 
+{-# NOINLINE unsafeNew #-}
 unsafeNew :: a -> LeftValueOf a
 unsafeNew _ = unsafePerformIO newEmptyMVar
 
+{-# NOINLINE unsafeDeref #-}
 unsafeDeref :: MVar a -> a
 unsafeDeref = unsafePerformIO . readMVar
 
+{-# NOINLINE unsafePut #-}
 unsafePut :: a -> MVar a -> a
 unsafePut x v = unsafePerformIO $ do
               { s <- tryPutMVar v x
diff --git a/src/Data/OI/Merge.hs b/src/Data/OI/Merge.hs
--- a/src/Data/OI/Merge.hs
+++ b/src/Data/OI/Merge.hs
@@ -1,4 +1,12 @@
 {-# LANGUAGE TypeOperators #-}
+-- |
+-- Module      : Data.OI.Merge
+-- Copyright   : (c) Nobuo Yamashita 2011-2016
+-- License     : BSD3
+-- Author      : Nobuo Yamashita
+-- Maintainer  : nobsun@sampou.org
+-- Stability   : experimental
+--
 module Data.OI.Merge
  ( -- * merge list
   mergeOI
@@ -9,7 +17,6 @@
 
 import Control.Concurrent (forkIO)
 import Control.Concurrent.MVar (MVar,newEmptyMVar,newMVar,takeMVar,putMVar)
-import Control.Concurrent.SSem (SSem,new,signal,wait)
 import System.IO.Unsafe (unsafeInterleaveIO)
 
 mergeOI :: [a] -> [a] -> [a] :-> [a]
@@ -18,6 +25,75 @@
 nmergeOI :: [[a]] -> [a] :-> [a]
 nmergeOI =  iooi . nmergeIO
 
+
+mergeIO :: [a] -> [a] -> IO [a]
+nmergeIO :: [[a]] -> IO [a]
+
+-- $merge
+-- The 'mergeIO' and 'nmergeIO' functions fork one thread for each
+-- input list that concurrently evaluates that list; the results are
+-- merged into a single output list.  
+
+mergeIO ls rs
+ = newEmptyMVar                >>= \ tail_node ->
+   newMVar tail_node           >>= \ tail_list ->
+   newMVar ()                  >>= \ e ->
+   newMVar 2                   >>= \ branches_running ->
+   let
+    buff = (tail_list,e)
+   in
+    forkIO (suckIO branches_running buff ls) >>
+    forkIO (suckIO branches_running buff rs) >>
+    takeMVar tail_node  >>= \ val ->
+    putMVar e ()        >>
+    return val
+
+nmergeIO lss
+ = let
+    len = length lss
+   in
+    newEmptyMVar          >>= \ tail_node ->
+    newMVar tail_node     >>= \ tail_list ->
+    newMVar ()            >>= \ e ->
+    newMVar len           >>= \ branches_running ->
+    let
+     buff = (tail_list,e)
+    in
+     mapM_ (\ x -> forkIO (suckIO branches_running buff x)) lss >>
+     takeMVar tail_node  >>= \ val ->
+     putMVar e ()        >>
+     return val
+
+type Buffer a
+ = (MVar (MVar [a]), MVar ())
+
+suckIO :: MVar Int -> Buffer a -> [a] -> IO ()
+suckIO branches_running buff@(tail_list,e) vs
+ = case vs of
+        [] -> takeMVar branches_running >>= \ val ->
+              if val == 1 then
+                 takeMVar tail_list     >>= \ node ->
+                 putMVar node []        >>
+                 putMVar tail_list node
+              else
+                 putMVar branches_running (val-1)
+        (x:xs) ->
+                takeMVar e                       >>= \ () ->
+                takeMVar tail_list               >>= \ node ->
+                newEmptyMVar                     >>= \ next_node ->
+                unsafeInterleaveIO (
+                        takeMVar next_node  >>= \ y ->
+                        putMVar e ()        >>
+                        return y)                >>= \ next_node_val ->
+                putMVar node (x:next_node_val)   >>
+                putMVar tail_list next_node      >>
+                suckIO branches_running buff xs
+
+
+
+
+
+{-
 -- The origin of following codes came from Control.Concurrent module.
 -- The original codes using Control.Concurrent.QSem were deprecated.
 -- The following codes are made by modifying the original code to use
@@ -85,3 +161,4 @@
                 putMVar node (x:next_node_val)   >>
                 putMVar tail_list next_node      >>
                 suckIO branches_running buff xs
+-}
diff --git a/src/Data/OI/Resource.hs b/src/Data/OI/Resource.hs
--- a/src/Data/OI/Resource.hs
+++ b/src/Data/OI/Resource.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE TypeOperators #-}
 -- |
 -- Module      : Data.OI.Resource
--- Copyright   : (c) Nobuo Yamashita 2011-2012
+-- Copyright   : (c) Nobuo Yamashita 2011-2016
 -- License     : BSD3
 -- Author      : Nobuo Yamashita
 -- Maintainer  : nobsun@sampou.org
diff --git a/src/Data/OI/System.hs b/src/Data/OI/System.hs
--- a/src/Data/OI/System.hs
+++ b/src/Data/OI/System.hs
@@ -1,6 +1,13 @@
 {-# LANGUAGE TypeOperators
   #-}
-
+-- |
+-- Module      : Data.OI.System
+-- Copyright   : (c) Nobuo Yamashita 2011-2016
+-- License     : BSD3
+-- Author      : Nobuo Yamashita
+-- Maintainer  : nobsun@sampou.org
+-- Stability   : experimental
+--
 module Data.OI.System 
   (
    args
