Adapted to SGE changes.