Improved error handling
General clean-up