Fixed dinstinct query and visitor reset