Main driver for queries.