Renamed some variables to emphasize the difference between the environment, which holds the functions, and the state, which holds the variables.