Vik/staff refactor

@nedbat @natea I was trying to debug some staff grading issues with ORA, and refactored a part of it to make it easier.  I may refactor more later, but this is a good "intro" piece of code to review for ORA.