Cleanup query.py