Week 6 homework - misc refactorings.