Fixed memory leaks in worker