backporting 4ae5cb519cc2aa6ea806461a6972a1108a070384 to RTD
some back porting