add rate limit calculation, fixes #5 and #7