cleaned up the getstate/setstate stuff