Added log files, better shutdown