add basic conversion between tok and str

hopefully using Maps here will make this
actually run faster than the old version