Alter comments

Not really blatantly stolen anymore since it's been changed a fair
amount
Localise some functions
Some code and style cleanup