Sync with bug 981029 and 980493