Merged fixes for bugs 87366 and 87102 from trunk