refactoring, logging, async mail sending