Minor refactoring of java code