Codebook saving function fixed