refactor mailer, libs and bewit