When the keyword list is emitted, COUNT isn't re-initialized to zero, which causes wrong values to be written to the hash table.
Created attachment 9890 [details] [review]
Patch that fixes the bug
Created attachment 9891 [details] [review]
I guess I should provide a full git commit, here it is.
Wow. That was a dumb bug and a clear fix, which I've pushed. Thanks!
For what it's worth, your second attachment still wasn't a commit I could apply with git-am; you want git-format-patch for that.