Add optional e-mail notifications; cleanup code