Fix bug with thread, changed gui on wrong thread