Improvements in error handling