Set of fixes suggered by findbugs and PMD