better shutdown; monir refactoring