Add better support for Java 7 and 8

Fixes #490