-merge from origin -Fixed thread statics.