Fix several dozens of errors/warnings reported by FindBugs