Fix wait threading