added codebook serialization