DynamoDB error handling and minor bug fix