Bug 6581 - Move definition of PWD higher than where it is initially used