Extract many tiny functions

This PR is a bit of a mess, for which I apologize. I tried to extract and use lots of tiny functions, simplify others, add support for using `wget` exclusively, delay doing actual work until after the sanity checks.

The original script switched its style from lots of functions to large braindump somewhere in the middle, this is mostly an attempt to move it in the direction of the former.

It also closes #3 and #4. Please let me know what kinds of cleanup you'd like.