Ported changes from wayin RMBP