Refactoring and clean up in grader.js