Added deallocation of states in the environment base class