Refactor link destination fixing code