Updated to work with java 6