Fix a long-standing bug which meant that rate limiting was not restrictive enough in some cases.