debugged some errors from token code.

many bugs to go.