Improve code by fixing some PMD analysis errors.