Updated for compatability with Java 1.6