General tidy up: dropped various unused variables, leftover code, fixed spelling, missing semicolons, etc

Hopefully this is useful; intellij was throwing up lots of warnings everywhere as I was working on other things, so I've gone through and cleaned up the obviously messy bits.