add comment for fail()
quote all variables
start with the code cleanup
license boilerplate in the script itself

Normally I avoid this, but it sorta makes sense for scripts (which tend
to be pasted around a lot). Hopefully no one will have the heart to
delete it.
license year bump: 2013-2014 now