I think the issue has been solved in this post.
Alternatively, if you want to remove the last layers and keep the layers till you want link.