I realize this algorithm is broken. We invalidate some keys in
_find_bad_keys that could actually be perfectly fine. However, it seems to
work ok for now, and this is all just a lame adhoc method. Maybe someday we
can revisit this and make it a bit less ghetto…