Port fix from 1.6 branch.
The fix for this that was applied to the 1.6 branch needs to be ported to the trunk. Apparently to code is different so a different fix may be needed.
Port fix from 1.6 branch.