Migrate changes from v2.38 to v2.40