Various tweaks for paging, also factored out WdqQueryEngine class

* WHERE fixed for web queries
* Fixed UNION/INTERSECT/DIFFERENCE queries
* Other assorted fixes