saves output to logfile and more sanity checks