Fix checkstyle warings and removeduplicate code.