Refactor amazon integration.