Pull role check out of function call.
Factory calculation outward.
Merge branch 'feature/fewerrolerefs' into develop