  /// @brief V8 startup loader
  ////////////////////////////////////////////////////////////////////////////////
  
+diff --git a/arangod/V8Server/v8-query.cpp b/arangod/V8Server/v8-query.cpp
+index 0ca033a..e737007 100755
+--- a/arangod/V8Server/v8-query.cpp
++++ b/arangod/V8Server/v8-query.cpp
+@@ -35,6 +35,7 @@
+ #include "V8/v8-conv.h"
+ #include "V8/v8-utils.h"
+ #include "V8Server/v8-vocbase.h"
++#include "Logger/Logger.h"
+ 
+ // -----------------------------------------------------------------------------
+ // --SECTION--                                                  HELPER FUNCTIONS
+@@ -1210,6 +1211,7 @@ static v8::Handle<v8::Value> EdgesQuery (TRI_edge_direction_e direction, v8::Arg
+ static v8::Handle<v8::Value> JS_AllQuery (v8::Arguments const& argv) {
+   v8::HandleScope scope;
+ 
++  LOGGER_TRACE << "executing ALL query";
+   // extract and use the simple collection
+   v8::Handle<v8::Object> err;
+   TRI_vocbase_col_t const* collection;
+@@ -1243,10 +1245,15 @@ static v8::Handle<v8::Value> JS_AllQuery (v8::Arguments const& argv) {
+   // inside a read transaction
+   // .............................................................................
+ 
+-  collection->_collection->beginRead(collection->_collection);
++  LOGGER_TRACE << "acquiring lock in allquery";
++  int lockResult = collection->_collection->beginRead(collection->_collection);
++  LOGGER_TRACE << "result of beginRead: " << lockResult;
+ 
+   size_t total = sim->_primaryIndex._nrUsed;
+   uint32_t count = 0;
++  LOGGER_TRACE << "number of documents: " << total;
++  LOGGER_TRACE << "skip: " << skip;
++  LOGGER_TRACE << "limit: " << limit;
+ 
+   if (0 < total && 0 < limit) {
+     TRI_barrier_t* barrier = 0;
+@@ -1254,6 +1261,9 @@ static v8::Handle<v8::Value> JS_AllQuery (v8::Arguments const& argv) {
+     void** beg = sim->_primaryIndex._table;
+     void** end = sim->_primaryIndex._table + sim->_primaryIndex._nrAlloc;
+     void** ptr = beg;
++    LOGGER_TRACE << "nrAlloc: " << sim->_primaryIndex._nrAlloc;
++    LOGGER_TRACE << "begin: " << beg;
++    LOGGER_TRACE << "end: " << beg;
+ 
+     // skip from the beginning
+     if (0 < skip) {
+@@ -1291,6 +1301,7 @@ static v8::Handle<v8::Value> JS_AllQuery (v8::Arguments const& argv) {
+       }
+     }
+ 
++    LOGGER_TRACE << "beginning extraction. ptr: " << ptr << ", end: " << end << ", range: " << (end - ptr) << ", count: " << count << ", limit: " << limit;
+     // limit
+     for (;  ptr < end && count < limit;  ++ptr) {
+       if (*ptr) {
+@@ -1307,9 +1318,11 @@ static v8::Handle<v8::Value> JS_AllQuery (v8::Arguments const& argv) {
+         }
+       }
+     }
++    LOGGER_TRACE << "finished extraction. count is " << count;
+   }
+ 
+   collection->_collection->endRead(collection->_collection);
++  LOGGER_TRACE << "endRead";
+ 
+   // .............................................................................
+   // outside a write transaction
 diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp
 index 9bd6923..8b7aad7 100755
 --- a/arangod/V8Server/v8-vocbase.cpp

   }
   catch (err) {
     actions.resultException(req, res, err);
diff --git a/lib/Basics/ConditionLocker.cpp b/lib/Basics/ConditionLocker.cpp
index e9469e6..097ef7b 100644
--- a/lib/Basics/ConditionLocker.cpp

 
   return true;
 }
diff --git a/arangod/Ahuacatl/ahuacatl-log.h b/arangod/Ahuacatl/ahuacatl-log.h
index f8e92b7..aa5cf5e 100644
--- a/arangod/Ahuacatl/ahuacatl-log.h
+++ b/arangod/Ahuacatl/ahuacatl-log.h
@@ -35,7 +35,7 @@ extern "C" {
 #endif
 
 #undef TRI_DEBUG_AQL  
-//#define TRI_DEBUG_AQL 1
+#define TRI_DEBUG_AQL 1
 
 // -----------------------------------------------------------------------------
 // --SECTION--                                                     public macros
@@ -52,10 +52,8 @@ extern "C" {
 
 #ifdef TRI_DEBUG_AQL
 #define TRI_AQL_LOG(...) LOG_INFO(__VA_ARGS__);
-#define TRI_AQL_DUMP(format, ...) printf(format, __VA_ARGS__);
 #else
 #define TRI_AQL_LOG(...) LOG_TRACE(__VA_ARGS__);
-#define TRI_AQL_DUMP(...) { };
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/arangod/Ahuacatl/ahuacatl-optimiser.c b/arangod/Ahuacatl/ahuacatl-optimiser.c
index 49437aa..43d905b 100644
--- a/arangod/Ahuacatl/ahuacatl-optimiser.c
