More query tidying.