fix line endings, add validity checking to thread state