Added teardown things

All these link and link-remove functions are added to this script.
This to make it more clear where it is and keep maintenance low.