Main thread bug fix