Fix async calls causing deadlock when run on main threads.