Some refactoring about common java code.