pretty much ground up rewrite of linking process