Merge fix for bug 986 from 1.0.x branch.