Minor bug fixes and tweaks suggested by Findbugs and PMD.