Updated codebook and fixed bugs in R