Replaced some uses of wait() by wait_all()
unwrapped