Refactor based on machine roles