Clean up query data handling.