Improve jdk8 compatibility

Fixes #723