Major refactoring to put all Tkinter GUI code on main thread.