ClassCastException fixes