Fix multiple thread issues.