Fix java.lang.ClassCastException issue #1