MAIL module improvements

Hope this time travis gives green.

- fixed bug in handling BBCs
- general code improvements