Moved main to a thread.