Fixing code to support Java 6