refactorings, first implementation of the serialization