Bug fix for queries.