Fix some bugs in script and add feature names to codebook