Fix issues with empty queries.