Adding basic exception handling.