Modified link creation so that it doesn't break when a non-rectangle is selected.