bug fixes and ground work for emailed alerts