diff --git a/Bindings/Libgit2.hs b/Bindings/Libgit2.hs
--- a/Bindings/Libgit2.hs
+++ b/Bindings/Libgit2.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
 module Bindings.Libgit2
     ( module Bindings.Libgit2.Attr
     , module Bindings.Libgit2.Blob
@@ -45,8 +47,9 @@
     , module Bindings.Libgit2.Transport
     , module Bindings.Libgit2.Tree
     , module Bindings.Libgit2.Types
-    , module Bindings.Libgit2.Version
+#ifdef WINDOWS
     , module Bindings.Libgit2.Windows
+#endif
     , withLibGitDo
     ) where
 import Bindings.Libgit2.Attr
@@ -95,8 +98,9 @@
 import Bindings.Libgit2.Transport
 import Bindings.Libgit2.Tree
 import Bindings.Libgit2.Types
-import Bindings.Libgit2.Version
+#ifdef WINDOWS
 import Bindings.Libgit2.Windows
+#endif
 
 -- import Control.Monad.IO.Class (MonadIO, liftIO)
 -- import Control.Monad.Trans.Control (MonadBaseControl)
@@ -113,5 +117,7 @@
 --   thread libgit2 library is performed.
 withLibGitDo :: IO a -> IO a
 withLibGitDo f = do
-    c'git_threads_init
-    finally f (performGC >> c'git_threads_shutdown)
+    r <- c'git_threads_init
+    if r < 0
+        then error "c'git_threads_init failed"
+        else finally f (performGC >> c'git_threads_shutdown)
diff --git a/Bindings/Libgit2/Windows.hsc b/Bindings/Libgit2/Windows.hsc
--- a/Bindings/Libgit2/Windows.hsc
+++ b/Bindings/Libgit2/Windows.hsc
@@ -1,9 +1,7 @@
 #include <bindings.dsl.h>
 #include <git2.h>
 module Bindings.Libgit2.Windows where
-#strict_import
 
-import Bindings.Libgit2.Common
 #ifdef GIT_WIN32
 #ccall gitwin_set_codepage , CUInt -> IO ()
 #ccall gitwin_get_codepage , IO (CUInt)
diff --git a/hlibgit2.cabal b/hlibgit2.cabal
--- a/hlibgit2.cabal
+++ b/hlibgit2.cabal
@@ -1,5 +1,5 @@
 Name:                hlibgit2
-Version:             0.18.0.5
+Version:             0.18.0.6
 Synopsis:            Low-level bindings to libgit2
 Description:         Bindings to libgit2 v0.18.0.
 License-file:        LICENSE
@@ -28,6 +28,7 @@
 Test-suite smoke
   default-language: Haskell98
   type: exitcode-stdio-1.0
+  ghc-options: -Wall
   main-is: Main.hs
   hs-source-dirs: test
   build-depends:
@@ -37,6 +38,7 @@
 
 Library
   hs-source-dirs: .
+  ghc-options: -Wall
   default-language: Haskell98
   default-extensions:
     ForeignFunctionInterface
@@ -208,6 +210,7 @@
   cc-options: -g         -DGIT_THREADS -D_FILE_OFFSET_BITS=64 -DGIT_SSL
   ld-options: -g
   if os(windows)
+    cpp-options: -DWINDOWS
     cc-options: -DGIT_WIN32 -DWIN32 -DWIN32_SHA1 -D_DEBUG -D_WIN32_WINNT=0x0501 -DGIT_WINHTTP
     c-sources:
       libgit2/src/hash/hash_win32.c
diff --git a/libgit2/include/git2/odb.h b/libgit2/include/git2/odb.h
--- a/libgit2/include/git2/odb.h
+++ b/libgit2/include/git2/odb.h
@@ -185,11 +185,15 @@
  *
  * @param db database to be searched for the given object.
  * @param id the object to search for.
+ * @param confirm_not_exist true if this existence call is simply
+ *   verifying that the object does not already exist in the object
+ *   database (allowing for an optimization opportunity in custom
+ *   backends)
  * @return
  * - 1, if the object was found
  * - 0, otherwise
  */
-GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
+GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id, int confirm_not_exist);
 
 /**
  * Refresh the object database to load newly added files.
diff --git a/libgit2/include/git2/odb_backend.h b/libgit2/include/git2/odb_backend.h
--- a/libgit2/include/git2/odb_backend.h
+++ b/libgit2/include/git2/odb_backend.h
@@ -87,7 +87,8 @@
 
 	int (* exists)(
 			struct git_odb_backend *,
-			const git_oid *);
+			const git_oid *,
+			int);
 
 	int (* refresh)(struct git_odb_backend *);
 
diff --git a/libgit2/src/fetch.c b/libgit2/src/fetch.c
--- a/libgit2/src/fetch.c
+++ b/libgit2/src/fetch.c
@@ -44,7 +44,7 @@
 		return 0;
 
 	/* If we have the object, mark it so we don't ask for it */
-	if (git_odb_exists(p->odb, &head->oid))
+	if (git_odb_exists(p->odb, &head->oid, 0))
 		head->local = 1;
 	else
 		p->remote->need_pack = 1;
diff --git a/libgit2/src/odb.c b/libgit2/src/odb.c
--- a/libgit2/src/odb.c
+++ b/libgit2/src/odb.c
@@ -526,7 +526,7 @@
 	GIT_REFCOUNT_DEC(db, odb_free);
 }
 
