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.

P.S. I suggest reading this commit by commit, otherwise it might seem too random.
You forgot to remove useless L2Armor import.