I don't quite know what I did here, as I was in a haze of coding stupor
while doing it.