Make #executeQuery return a deferred instead of an iterator and use new query implementation