[export_links]Factor out actual link creation and make it more robust and expressive.