Added serialization and de-serialization functions.