First version of script, bashed out in a half hour or so.