Fixed some possible bugs with email notification