Refactor bits of exercise.js