generate token final version and other improvements