Check tokens before trimming. Should fix #2