Refactoring of worker threads logic.