Implement memory and serialization functions