bugfixes to links (just some NULL checks). trying to understand why cat on the third time for a link fails