Backport of switch fixes.