Added serialization capability. Some tests needed