Fixing class cast exception.