Improved shutdown.
Minor changes.