Fixed Query_tree bugs