query transformation improvements