Throttling only the PIECE messages is definitely the way to go, there's no doubt about it. But yeah I'm not a fan of the magic numbers as well and the algorithm could be smarter. But it's a good first step. If you have some time you can contribute further improvements, or maybe I or somebody else will take a crack at it as well.