fixed a single typo right at start of script
added a vim modeline so tabs are converted to spaces and backspace works magically, cleaned up quite a lot whitespace.
updated comments and put my name into it, so it's clear who is to be blamed :)