Added code to understand the gen query stuff a little better.