Rearrange querytools routines for clarity