Fix bug in mailing of success/error and remove debug code