Refactor robot and master