3030 clean helper functions

These commits do some refactoring of the helper functions used in link creation.  It may be easier to review the changes by looking at the commits even with my bugfixes.  rather than just looking at the final changes together.

hopefully this helps simplify the helpers a little