Fixed various bugs introduced by new token handling