Corrected thread related errors.