Added error logging to tokenization