Adapted to latest API changes/moved to Java 8.