Refactor link helpers

Keep only required code. Code for functionality that isn't exercised is removed.