restore old behavior of token and add onMatch. fixes #1269