improved handling of links and references