Improved Error handling.