Refactor grid-engine tasks into master and worker