fix getstate and setstate