Cleanup
Improved error handling