Better exception handling.

Exception handling is better now.