A bit more type safety

The previous commit fails on Java 6 for some reason.