Fixes applied in mainline