Fixes in queries.py