clean shutdown; small changes