add ndbquery and fix a few small things