Fix imports
Fix hang on start on Mac
Refactor thread util
Fix merge window closing despite canceling close
Remove debugging messages