Solved some issues found by findbugs/PMD