Ported to Java 8 (1.8.0_20) with lambdas