Adding serialization functions to bat class.