Fix threading issue with GUI. #1443 #1444