Added the possibility to serialize a state