backporting from master