Fixed bugs with thread deaths and event passing.