Cleaned up exception handling.