Completed basic testing of email message handling.

* Created a management task to send an email
* Fixed multi-email problem by locking the threshold object while sending emails
* Fixed improper formation of message body
Several more tweaks and bugfixes. Probably ready for staging...

* Added a cleanup for old events
* Scheduled the worker down check
* Fixed bug in the rate limiting
* Did check that will prevent double sending on rapid queue flush
Added database migrations