Added token stream sanitizer function