Fix for issue #28

Fix for issue #28 : Removing a non referenced document used to delete the first document. Fixed in template such that it does nothing if the document is not referenced.