Cleanup and refactor. Move general link rendering out to functions.