Fixes for WriteState.