backport from cm11 branch