Fixed unicode error
Remove unused imports
Replaced deprecated has_key function