TODO: fix thread integration with gui