diff --git a/haste-compiler.cabal b/haste-compiler.cabal
--- a/haste-compiler.cabal
+++ b/haste-compiler.cabal
@@ -1,5 +1,5 @@
 Name:           haste-compiler
-Version:        0.4.1
+Version:        0.4.2
 License:        BSD3
 License-File:   LICENSE
 Synopsis:       Haskell To ECMAScript compiler
@@ -54,10 +54,6 @@
     Hs-Source-Dirs: src
     if flag(portable)
         CPP-Options: -DPORTABLE
-        if os(windows)
-          GHC-Options: -static -optl-static
-        else
-          GHC-Options: -static -optl-static -optl-pthread
     Build-Depends:
         ghc,
         base < 5,
@@ -81,7 +77,8 @@
         if os(windows)
           GHC-Options: -static -optl-static
         else
-          GHC-Options: -static -optl-static -optl-pthread
+          if os(linux)
+            GHC-Options: -static -optl-static -optl-pthread
     Build-Depends:
         base < 5,
         ghc-prim,
@@ -135,7 +132,8 @@
         if os(windows)
           GHC-Options: -static -optl-static
         else
-          GHC-Options: -static -optl-static -optl-pthread
+          if os(linux)
+            GHC-Options: -static -optl-static -optl-pthread
     Build-Depends:
         base < 5,
         shellmate,
@@ -152,7 +150,8 @@
         if os(windows)
           GHC-Options: -static -optl-static
         else
-          GHC-Options: -static -optl-static -optl-pthread
+          if os(linux)
+            GHC-Options: -static -optl-static -optl-pthread
     Build-Depends:
         base < 5,
         shellmate,
@@ -167,10 +166,6 @@
     Hs-Source-Dirs: src
     if flag(portable)
         CPP-Options: -DPORTABLE
-        if os(windows)
-          GHC-Options: -static -optl-static
-        else
-          GHC-Options: -static -optl-static -optl-pthread
     Build-Depends:
         base < 5,
         shellmate,
@@ -186,10 +181,6 @@
     Hs-Source-Dirs: src
     if flag(portable)
         CPP-Options: -DPORTABLE
-        if os(windows)
-          GHC-Options: -static -optl-static
-        else
-          GHC-Options: -static -optl-static -optl-pthread
     Build-Depends:
         base < 5,
         shellmate >= 0.1.5,
diff --git a/libraries/haste-lib/src/Haste/Foreign.hs b/libraries/haste-lib/src/Haste/Foreign.hs
--- a/libraries/haste-lib/src/Haste/Foreign.hs
+++ b/libraries/haste-lib/src/Haste/Foreign.hs
@@ -15,6 +15,8 @@
 import System.IO.Unsafe
 import Unsafe.Coerce
 
+import Debug.Trace
+
 #ifdef __HASTE__
 foreign import ccall eval :: JSString -> IO (Ptr a)
 foreign import ccall "String" jsString :: Double -> JSString
@@ -262,28 +264,45 @@
 
 instance Unpack a => IOFun (IO a) where
   type X (IO a) = Unpacked
-  packify = unsafePerformIO . unpack' . toOpaque . fmap unpack
-    where
-      {-# NOINLINE unpack' #-}
-      unpack' :: Opaque (IO a) -> IO Unpacked
-      unpack' =
-        ffi (toJSStr $ "(function(f) {" ++
-             "  return (function() {" ++
-             "      var args=Array.prototype.slice.call(arguments,0);"++
-             "      args.push(0);" ++
-             "      return E(B(A(f, args)));" ++
-             "    });" ++
-             "})")
+  packify m = unsafePerformIO $ do
+    x <- m
+    return $! unpack x
 
 instance (Pack a, IOFun b) => IOFun (a -> b) where
   type X (a -> b) = Unpacked -> X b
   packify f = \x -> packify (f $! pack x)
 
 instance Unpack a => Unpack (IO a) where
-  unpack = packify
+  unpack = unsafePerformIO . unpackAct . toOpaque . fmap unpack
+    where
+      {-# NOINLINE unpackAct #-}
+      unpackAct :: Opaque (IO Unpacked) -> IO Unpacked
+      unpackAct =
+        ffi (toJSStr $ "(function(m){" ++
+             "    return (function() {" ++
+             "        return (function(){return E(B(A(m,[0])));});" ++
+             "      });" ++
+             "})")
 
 instance (IOFun (a -> b)) => Unpack (a -> b) where
-  unpack = unsafeCoerce . packify
+  unpack = unpackFun
+
+unpackFun :: IOFun a => a -> Unpacked
+unpackFun =
+    unsafePerformIO . go . toOpaque . packify
+  where
+    {-# NOINLINE go #-}
+    go :: Opaque a -> IO Unpacked
+    go = ffi (toJSStr $ "(function(f) {" ++
+              "  return (function() {" ++
+              "      return (function(){" ++
+              "        var args=Array.prototype.slice.call(arguments,0);"++
+              "        args.push(0);" ++
+              "        return E(B(A(f, args)));" ++
+              "    });" ++
+              "  });" ++
+              "})")
+
 
 -- | Creates a function based on the given string of Javascript code. If this
 --   code is not well typed or is otherwise incorrect, your program may crash
diff --git a/src/Haste/Version.hs b/src/Haste/Version.hs
--- a/src/Haste/Version.hs
+++ b/src/Haste/Version.hs
@@ -9,7 +9,7 @@
 import Haste.Environment (hasteSysDir, ghcBinary)
 
 hasteVersion :: Version
-hasteVersion = Version [0, 4, 1] []
+hasteVersion = Version [0, 4, 2] []
 
 ghcVersion :: String
 ghcVersion = unsafePerformIO $ do
diff --git a/src/haste-pkg.hs b/src/haste-pkg.hs
--- a/src/haste-pkg.hs
+++ b/src/haste-pkg.hs
@@ -53,9 +53,13 @@
 
     prefix s pfx path = pfx ++ ": " ++ path </> stripPrefix s
 
-    stripPrefix s =
-      case take 2 $ reverse $ splitPath s of
-        [second, first] -> first </> second
+    stripPrefix s
+      | os == "darwin" =
+        case take 3 $ reverse $ splitPath s of
+          [third, second, first] -> first </> second </> third
+      | otherwise =
+        case take 2 $ reverse $ splitPath s of
+          [second, first] -> first </> second
 
     isKey _ "" =
       False
@@ -63,6 +67,6 @@
       and $ zipWith (==) key str
 
     importDir
-      | os == "mingw32" = "${pkgroot}" </> "libraries"
-      | otherwise       = "${pkgroot}" </> "libraries" </> "lib"
+      | os == "linux"  = "${pkgroot}" </> "libraries" </> "lib"
+      | otherwise      = "${pkgroot}" </> "libraries"
     includeDir = "${pkgroot}" </> "include"
