Avoid class cast exception.