Fix/pmd warnings

This set of patches fix a number of PMD high priority warnings.