Added complex thread sleeping.