Replaced several copies of a for loop with an arguably nicer n.times
construct. The fact that I had to replace this in several places
suggests that there's some duplicate code we could improve on.