fixed some bugs in the trove query code