Major refactoring + support for multiple tokens.

This version is incompatible with the previous one. The users will have
to redefine their tokens.