Revised escaping of queries.