Added more to the query service and fixed a few bugs.