Fixed errors and PMD warnings