Refactor query translating tools