Another ClassCastException bug fix