code cleanups, added email validity check