Cherrypicked caed2ec