Merged fix for bug 87073 and 87006 from trunk