Merge "Revert "Revert "Improve the thread flip."""