fix clearkeys to handle missing keys