-int git_odb_exists(git_odb *db, const git_oid *id)
+int git_odb_exists(git_odb *db, const git_oid *id, int confirm_not_exist)
 {
 	git_odb_object *object;
 	size_t i;
@@ -546,7 +546,7 @@
 		git_odb_backend *b = internal->backend;
 
 		if (b->exists != NULL)
-			found = b->exists(b, id);
+			found = b->exists(b, id, confirm_not_exist);
 	}
 
 	if (!found && !refreshed) {
@@ -752,7 +752,7 @@
 	assert(oid && db);
 
 	git_odb_hash(oid, data, len, type);
-	if (git_odb_exists(db, oid))
+	if (git_odb_exists(db, oid, 1))
 		return 0;
 
 	for (i = 0; i < db->backends.length && error < 0; ++i) {
diff --git a/libgit2/src/odb_loose.c b/libgit2/src/odb_loose.c
--- a/libgit2/src/odb_loose.c
+++ b/libgit2/src/odb_loose.c
@@ -662,7 +662,7 @@
 	return error;
 }
 
-static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
+static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid, int confirm_not_exist)
 {
 	git_buf object_path = GIT_BUF_INIT;
 	int error;
diff --git a/libgit2/src/odb_pack.c b/libgit2/src/odb_pack.c
--- a/libgit2/src/odb_pack.c
+++ b/libgit2/src/odb_pack.c
@@ -418,7 +418,7 @@
 	return error;
 }
 
-static int pack_backend__exists(git_odb_backend *backend, const git_oid *oid)
+static int pack_backend__exists(git_odb_backend *backend, const git_oid *oid, int confirm_not_exist)
 {
 	struct git_pack_entry e;
 	return pack_entry_find(&e, (struct pack_backend *)backend, oid) == 0;
diff --git a/libgit2/src/push.c b/libgit2/src/push.c
--- a/libgit2/src/push.c
+++ b/libgit2/src/push.c
@@ -301,7 +301,7 @@
 			if (git_oid_iszero(&spec->roid))
 				continue;
 
-			if (!git_odb_exists(push->repo->_odb, &spec->roid)) {
+			if (!git_odb_exists(push->repo->_odb, &spec->roid, 0)) {
 				giterr_clear();
 				error = GIT_ENONFASTFORWARD;
 				goto on_error;
diff --git a/libgit2/src/refs.c b/libgit2/src/refs.c
--- a/libgit2/src/refs.c
+++ b/libgit2/src/refs.c
@@ -368,7 +368,7 @@
 	if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
 		return error;
 	
-	if (!git_odb_exists(odb, oid)) {
+	if (!git_odb_exists(odb, oid, 0)) {
 		giterr_set(GITERR_REFERENCE,
 			"Target OID for the reference doesn't exist on the repository");
 		return -1;
diff --git a/libgit2/src/remote.c b/libgit2/src/remote.c
--- a/libgit2/src/remote.c
+++ b/libgit2/src/remote.c
@@ -856,7 +856,7 @@
 			continue;
 		}
 
-		if (autotag && !git_odb_exists(odb, &head->oid))
+		if (autotag && !git_odb_exists(odb, &head->oid, 0))
 			continue;
 
 		if (git_vector_insert(&update_heads, head) < 0)
diff --git a/libgit2/src/repository.c b/libgit2/src/repository.c
--- a/libgit2/src/repository.c
+++ b/libgit2/src/repository.c
@@ -1337,7 +1337,7 @@
 		return 0;
 	}
 
-	exists = git_odb_exists(odb, git_reference_target(ref));
+	exists = git_odb_exists(odb, git_reference_target(ref), 0);
 
 	git_reference_free(ref);
 	return exists;
diff --git a/libgit2/src/transports/local.c b/libgit2/src/transports/local.c
--- a/libgit2/src/transports/local.c
+++ b/libgit2/src/transports/local.c
@@ -265,7 +265,7 @@
 	git_oid remote_odb_obj_oid;
 
 	/* Object already exists in the remote ODB; do nothing and return 0*/
-	if (git_odb_exists(remote_odb, &obj->id))
+	if (git_odb_exists(remote_odb, &obj->id, 1))
 		return 0;
 
 	if ((error = git_odb_read(&odb_obj, local_odb, &obj->id)) < 0)
@@ -506,7 +506,7 @@
 		git_commit *commit;
 
 		/* Skip commits we already have */
-		if (git_odb_exists(odb, &oid)) continue;
+		if (git_odb_exists(odb, &oid, 0)) continue;
 
 		if (!git_object_lookup((git_object**)&commit, t->repo, &oid, GIT_OBJ_COMMIT)) {
 			const git_oid *tree_oid = git_commit_tree_id(commit);
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -10,17 +10,15 @@
 import System.Process (system)
 
 main :: IO ()
-main = do
+main = withLibGitDo $ do
   putStrLn "Creating Git repository..."
   _ <- system "git init smoke.git"
 
   putStrLn "Accessing directly..."
-  c'git_threads_init
   alloca $ \ptr -> do
     withCString "smoke.git/.git" $ \str -> do
       r <- c'git_repository_open ptr str
       when (r < 0) $ exitWith (ExitFailure 1)
       peek ptr >>= c'git_repository_free
-  c'git_threads_shutdown
 
 -- Main.hs ends here
