tokenize bugfix and cleanup