And changed related_query_name to a singular noun. Backport of 130192b12b63357a8f5ff448cd0edfa5a8094909 from master.