Fixed minor threading issue