add DynamoDB & SES support, refactor code