Lot of fixes. The mutex test is passed.