CRUNCH-276: Various static checks and FindBugs fixes. Contributed by Sean Owen.