diff -ur psi4.0b5.orig/src/bin/detci/tpool.cc psi4.0b5/src/bin/detci/tpool.cc
--- psi4.0b5.orig/src/bin/detci/tpool.cc	2013-07-01 23:11:05.000000000 +0200
+++ psi4.0b5/src/bin/detci/tpool.cc	2013-09-24 16:00:34.584896769 +0200
@@ -78,7 +78,7 @@
   tpool->queue_tail = NULL;
   tpool->queue_closed = 0;  
   tpool->shutdown = 0; 
-  tpool->threads_awake = 0;
+  tpool->threads_awake = num_worker_threads;
   if ((rtn = pthread_mutex_init(&(tpool->queue_lock), NULL)) != 0){
     str = "pthread_mutex_init ";
     str += strerror(rtn);
@@ -115,7 +115,6 @@
       str += boost::lexical_cast<std::string>( rtn) ;
       throw PsiException(str,__FILE__,__LINE__);
   }
-    tpool->threads_awake++;
   }
 
   *tpoolp = tpool;
diff --git a/src/bin/detci/tpool.cc b/src/bin/detci/tpool.cc
index ab42c9a..cfbffa2 100644
--- a/src/bin/detci/tpool.cc
+++ b/src/bin/detci/tpool.cc
@@ -284,10 +284,22 @@ int tpool_destroy(tpool_t          tpool,
 }
 void tpool_queue_open(tpool_t tpool)
 {
-  pthread_mutex_lock(&tpool->queue_lock);
+  int rtn;
+  std::string str;
+
+  if ((rtn = pthread_mutex_lock(&(tpool->queue_lock))) != 0){
+      str = "pthread_mutex_lock ";
+      str += boost::lexical_cast<std::string>( rtn) ;
+      throw PsiException(str,__FILE__,__LINE__);
+  }
+
   tpool->queue_closed = 0;
-  tpool->threads_awake = 0;
-  pthread_mutex_unlock(&tpool->queue_lock);
+
+  if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0){
+      str = "pthread_mutex_unlock ";
+      str += boost::lexical_cast<std::string>( rtn) ;
+      throw PsiException(str,__FILE__,__LINE__);
+  }
 }
   
 void tpool_queue_close(tpool_t tpool, int finish)
@@ -295,7 +307,12 @@ void tpool_queue_close(tpool_t tpool, int finish)
   std::string str;
   int rtn;
   
-  pthread_mutex_lock(&tpool->queue_lock);
+  if ((rtn = pthread_mutex_lock(&(tpool->queue_lock))) != 0){
+      str = "pthread_mutex_lock ";
+      str += boost::lexical_cast<std::string>( rtn) ;
+      throw PsiException(str,__FILE__,__LINE__);
+  }
+
   tpool->queue_closed = 1;
   
   if (finish) {
@@ -309,7 +326,11 @@ void tpool_queue_close(tpool_t tpool, int finish)
     
     }
   
-  pthread_mutex_unlock(&tpool->queue_lock);
+  if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0){
+      str = "pthread_mutex_unlock ";
+      str += boost::lexical_cast<std::string>( rtn) ;
+      throw PsiException(str,__FILE__,__LINE__);
+  }
   
 }
   
