Refactored grader.js to be better engineered, more readable, and hopefully easier to read.