Integrated Andrew's change. Both AWS api and Andrew's part is working fine.