Moved non-gui logic into a dedicated thread