Fix class cast exception
Fix warnings