Made changes (from Assignment 1 baseline) recommended by Dominic Heale