The kept-key bugfix was inmproved and generalized