Implemented serialization.