Catch ClassCastExceptions when deserializing data