Fixed issues found when porting to AWS.