Fixes

A few fixes suggested by Intellij IDEA analyzer and FindBugs.