More changes for query and other cleanup