Fix slow main thread