Fix cast class exception