backport some enchancements from production