Minor clean up, fixed a bug on token validation