cleanup and updates, added shutdown hooks and restored original ports