fixes, refactoring, mailer