worker: code cleanups in worker.py