Fix bugs in worker script.