Refactor code to support building against Java 1.6