Fixing tokens generation and escaping the spans (fixes #3)