Minor cleanup of queries