fixed some code related to exception handling and mail notification.