Backport some 2552212 changeset to 2.0

Signed-off-by: crynobone <crynobone@gmail.com>