Refactor unlinking code
Merge pull request #902 from TalkTakesTime/patch-2

Refactor unlinking code