    }
    catch (err) {
      actions.resultException(req, res, err);
+diff --git a/js/common/modules/simple-query-basics.js b/js/common/modules/simple-query-basics.js
+index 0840c2c..ed5daa1 100644
+--- a/js/common/modules/simple-query-basics.js
++++ b/js/common/modules/simple-query-basics.js
+@@ -150,6 +150,7 @@ GeneralArrayCursor.prototype._PRINT = function () {
+ ////////////////////////////////////////////////////////////////////////////////
+ 
+ GeneralArrayCursor.prototype.hasNext = function () {
++  require("console").log("hasNext called. current: " + this._current + ", stop: " + this._stop);
+   return this._current < this._stop;
+ }
+ 
+@@ -176,7 +177,8 @@ GeneralArrayCursor.prototype.dispose = function() {
+   this._limit = null;
+   this._countTotal = null;
+   this._countQuery = null;
+-  this.current = null;
++  this._current = null;
++  this._stop = null;
+ }
+ 
+ ////////////////////////////////////////////////////////////////////////////////
+@@ -663,7 +665,9 @@ SimpleQueryArray.prototype.execute = function () {
+       this._skip = 0;
+     }
+ 
++    require("console").log("creating GeneralArrayCursor with " + this._documents.length + " docs, skip: " + this._skip + ", limit: " + this._limit);
+     this._execution = new GeneralArrayCursor(this._documents, this._skip, this._limit);
++    require("console").log("created GeneralArrayCursor");
+   }
+ }
+ 
+diff --git a/js/server/ahuacatl.js b/js/server/ahuacatl.js
+index 665f723..1707ab4 100644
+--- a/js/server/ahuacatl.js
++++ b/js/server/ahuacatl.js
+@@ -385,7 +385,11 @@ function AHUACATL_LIST (value) {
+ ////////////////////////////////////////////////////////////////////////////////
+ 
+ function AHUACATL_GET_DOCUMENTS (collection) {
+-  return internal.db[collection].all().toArray();
++  require("console").log("AHUACATL_GET_DOCUMENTS called for " + collection);
++  var result = internal.db[collection].ALL(0, null).documents;
++  require("console").log("AHUACATL_GET_DOCUMENTS finished for " + collection);
++
++  return result;
+ }
+ 
+ ////////////////////////////////////////////////////////////////////////////////
+diff --git a/js/server/js-ahuacatl.h b/js/server/js-ahuacatl.h
+index 7bf2dd5..7ab98bc 100644
+--- a/js/server/js-ahuacatl.h
++++ b/js/server/js-ahuacatl.h
+@@ -386,7 +386,11 @@ static string JS_server_ahuacatl =
+   "////////////////////////////////////////////////////////////////////////////////\n"
+   "\n"
+   "function AHUACATL_GET_DOCUMENTS (collection) {\n"
+-  "  return internal.db[collection].all().toArray();\n"
++  "  require(\"console\").log(\"AHUACATL_GET_DOCUMENTS called for \" + collection);\n"
++  "  var result = internal.db[collection].ALL(0, null).documents;\n"
++  "  require(\"console\").log(\"AHUACATL_GET_DOCUMENTS finished for \" + collection);\n"
++  "\n"
++  "  return result;\n"
+   "}\n"
+   "\n"
+   "////////////////////////////////////////////////////////////////////////////////\n"
 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-optimiser.c b/arangod/Ahuacatl/ahuacatl-optimiser.c
index 49437aa..43d905b 100644
--- a/arangod/Ahuacatl/ahuacatl-optimiser.c

     FreeGenerator(generator);
 
     return NULL;
@@ -2283,9 +2287,11 @@ char* TRI_GenerateCodeAql (TRI_aql_context_t* const context) {
   FreeGenerator(generator);
 
   if (code) {
-    TRI_AQL_DUMP("generated code: %s\n", code);
+    TRI_AQL_LOG("generated code: %s\n", code);
   }
 
+  TRI_AQL_LOG("generating code successful");
