Solved the issues with links not being removed when their posts are removed.