fix bug in token deserialization

  * clean up code a bit