Fix handling of queries with comments