A few fixes to make the script actually functional

Turns out this has just been sitting here broken since whenever.