Fix getstate and setstate for unified model