Token storage

Note that the tests for this are in the new separate repository, which has a corresponding pull request.