Fix and improve inter-document linking