Improved error handling, etc.