Added monitoring of api rate limits and waiting for replenishment.

Should address issue #254.