Added log-file error checking and emails upon errors