CAPEDWARF-120 Reimplement pull task leasing
Fix env counter.