landed patch for bug 861338. more work for bug 877262