Cleans up the complex query merge.

Brin Gaffey