Factor out the role parsing.