Added email functionality & fixed some bugs