Fix an important bug in cloning the state.