Changed iterator task in pmap to a function. Fixes #4035 and #4034
Merge pull request #4054 from amitmurthy/amitm/pmapfix

Changed iterator task in pmap to a function. Fixes #4035 and #4034