Added some fixes for transaction.

Refactored mail creation.