More robust error handling.
Clean up exception handling.