Refactor utilities for Java code