Added the start of some of the linking code.
Still need to select whether to do the second pass at compile time
Still need to rename link to a function to do with second pass
Still need to swap between dereference and not for apply parameters