Fixed some issues with error handling.