Separate AI and UI into two different threads.