Various token handling fixes