Worker threads, refactoring