Intellij idea code analysis

IntelliJ code analyser has some pretty good suggestions for improving code. I'm pretty sure I've fixed a bug or two along the way too.
This is only part 1, there are a ton more inspections that I haven't gone through yet.