A few changes found by using IntelliJ's analyze feature

I found a few things by using IntelliJ's analyze feature and fixed them up.