Fixed some bugs found with FindBugs.