Refactor worker creation and history submission logic