fixed bug 403, added logging to tcp and email