Fix bug where the token was not being reliably determined.