onshutdown hook for cleaning up. correcting links