updated serialization. It works but has trouble with immutables