Figured out that main thread is causing deadlock, and sleep fixes that for now.