Modified code to support Java 6.