Various generic changes from the use-mail branch