fixed problems with ClassCastExceptions