Improve global handling of state variables.