Fixed back-porting of 2a8603018159b1019ae9156e6b511503fc0c1238