Improvements to the query tool