Cleaning up the file token handling code.
The logs are transferred twice - at the beginning of running a task, and after everything succeeds/fails. This way a remote machine will update the logs if these are not directly accessible.