tokens implementation, db script, refactoring