Some tweaks of shutdown and logging