Added checks for null
Removed unused method
Removed unused import