Prevent class cast exception.