Fix links at the end of documents being destroyed

[closes #40]