Implemented multithreading to fix GUI freezing issues.