Add $thread, fix some encoding issues (again)