finish codebook and readme, and refactor the code.