Refactor logic to synchronize active bach jobs and their script/environment files, reducing overhead dramatically for large numbers of active jobs. backport of commit 41eead64 bug 2220