Fix the ClassCastExceptions