Added cast exception throwing.