Retry if EC2 reports server errors (HTTP 5xx)

EC2 limits the rate of requests one can make against the backend, which
sometimes has caused us to experience errors. Their
[http://docs.aws.amazon.com/general/latest/gr/api-retries.html](official
guidelines) state that one should retry in this case, with a delay. We
don't do the exponential backoff they suggest, however. We just wait a
little while between attempts.
Code cleanup

Minor cleanup to avoid repetition.