Refactor how token class is determined