diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) Bjorn Bringert, Lemmih
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the author nor the names of his contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/Network/FastCGI.hsc b/Network/FastCGI.hsc
--- a/Network/FastCGI.hsc
+++ b/Network/FastCGI.hsc
@@ -12,7 +12,7 @@
 --
 -----------------------------------------------------------------------------
 module Network.FastCGI
-    ( 
+    (
     -- * Single-threaded interface
       runFastCGIorCGI
     , runOneFastCGIorCGI
@@ -58,10 +58,14 @@
 
 #include <fcgiapp.h>
 
+------------------------------------------------------------------------
+
 data FCGX_Stream
 type StreamPtr = Ptr FCGX_Stream
 type Environ = Ptr CString
 
+------------------------------------------------------------------------
+
 foreign import ccall unsafe "fcgiapp.h FCGX_IsCGI" fcgx_isCGI
     :: IO CInt
 
@@ -76,6 +80,8 @@
 foreign import ccall unsafe "fcgiapp.h FCGX_Finish" fcgx_finish
     :: IO ()
 
+------------------------------------------------------------------------
+
 -- | Handle a single CGI request, or FastCGI requests in an infinite loop.
 --   This function only returns normally if it was a CGI request.
 --   This lets you use the same program
@@ -89,7 +95,7 @@
 -- | Handle a single FastCGI or CGI request. This lets you use the same program
 --   as either a FastCGI or CGI program, depending on what the server 
 --   treats it as.
-runOneFastCGIorCGI :: CGI CGIResult 
+runOneFastCGIorCGI :: CGI CGIResult
                    -> IO Bool -- ^ True if it was a FastCGI request, 
                               --   False if CGI.
 runOneFastCGIorCGI f =
@@ -164,42 +170,44 @@
 runFastCGIConcurrent' :: (IO () -> IO a) -- ^ How to fork a request.
                       -> Int             -- ^ Max number of concurrent threads.
                       -> CGI CGIResult -> IO ()
+
 runFastCGIConcurrent' fork m f
     = do qsem <- newQSem m
-	 testReturn "FCGX_Init" $ fcgx_init
+         testReturn "FCGX_Init" $ fcgx_init
          let loop = do waitQSem qsem
                        reqp <- acceptRequest
-	               fork (oneRequestMT f reqp `finally` (finishRequest reqp >> signalQSem qsem))
-	               loop
-	 loop `catch` \e -> log (show e)
+                       fork (oneRequestMT f reqp
+                             `finally`
+                            (finishRequest reqp >> signalQSem qsem))
+                       loop
+         loop `catch` \e -> log (show e)
 
 oneRequestMT :: CGI CGIResult -> Ptr FCGX_Request -> IO ()
 oneRequestMT f r = do
-		 env <- peekEnvp r
-		 vars <- environToTable env
-		 ins <- peekIn r
-		 input <- sRead ins
-		 output <- runCGIEnvFPS vars input (runCGIT f)
-		 outs <- peekOut r
-		 sPutStr outs output
+     env    <- peekEnvp r
+     vars   <- environToTable env
+     ins    <- peekIn r
+     input  <- sRead ins
+     output <- runCGIEnvFPS vars input (runCGIT f)
+     outs   <- peekOut r
+     sPutStr outs output
 --
 -- * FCGX_Reqest struct
 --
 
 acceptRequest :: IO (Ptr FCGX_Request)
 acceptRequest = do
- 		reqp <- mallocBytes (#size FCGX_Request)
-		initAndAccept reqp
-		return reqp
-    where initAndAccept reqp = 
-	      do 
-	      testReturn "FCGX_InitRequest" $ fcgx_initrequest reqp 0 0
-	      testReturn "FCGX_Accept_r" $ fcgx_accept_r reqp
+    reqp <- mallocBytes (#size FCGX_Request)
+    initAndAccept reqp
+    return reqp
+  where initAndAccept reqp = do
+          testReturn "FCGX_InitRequest" $ fcgx_initrequest reqp 0 0
+          testReturn "FCGX_Accept_r" $ fcgx_accept_r reqp
 
 finishRequest :: Ptr FCGX_Request -> IO ()
 finishRequest reqp = do
-		     fcgx_finish_r reqp
-		     free reqp
+                     fcgx_finish_r reqp
+                     free reqp
 
 peekIn, peekOut, _peekErr :: Ptr FCGX_Request -> IO (Ptr FCGX_Stream)
 peekIn  = (#peek FCGX_Request, in)
@@ -215,18 +223,18 @@
 --
 
 sPutStr :: StreamPtr -> Lazy.ByteString -> IO ()
-sPutStr h str = 
+sPutStr h str =
     mapM_ (flip BSB.unsafeUseAsCStringLen (fcgxPutCStringLen h)) (Lazy.toChunks str)
 
 fcgxPutCStringLen :: StreamPtr -> CStringLen -> IO ()
-fcgxPutCStringLen h (cs,len) = 
+fcgxPutCStringLen h (cs,len) =
     testReturn "FCGX_PutStr" $ fcgx_putStr cs (fromIntegral len) h
 
 sRead :: StreamPtr -> IO Lazy.ByteString
 sRead h = buildByteString (fcgxGetBuf h) 4096
 
 fcgxGetBuf :: StreamPtr -> Ptr a -> Int -> IO Int
-fcgxGetBuf h p c = 
+fcgxGetBuf h p c =
     liftM fromIntegral $ fcgx_getStr (castPtr p) (fromIntegral c) h
 
 --
@@ -251,10 +259,10 @@
 --
 
 testReturn :: String -> IO CInt -> IO ()
-testReturn e = throwIfNeg_ (const $ e ++ " failed")
+testReturn e = throwIfNeg_ (\n -> e ++ " failed with error code: "++ show n)
 
 environToTable :: Environ -> IO [(String,String)]
-environToTable arr = 
+environToTable arr =
     do css <- peekArray0 nullPtr arr
        ss <- mapM peekCString css
        return $ map (splitBy '=') ss
@@ -277,5 +285,5 @@
 
 log :: String -> IO ()
 log msg = do
-	  t <- myThreadId
-	  withMVar logMutex (const $ hPutStrLn stderr (show t ++ ": " ++ msg))
+          t <- myThreadId
+          withMVar logMutex (const $ hPutStrLn stderr (show t ++ ": " ++ msg))
diff --git a/configure b/configure
new file mode 100644
--- /dev/null
+++ b/configure
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+
+# subst standard header path variables
+if test -n "$CPPFLAGS" ; then
+    echo "Found CPPFLAGS in environment: '$CPPFLAGS'"
+    sed 's,@CPPFLAGS@,'"$CPPFLAGS"',g;s,@LDFLAGS@,'"$LDFLAGS"',g'  \
+        < fastcgi.buildinfo.in > fastcgi.buildinfo
+fi
diff --git a/fastcgi.cabal b/fastcgi.cabal
--- a/fastcgi.cabal
+++ b/fastcgi.cabal
@@ -1,13 +1,16 @@
-Name: fastcgi
-Version: 3001.0.1
-Copyright: Bjorn Bringert, Lemmih
-Maintainer: lemmih@gmail.com
-License: BSD3
-Synopsis: A Haskell library for writing FastCGI programs
+Name:           fastcgi
+Version:        3001.0.2
+Copyright:      Bjorn Bringert, Lemmih
+Maintainer:     bjorn@bringert.net
+License:        BSD3
+license-file:   LICENSE
+Synopsis:       A Haskell library for writing FastCGI programs
 Description:
  This library lets you write FastCGI programs. This package reuses the
  cgi package API, making it very easy to port CGI programs to FastCGI.
 Cabal-version: >= 1.2.0
+build-type:     Configure
+extra-source-files: configure
 
 flag small_base
   description: Choose the new smaller, split-up base package.
@@ -21,5 +24,5 @@
   Extensions: ForeignFunctionInterface, EmptyDataDecls
   Exposed-Modules: 
      Network.FastCGI
-  ghc-options: -O2 -Werror -fwarn-unused-binds -fwarn-unused-imports -fwarn-unused-matches
+  ghc-options: -O2 -fwarn-unused-binds -fwarn-unused-imports -fwarn-unused-matches
   extra-libraries: fcgi
