added logging system so that a failed run can be restarted nearly immediately at the last failure