Backported from RCPTT

RCPTT commit f12adabf8a958254af14b5deb19a9c199cbda9e0