We should be recording only the N closest hits in case the number of hits is exceeding the maximum allowed or the size of the hits stack. Previously, some cases made it record hits beyond the furthest recorded one due to lack of hit distance check.