Fixing some potential bugs found by FindBugs.