Implement TokenToAtom, refactor