Fix incorrect clearing of visit history