more reworking of the guts of the main community query system