Code copied from local.