Included mail functionality and tidied up database.