Limit GUI calls to the main thread

GTK backend of wxWidgets has some issues related with many threads touching the GUI. @Bigpet fixed some code here dad82aa.