Split generator into a web worker so the UI doesn't hang.