Fixed a class cast exception.