Added logging, fixed email, minor bug fixes