Fix problems caused by some scoping