Fix code based on FindBugs