Some more changes to manage visited list