Finally corrected computation of duplicate visits
Code clean up