Added some logging, email logging not working yet.