Ported to Java 7