query processing fixes