Fixed background thread bug