Ensure temp files are only accessed by the correct thread

It appears the problems may have been caused by threads simultaneously
accessing the same temp files, such that they were executed multiple times
on certain hosts and never on others. This change prevents this by appending
the hostname to all temporary files, so they will only be accessed by the
correct thread.
A work in progress, worker script, and an updated template