Bug fixes towards QueryUtils