fix token and some other bugs