Fixed potentially incorreclty re-used global state.