Make link selection detection much more robust