Fix Long class cast exception