Add __setstate__ and __getstate__

Allowing objects to be pickled and unpickled