fixed token handling

see Ábel's comments @110b482bc66f0c849f32857eeff5cc14d37ef11d