Added some error handling
Removed unused classes